|
1 |
| -// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -Wno-uninitialized-const-reference -std=c++1z -verify %s |
2 |
| -// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -Wno-uninitialized-const-reference -std=c++1z -verify %s -fexperimental-new-constant-interpreter |
| 1 | +// RUN: %clang_cc1 -fsyntax-only -Wall -Wc++20-compat -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -Wno-uninitialized-const-reference -std=c++1z -verify %s |
| 2 | +// RUN: %clang_cc1 -fsyntax-only -Wall -Wc++20-compat -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -Wno-uninitialized-const-reference -std=c++1z -verify %s -fexperimental-new-constant-interpreter |
| 3 | +// RUN: %clang_cc1 -fsyntax-only -Wall -Wc++20-compat -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -Wno-uninitialized-const-reference -std=c++20 -verify %s |
3 | 4 |
|
4 | 5 | // definitions for std::move
|
5 | 6 | namespace std {
|
@@ -1514,10 +1515,11 @@ void aggregate() {
|
1514 | 1515 | };
|
1515 | 1516 |
|
1516 | 1517 | struct C {
|
1517 |
| - [[clang::requires_explicit_initialization]] int c1; // #FIELD_C1 |
1518 |
| -#if 201703L <= __cplusplus && __cplusplus < 202002L |
1519 |
| - // expected-warning@#FIELD_C1 {{explicit initialization of field 'c1' will not be enforced in C++20 and later because 'C' has a user-declared constructor, making the type no longer an aggregate}} |
| 1518 | +#if __cplusplus < 202002L |
| 1519 | + // expected-warning@+1 {{explicit initialization of field 'c1' will not be enforced in C++20 and later because 'C' has a user-declared constructor, making the type no longer an aggregate}} |
| 1520 | + [[clang::requires_explicit_initialization]] |
1520 | 1521 | #endif
|
| 1522 | + int c1; // #FIELD_C1 |
1521 | 1523 | C() = default; // Test pre-C++20 aggregates
|
1522 | 1524 | };
|
1523 | 1525 |
|
@@ -1555,11 +1557,41 @@ void aggregate() {
|
1555 | 1557 | delete ptr2;
|
1556 | 1558 |
|
1557 | 1559 | #if __cplusplus >= 202002L
|
1558 |
| - // expected-warning@+2 {{field 'd2' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_D2 {{'d2' declared here}} |
1559 |
| - // expected-warning {{field 's1' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S1 {{'s1' declared here}} |
1560 |
| - D a({}, 0); |
1561 |
| - (void)a; |
1562 |
| -#else |
| 1560 | + // expected-warning@+3 {{field 's1' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S1 {{'s1' declared here}} |
| 1561 | + // expected-warning@+2 {{field 's4' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S4 {{'s4' declared here}} |
| 1562 | + // expected-warning@+1 {{field 'd2' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_D2 {{'d2' declared here}} |
| 1563 | + D a1({}, 0); |
| 1564 | + (void)a1; |
| 1565 | + |
| 1566 | + // expected-warning@+3 {{field 's1' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S1 {{'s1' declared here}} |
| 1567 | + // expected-warning@+2 {{field 's4' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S4 {{'s4' declared here}} |
| 1568 | + // expected-warning@+1 {{field 'd2' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_D2 {{'d2' declared here}} |
| 1569 | + D a2(S{}, 0); |
| 1570 | + (void)a2; |
| 1571 | + |
| 1572 | + // expected-warning@+2 {{field 's4' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S4 {{'s4' declared here}} |
| 1573 | + // expected-warning@+1 {{field 'd2' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_D2 {{'d2' declared here}} |
| 1574 | + D a3(S{.s1 = 0}, 0); |
| 1575 | + (void)a3; |
| 1576 | + |
| 1577 | + // expected-warning@+3 {{field 's1' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S1 {{'s1' declared here}} |
| 1578 | + // expected-warning@+2 {{field 's4' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S4 {{'s4' declared here}} |
| 1579 | + // expected-warning@+1 {{field 'd2' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_D2 {{'d2' declared here}} |
| 1580 | + D a4(S(), 0); |
| 1581 | + (void)a4; |
| 1582 | + |
| 1583 | + // expected-warning@+2 {{field 's4' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S4 {{'s4' declared here}} |
| 1584 | + // expected-warning@+1 {{field 'd2' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_D2 {{'d2' declared here}} |
| 1585 | + D a5(S(0), 0); |
| 1586 | + (void)a5; |
| 1587 | + |
| 1588 | + // expected-warning@+2 {{field 's4' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_S4 {{'s4' declared here}} |
| 1589 | + // expected-warning@+1 {{field 'd2' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_D2 {{'d2' declared here}} |
| 1590 | + D a6 = {S(0), 0}; |
| 1591 | + (void)a6; |
| 1592 | +#endif |
| 1593 | + |
| 1594 | +#if 201103L <= __cplusplus && __cplusplus < 202002L |
1563 | 1595 | C a; // expected-warning {{field in 'C' requires explicit initialization but is not explicitly initialized}} expected-note@#FIELD_C1 {{'c1' declared here}}
|
1564 | 1596 | (void)a;
|
1565 | 1597 | #endif
|
|
0 commit comments