diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2012-02-07 05:00:47 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2012-02-07 05:00:47 +0000 |
commit | 11e70d7fe2eb11874c3619ad26dc2b525b81074f (patch) | |
tree | 556e6a6fde17d55ffa91e109cb841a4fff621bb0 /lib/Sema/SemaDecl.cpp | |
parent | 04ca25276245fbcf0a353e965de476080fa01b99 (diff) |
Fix a bug in semantic analysis involving anonymous structs and flexible arrays.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index c44b474e80..ffc7c61872 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9171,11 +9171,23 @@ void Sema::ActOnFields(Scope* S, if (EnclosingDecl->isInvalidDecl()) return; - // Verify that all the fields are okay. + RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl); + + // Start counting up the number of named members; make sure to include + // members of anonymous structs and unions in the total. unsigned NumNamedMembers = 0; + if (Record) { + for (RecordDecl::decl_iterator i = Record->decls_begin(), + e = Record->decls_end(); i != e; i++) { + if (IndirectFieldDecl *IFD = dyn_cast<IndirectFieldDecl>(*i)) + if (IFD->getDeclName()) + ++NumNamedMembers; + } + } + + // Verify that all the fields are okay. SmallVector<FieldDecl*, 32> RecFields; - RecordDecl *Record = dyn_cast<RecordDecl>(EnclosingDecl); bool ARCErrReported = false; for (llvm::ArrayRef<Decl *>::iterator i = Fields.begin(), end = Fields.end(); i != end; ++i) { |