Handle use of default member initializers before end of outermost class
authorReid Kleckner <reid@kleckner.net>
Mon, 17 Nov 2014 23:36:45 +0000 (23:36 +0000)
committerReid Kleckner <reid@kleckner.net>
Mon, 17 Nov 2014 23:36:45 +0000 (23:36 +0000)
commitd60b82f93eee090650d848c45f34dcf9d3ffa0ea
tree248e4025074de0fb3c720dbad97942efe0d18b08
parentf39c3b8108c34148e6f03cbd0907619020c1a9eb
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
15 files changed:
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/DeclBase.cpp
clang/lib/AST/Expr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp
clang/test/CXX/temp/temp.param/p5.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/implicit-exception-spec.cpp
clang/test/SemaCXX/member-init.cpp
clang/test/SemaTemplate/instantiate-init.cpp