summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorErik Verbruggen <erikjv@me.com>2016-10-27 08:37:14 +0000
committerErik Verbruggen <erikjv@me.com>2016-10-27 08:37:14 +0000
commit52b26713bebf3a6724d924a10719fb9ab936e694 (patch)
treeae8f5170b1a8893464e540f4053ce68ffe2b2f2a /clang/lib/Sema
parentdd680cc753f4874cc5bd1e4680676cb6c3f5f8df (diff)
downloadbcm5719-llvm-52b26713bebf3a6724d924a10719fb9ab936e694.tar.gz
bcm5719-llvm-52b26713bebf3a6724d924a10719fb9ab936e694.zip
Mark invalid RecordDecls as completed.
Sema::ActOnTag creates TagDecls for records. However, if those record declarations are invalid, and the parser is in C++ mode, it would silently drop the TagDecl (and leave it as "beingDefined"). The problem is that other code (e.g. the ASTWriter) will serialize all types, and expects them to be complete. So, leaving them open would result in failing asserts. Fixes PR20320 Differential Revision: http://reviews.llvm.org/D21176 llvm-svn: 285275
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e9e0f5e214d..c8973ae100e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13386,7 +13386,14 @@ CreateNewDecl:
OwnedDecl = true;
// In C++, don't return an invalid declaration. We can't recover well from
// the cases where we make the type anonymous.
- return (Invalid && getLangOpts().CPlusPlus) ? nullptr : New;
+ if (Invalid && getLangOpts().CPlusPlus) {
+ if (New->isBeingDefined())
+ if (auto RD = dyn_cast<RecordDecl>(New))
+ RD->completeDefinition();
+ return nullptr;
+ } else {
+ return New;
+ }
}
void Sema::ActOnTagStartDefinition(Scope *S, Decl *TagD) {
OpenPOWER on IntegriCloud