diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-11-17 23:36:45 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-11-17 23:36:45 +0000 |
commit | d60b82f93eee090650d848c45f34dcf9d3ffa0ea (patch) | |
tree | 248e4025074de0fb3c720dbad97942efe0d18b08 /clang/lib/AST/DeclBase.cpp | |
parent | f39c3b8108c34148e6f03cbd0907619020c1a9eb (diff) | |
download | bcm5719-llvm-d60b82f93eee090650d848c45f34dcf9d3ffa0ea.tar.gz bcm5719-llvm-d60b82f93eee090650d848c45f34dcf9d3ffa0ea.zip |
Handle use of default member initializers before end of outermost class
Specifically, when we have this situation:
struct A {
template <typename T> struct B {
int m1 = sizeof(A);
};
B<int> m2;
};
We can't parse m1's initializer eagerly because we need A to be
complete. Therefore we wait until the end of A's class scope to parse
it. However, we can trigger instantiation of B before the end of A,
which will attempt to instantiate the field decls eagerly, and it would
build a bad field decl instantiation that said it had an initializer but
actually lacked one.
Fixed by deferring instantiation of default member initializers until
they are needed during constructor analysis. This addresses a long
standing FIXME in the code.
Fixes PR19195.
Reviewed By: rsmith
Differential Revision: http://reviews.llvm.org/D5690
llvm-svn: 222192
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 014e3f9ef55..a46787fb0e8 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1441,6 +1441,17 @@ DeclContext *DeclContext::getEnclosingNamespaceContext() { return Ctx->getPrimaryContext(); } +RecordDecl *DeclContext::getOuterLexicalRecordContext() { + // Loop until we find a non-record context. + RecordDecl *OutermostRD = nullptr; + DeclContext *DC = this; + while (DC->isRecord()) { + OutermostRD = cast<RecordDecl>(DC); + DC = DC->getLexicalParent(); + } + return OutermostRD; +} + bool DeclContext::InEnclosingNamespaceSetOf(const DeclContext *O) const { // For non-file contexts, this is equivalent to Equals. if (!isFileContext()) |