[PATCH] Handle use of default member initializers before end of outermost class
Reid Kleckner
rnk at google.com
Wed Oct 8 18:31:08 PDT 2014
Hi rsmith,
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 doing template instantiation when building a CXXDefaultInitExpr
and erorring out if the initializer is missing for any other reason.
Fixes PR19195.
This does *not* defer all field instantiation until later, as that
causes assertions in the test suite. Fixing that might be the right
thing to do, but I wanted feedback on the approach so far first.
http://reviews.llvm.org/D5690
Files:
include/clang/AST/ExprCXX.h
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaTemplateInstantiate.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
test/SemaCXX/constant-expression-cxx11.cpp
test/SemaCXX/implicit-exception-spec.cpp
test/SemaCXX/member-init.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5690.14620.patch
Type: text/x-patch
Size: 20770 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141009/b8aa6b11/attachment.bin>
More information about the cfe-commits
mailing list