diff options
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 18 |
2 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index e11e161ffde..f5f2f947586 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5261,6 +5261,10 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, FieldDecl *NewFD = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, TSSL, AS, PrevDecl, &D); + + if (NewFD->isInvalidDecl()) + Record->setInvalidDecl(); + if (NewFD->isInvalidDecl() && PrevDecl) { // Don't introduce NewFD into scope; there's already something // with the same name in the same scope. diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index a79853afdc6..80e1a051115 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1942,6 +1942,16 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, if (diag == 0) return true; + const TagType *Tag = 0; + if (const RecordType *Record = T->getAs<RecordType>()) + Tag = Record; + else if (const EnumType *Enum = T->getAs<EnumType>()) + Tag = Enum; + + // Avoid diagnosing invalid decls as incomplete. + if (Tag && Tag->getDecl()->isInvalidDecl()) + return true; + // We have an incomplete type. Produce a diagnostic. Diag(Loc, PD) << T; @@ -1950,13 +1960,7 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, Diag(Note.first, Note.second); // If the type was a forward declaration of a class/struct/union - // type, produce - const TagType *Tag = 0; - if (const RecordType *Record = T->getAs<RecordType>()) - Tag = Record; - else if (const EnumType *Enum = T->getAs<EnumType>()) - Tag = Enum; - + // type, produce a note. if (Tag && !Tag->getDecl()->isInvalidDecl()) Diag(Tag->getDecl()->getLocation(), Tag->isBeingDefined() ? diag::note_type_being_defined |

