diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-09-26 19:00:16 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-09-26 19:00:16 +0000 |
commit | de8e63fd00e24e58a5ca05007cf7954916a6e6b9 (patch) | |
tree | 22c0af7e8297cc9933e3832492bd5433ba61174f /test/SemaCXX/cxx2a-compat.cpp | |
parent | 26346fbcb9bb9fe7a6374e84eb994e8743e65327 (diff) |
P1008R1 Classes with user-declared constructors are never aggregates in
C++20.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343131 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/cxx2a-compat.cpp')
-rw-r--r-- | test/SemaCXX/cxx2a-compat.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/SemaCXX/cxx2a-compat.cpp b/test/SemaCXX/cxx2a-compat.cpp new file mode 100644 index 0000000000..53043d67fb --- /dev/null +++ b/test/SemaCXX/cxx2a-compat.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++2a-compat-pedantic -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++2a -pedantic -verify %s + +struct A { // expected-note 0+{{candidate}} + A() = default; // expected-note 0+{{candidate}} + int x, y; +}; +A a1 = {1, 2}; +#if __cplusplus <= 201703L + // expected-warning@-2 {{aggregate initialization of type 'A' with user-declared constructors is incompatible with C++2a}} +#else + // expected-error@-4 {{no matching constructor}} +#endif +A a2 = {}; + +struct B : A { A a; }; +B b1 = {{}, {}}; // ok +B b2 = {1, 2, 3, 4}; +#if __cplusplus <= 201703L + // expected-warning@-2 2{{aggregate initialization of type 'A' with user-declared constructors is incompatible with C++2a}} +#else + // expected-error@-4 2{{no viable conversion from 'int' to 'A'}} +#endif |