aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-03-21 22:56:43 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-03-21 22:56:43 +0000
commit01620704304f819b82ecef769ec114e541a364d7 (patch)
tree156056bbd0e9dcf77a4971756a44875c2e88e096 /lib/Sema/SemaType.cpp
parent2d52be56ff595341be3c6cec337af6763804ce66 (diff)
Fix PR6618.
If a struct has an invalid field, mark it as invalid. Also avoid producing errors about incomplete types that are invalid. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index a79853afdc..80e1a05111 100644
--- a/lib/Sema/SemaType.cpp
+++ b/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