diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-12-07 00:22:08 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-12-07 00:22:08 +0000 |
commit | d0e8de2cd82ebd517493626a503dbbc6d1f74430 (patch) | |
tree | 2d19ff78dba5fbef98f8d1db71bec126e15d7a6a /clang/lib/Sema/SemaDecl.cpp | |
parent | 75b6f62d686a999aa048c6ed32d422d01e434782 (diff) | |
download | bcm5719-llvm-d0e8de2cd82ebd517493626a503dbbc6d1f74430.tar.gz bcm5719-llvm-d0e8de2cd82ebd517493626a503dbbc6d1f74430.zip |
Move RequireCompleteType requirement for fields early into ActOnField so that
subsequent code which depends on a complete type does the right thing.
llvm-svn: 90727
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 0fa5780e982..01314c31cf4 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5044,9 +5044,14 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, T = Context.IntTy; } + QualType EltTy = Context.getBaseElementType(T); + if (!EltTy->isDependentType() && + RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) + InvalidDecl = true; + // C99 6.7.2.1p8: A member of a structure or union may have any type other // than a variably modified type. - if (T->isVariablyModifiedType()) { + if (!InvalidDecl && T->isVariablyModifiedType()) { bool SizeIsNegative; QualType FixedTy = TryToFixInvalidVariablyModifiedType(T, Context, SizeIsNegative); @@ -5063,13 +5068,15 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, } // Fields can not have abstract class types - if (RequireNonAbstractType(Loc, T, diag::err_abstract_type_in_decl, - AbstractFieldType)) + if (!InvalidDecl && RequireNonAbstractType(Loc, T, + diag::err_abstract_type_in_decl, + AbstractFieldType)) InvalidDecl = true; bool ZeroWidth = false; // If this is declared as a bit-field, check the bit-field. - if (BitWidth && VerifyBitField(Loc, II, T, BitWidth, &ZeroWidth)) { + if (!InvalidDecl && BitWidth && + VerifyBitField(Loc, II, T, BitWidth, &ZeroWidth)) { InvalidDecl = true; DeleteExpr(BitWidth); BitWidth = 0; @@ -5088,8 +5095,6 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T, } if (getLangOptions().CPlusPlus) { - QualType EltTy = Context.getBaseElementType(T); - CXXRecordDecl* CXXRecord = cast<CXXRecordDecl>(Record); if (!T->isPODType()) @@ -5432,8 +5437,10 @@ void Sema::ActOnFields(Scope* S, // If the field is already invalid for some reason, don't emit more // diagnostics about it. - if (FD->isInvalidDecl()) + if (FD->isInvalidDecl()) { + EnclosingDecl->setInvalidDecl(); continue; + } // C99 6.7.2.1p2: // A structure or union shall not contain a member with |