diff options
Diffstat (limited to 'clang/test/SemaCXX/implicit-exception-spec.cpp')
-rw-r--r-- | clang/test/SemaCXX/implicit-exception-spec.cpp | 22 |
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}} }; } |