forked from OSchip/llvm-project
Fix PR8796.
The problem was that we were asserting the we never added an empty class to the same offset twice. This is not true for unions, where two members, empty or not, can have the some offset. llvm-svn: 122633
This commit is contained in:
parent
bd530a8e83
commit
7bcde197d7
|
@ -216,10 +216,12 @@ void EmptySubobjectMap::AddSubobjectAtOffset(const CXXRecordDecl *RD,
|
|||
if (!RD->isEmpty())
|
||||
return;
|
||||
|
||||
// If we have empty structures inside an union, we can assign both
|
||||
// the same offset. Just avoid pushing them twice in the list.
|
||||
ClassVectorTy& Classes = EmptyClassOffsets[Offset];
|
||||
assert(std::find(Classes.begin(), Classes.end(), RD) == Classes.end() &&
|
||||
"Duplicate empty class detected!");
|
||||
|
||||
if (std::find(Classes.begin(), Classes.end(), RD) != Classes.end())
|
||||
return;
|
||||
|
||||
Classes.push_back(RD);
|
||||
|
||||
// Update the empty class offset.
|
||||
|
|
|
@ -53,6 +53,19 @@ int f() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
namespace PR8796 {
|
||||
struct FreeCell {
|
||||
};
|
||||
union ThingOrCell {
|
||||
FreeCell t;
|
||||
FreeCell cell;
|
||||
};
|
||||
struct Things {
|
||||
ThingOrCell things;
|
||||
};
|
||||
Things x;
|
||||
}
|
||||
|
||||
#ifdef HARNESS
|
||||
extern "C" void printf(const char *, ...);
|
||||
|
||||
|
|
Loading…
Reference in New Issue