mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 11:35:51 -04:00
[ODRHash] Fix wrong error message with bitfields and mutable.
Add a check to bitfield mismatches that may have caused Clang to give an error about the bitfield instead of being mutable.
This commit is contained in:
parent
36eedfcb3c
commit
a60e892729
@ -10094,14 +10094,22 @@ void ASTReader::diagnoseOdrViolations() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsFirstBitField && IsSecondBitField) {
|
if (IsFirstBitField && IsSecondBitField) {
|
||||||
ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
|
unsigned FirstBitWidthHash =
|
||||||
FieldDifferentWidthBitField)
|
ComputeODRHash(FirstField->getBitWidth());
|
||||||
<< FirstII << FirstField->getBitWidth()->getSourceRange();
|
unsigned SecondBitWidthHash =
|
||||||
ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
|
ComputeODRHash(SecondField->getBitWidth());
|
||||||
FieldDifferentWidthBitField)
|
if (FirstBitWidthHash != SecondBitWidthHash) {
|
||||||
<< SecondII << SecondField->getBitWidth()->getSourceRange();
|
ODRDiagError(FirstField->getLocation(),
|
||||||
Diagnosed = true;
|
FirstField->getSourceRange(),
|
||||||
break;
|
FieldDifferentWidthBitField)
|
||||||
|
<< FirstII << FirstField->getBitWidth()->getSourceRange();
|
||||||
|
ODRDiagNote(SecondField->getLocation(),
|
||||||
|
SecondField->getSourceRange(),
|
||||||
|
FieldDifferentWidthBitField)
|
||||||
|
<< SecondII << SecondField->getBitWidth()->getSourceRange();
|
||||||
|
Diagnosed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool IsFirstMutable = FirstField->isMutable();
|
const bool IsFirstMutable = FirstField->isMutable();
|
||||||
|
@ -310,6 +310,20 @@ S9 s9;
|
|||||||
// expected-note@first.h:* {{but in 'FirstModule' found mutable field 'x'}}
|
// expected-note@first.h:* {{but in 'FirstModule' found mutable field 'x'}}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(FIRST)
|
||||||
|
struct S9b {
|
||||||
|
mutable int x : 2;
|
||||||
|
};
|
||||||
|
#elif defined(SECOND)
|
||||||
|
struct S9b {
|
||||||
|
int x : 2;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
S9b s9b;
|
||||||
|
// expected-error@second.h:* {{'Field::S9b' has different definitions in different modules; first difference is definition in module 'SecondModule' found non-mutable field 'x'}}
|
||||||
|
// expected-note@first.h:* {{but in 'FirstModule' found mutable field 'x'}}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(FIRST)
|
#if defined(FIRST)
|
||||||
struct S10 {
|
struct S10 {
|
||||||
unsigned x = 5;
|
unsigned x = 5;
|
||||||
@ -372,7 +386,9 @@ S13 s13;
|
|||||||
unsigned c : 1 + 2; \
|
unsigned c : 1 + 2; \
|
||||||
s d; \
|
s d; \
|
||||||
double e = 1.0; \
|
double e = 1.0; \
|
||||||
long f[5];
|
long f[5]; \
|
||||||
|
mutable int g; \
|
||||||
|
mutable int h : 5;
|
||||||
|
|
||||||
#if defined(FIRST) || defined(SECOND)
|
#if defined(FIRST) || defined(SECOND)
|
||||||
typedef short s;
|
typedef short s;
|
||||||
|
Loading…
Reference in New Issue
Block a user