diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-03 15:18:25 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-03 15:18:25 +0000 |
commit | fe60f84c4f201c9ca8126066779da8ee004a70fc (patch) | |
tree | 20a93229fc594039660d84491ec631463100013e /lib/Sema/SemaDecl.cpp | |
parent | e99bdb6969ec16d2829ccdf62b04a8c8eda8b215 (diff) |
When a class contains a non-empty anonymous union or struct, mark is
as non-empty. Fixes PR7021.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102913 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 3e4c923285..eb91ec6147 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1773,8 +1773,11 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, TInfo, /*BitWidth=*/0, /*Mutable=*/false); Anon->setAccess(AS_public); - if (getLangOptions().CPlusPlus) + if (getLangOptions().CPlusPlus) { FieldCollector->Add(cast<FieldDecl>(Anon)); + if (!cast<CXXRecordDecl>(Record)->isEmpty()) + cast<CXXRecordDecl>(OwningClass)->setEmpty(false); + } } else { DeclSpec::SCS SCSpec = DS.getStorageClassSpec(); assert(SCSpec != DeclSpec::SCS_typedef && @@ -1802,7 +1805,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, // context. We'll be referencing this object when we refer to one of // its members. Owner->addDecl(Anon); - + // Inject the members of the anonymous struct/union into the owning // context and into the identifier resolver chain for name lookup // purposes. |