diff options
| author | Erik Verbruggen <erikjv@me.com> | 2016-10-27 08:37:14 +0000 |
|---|---|---|
| committer | Erik Verbruggen <erikjv@me.com> | 2016-10-27 08:37:14 +0000 |
| commit | 52b26713bebf3a6724d924a10719fb9ab936e694 (patch) | |
| tree | ae8f5170b1a8893464e540f4053ce68ffe2b2f2a /clang/lib | |
| parent | dd680cc753f4874cc5bd1e4680676cb6c3f5f8df (diff) | |
| download | bcm5719-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')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 9 |
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) { |

