summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/implicit-exception-spec.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-11-17 23:36:45 +0000
committerReid Kleckner <reid@kleckner.net>2014-11-17 23:36:45 +0000
commitd60b82f93eee090650d848c45f34dcf9d3ffa0ea (patch)
tree248e4025074de0fb3c720dbad97942efe0d18b08 /clang/test/SemaCXX/implicit-exception-spec.cpp
parentf39c3b8108c34148e6f03cbd0907619020c1a9eb (diff)
downloadbcm5719-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/test/SemaCXX/implicit-exception-spec.cpp')
-rw-r--r--clang/test/SemaCXX/implicit-exception-spec.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/clang/test/SemaCXX/implicit-exception-spec.cpp b/clang/test/SemaCXX/implicit-exception-spec.cpp
index d9532580bd1..ff3d685d912 100644
--- a/clang/test/SemaCXX/implicit-exception-spec.cpp
+++ b/clang/test/SemaCXX/implicit-exception-spec.cpp
@@ -17,31 +17,33 @@ namespace InClassInitializers {
// is false.
bool ThrowSomething() noexcept(false);
struct ConstExpr {
- bool b = noexcept(ConstExpr()) && ThrowSomething(); // expected-error {{cannot be used by non-static data member initializer}}
+ bool b = noexcept(ConstExpr()) && ThrowSomething(); // expected-error {{cannot use defaulted default constructor of 'ConstExpr' within the class outside of member functions}}
+ // expected-note@-1 {{implicit default constructor for 'InClassInitializers::ConstExpr' first required here}}
};
- // We can use it now.
- bool w = noexcept(ConstExpr());
// Much more obviously broken: we can't parse the initializer without already
// knowing whether it produces a noexcept expression.
struct TemplateArg {
- int n = ExceptionIf<noexcept(TemplateArg())>::f(); // expected-error {{cannot be used by non-static data member initializer}}
+ int n = ExceptionIf<noexcept(TemplateArg())>::f(); // expected-error {{cannot use defaulted default constructor of 'TemplateArg' within the class outside of member functions}}
+ // expected-note@-1 {{implicit default constructor for 'InClassInitializers::TemplateArg' first required here}}
};
- bool x = noexcept(TemplateArg());
// And within a nested class.
- struct Nested { // expected-error {{cannot be used by non-static data member initializer}}
+ struct Nested { // expected-note {{implicit default constructor for 'InClassInitializers::Nested::Inner' first required here}}
struct Inner {
+ // expected-error@+1 {{cannot use defaulted default constructor of 'Inner' within 'Nested' outside of member functions}}
int n = ExceptionIf<noexcept(Nested())>::f(); // expected-note {{implicit default constructor for 'InClassInitializers::Nested' first required here}}
} inner;
};
- struct Nested2 {
+ struct Nested2 { // expected-error {{implicit default constructor for 'InClassInitializers::Nested2' must explicitly initialize the member 'inner' which does not have a default constructor}}
struct Inner;
- int n = Inner().n; // expected-error {{cannot be used by non-static data member initializer}}
- struct Inner {
+ int n = Inner().n; // expected-note {{implicit default constructor for 'InClassInitializers::Nested2::Inner' first required here}}
+ struct Inner { // expected-note {{declared here}}
+ // expected-error@+1 {{cannot use defaulted default constructor of 'Inner' within 'Nested2' outside of member functions}}
int n = ExceptionIf<noexcept(Nested2())>::f();
- } inner;
+ // expected-note@-1 {{implicit default constructor for 'InClassInitializers::Nested2' first required here}}
+ } inner; // expected-note {{member is declared here}}
};
}
OpenPOWER on IntegriCloud