From b9d84b57f680cb294da906a6eeca2d0598c11568 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Sat, 15 Apr 2023 18:24:35 +0300 Subject: [PATCH] [clang][NFC] Fix DR test ordering Some C++ DR tests are disrupting the usual ascending order, introducing confusion, and making people put new tests in the wrong place (myself included). This change affects 15 tests out of roughly 700. --- clang/test/CXX/drs/dr10xx.cpp | 26 ++++++------ clang/test/CXX/drs/dr13xx.cpp | 24 +++++------ clang/test/CXX/drs/dr14xx.cpp | 6 +-- clang/test/CXX/drs/dr16xx.cpp | 34 +++++++-------- clang/test/CXX/drs/dr17xx.cpp | 36 ++++++++-------- clang/test/CXX/drs/dr20xx.cpp | 56 ++++++++++++------------ clang/test/CXX/drs/dr22xx.cpp | 40 ++++++++--------- clang/test/CXX/drs/dr23xx.cpp | 99 +++++++++++++++++++++---------------------- clang/test/CXX/drs/dr26xx.cpp | 32 +++++++------- clang/test/CXX/drs/dr9xx.cpp | 58 ++++++++++++------------- 10 files changed, 205 insertions(+), 206 deletions(-) diff --git a/clang/test/CXX/drs/dr10xx.cpp b/clang/test/CXX/drs/dr10xx.cpp index 4d49a18..76b0e08 100644 --- a/clang/test/CXX/drs/dr10xx.cpp +++ b/clang/test/CXX/drs/dr10xx.cpp @@ -37,6 +37,19 @@ namespace dr1004 { // dr1004: 5 Third > t; // expected-note {{in instantiation of default argument}} } +namespace dr1042 { // dr1042: 3.5 +#if __cplusplus >= 201402L + // C++14 added an attribute that we can test the semantics of. + using foo [[deprecated]] = int; // expected-note {{'foo' has been explicitly marked deprecated here}} + foo f = 12; // expected-warning {{'foo' is deprecated}} +#elif __cplusplus >= 201103L + // C++11 did not have any attributes that could be applied to an alias + // declaration, so the best we can test is that we accept an empty attribute + // list in this mode. + using foo [[]] = int; +#endif +} + namespace dr1048 { // dr1048: 3.6 struct A {}; const A f(); @@ -85,16 +98,3 @@ namespace dr1070 { // dr1070: 3.5 C c = {}; #endif } - -namespace dr1042 { // dr1042: 3.5 -#if __cplusplus >= 201402L - // C++14 added an attribute that we can test the semantics of. - using foo [[deprecated]] = int; // expected-note {{'foo' has been explicitly marked deprecated here}} - foo f = 12; // expected-warning {{'foo' is deprecated}} -#elif __cplusplus >= 201103L - // C++11 did not have any attributes that could be applied to an alias - // declaration, so the best we can test is that we accept an empty attribute - // list in this mode. - using foo [[]] = int; -#endif -} diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp index 1a792f8..65eb8a2 100644 --- a/clang/test/CXX/drs/dr13xx.cpp +++ b/clang/test/CXX/drs/dr13xx.cpp @@ -23,6 +23,18 @@ int complete = alignof(Complete(&)[]); } #endif +namespace dr1307 { // dr1307: 14 +#if __cplusplus >= 201103L +void f(int const (&)[2]); +void f(int const (&)[3]); + +void caller() { + // This should not be ambiguous, the 2nd overload is better. + f({1, 2, 3}); +} +#endif // __cplusplus >= 201103L +} // namespace dr1307 + namespace dr1310 { // dr1310: 5 struct S {} * sp = new S::S; // expected-error {{qualified reference to 'S' is a constructor name}} void f() { @@ -476,15 +488,3 @@ namespace dr1399 { // dr1399: dup 1388 f(0, 0, 0); // expected-error {{no match}} } } - -namespace dr1307 { // dr1307: 14 -#if __cplusplus >= 201103L -void f(int const (&)[2]); -void f(int const (&)[3]); - -void caller() { - // This should not be ambiguous, the 2nd overload is better. - f({1, 2, 3}); -} -#endif // __cplusplus >= 201103L -} // namespace dr1307 diff --git a/clang/test/CXX/drs/dr14xx.cpp b/clang/test/CXX/drs/dr14xx.cpp index 7d27d3b..9d667db 100644 --- a/clang/test/CXX/drs/dr14xx.cpp +++ b/clang/test/CXX/drs/dr14xx.cpp @@ -36,6 +36,8 @@ namespace dr1423 { // dr1423: 11 #endif } +// dr1425: na abi + namespace dr1432 { // dr1432: 16 #if __cplusplus >= 201103L template T declval(); @@ -64,8 +66,6 @@ struct A { }; } -// dr1425: na abi - namespace dr1460 { // dr1460: 3.5 #if __cplusplus >= 201103L namespace DRExample { @@ -493,7 +493,7 @@ namespace dr1490 { // dr1490: 3.7 c++11 char s[4]{"abc"}; // Ok std::initializer_list{"abc"}; // expected-error {{expected unqualified-id}}} -} // dr190 +} // dr1490 namespace dr1495 { // dr1495: 4 // Deduction succeeds in both directions. diff --git a/clang/test/CXX/drs/dr16xx.cpp b/clang/test/CXX/drs/dr16xx.cpp index 6f8ced5..463353d 100644 --- a/clang/test/CXX/drs/dr16xx.cpp +++ b/clang/test/CXX/drs/dr16xx.cpp @@ -42,23 +42,6 @@ namespace dr1611 { // dr1611: dup 1658 C c; } -namespace dr1652 { // dr1652: 3.6 - int a, b; - int arr[&a + 1 == &b ? 1 : 2]; // expected-error 2{{variable length array}} - // expected-note@-1 {{points past the end}} -} - -namespace dr1684 { // dr1684: 3.6 -#if __cplusplus >= 201103L - struct NonLiteral { // expected-note {{because}} - NonLiteral(); - constexpr int f() { return 0; } // expected-warning 0-1{{will not be implicitly 'const'}} - }; - constexpr int f(NonLiteral &) { return 0; } - constexpr int f(NonLiteral) { return 0; } // expected-error {{not a literal type}} -#endif -} - namespace dr1631 { // dr1631: 3.7 #if __cplusplus >= 201103L // Incorrect overload resolution for single-element initializer-list @@ -131,6 +114,12 @@ namespace dr1645 { // dr1645: 3.9 #endif } +namespace dr1652 { // dr1652: 3.6 + int a, b; + int arr[&a + 1 == &b ? 1 : 2]; // expected-error 2{{variable length array}} + // expected-note@-1 {{points past the end}} +} + namespace dr1653 { // dr1653: 4 c++17 void f(bool b) { ++b; @@ -283,6 +272,17 @@ namespace dr1672 { // dr1672: 7 static_assert(!__is_standard_layout(Y), ""); } +namespace dr1684 { // dr1684: 3.6 +#if __cplusplus >= 201103L + struct NonLiteral { // expected-note {{because}} + NonLiteral(); + constexpr int f() { return 0; } // expected-warning 0-1{{will not be implicitly 'const'}} + }; + constexpr int f(NonLiteral &) { return 0; } + constexpr int f(NonLiteral) { return 0; } // expected-error {{not a literal type}} +#endif +} + namespace dr1687 { // dr1687: 7 template struct To { operator T(); // expected-note 2{{first operand was implicitly converted to type 'int *'}} diff --git a/clang/test/CXX/drs/dr17xx.cpp b/clang/test/CXX/drs/dr17xx.cpp index b5ee712..e91f4a6 100644 --- a/clang/test/CXX/drs/dr17xx.cpp +++ b/clang/test/CXX/drs/dr17xx.cpp @@ -27,6 +27,18 @@ namespace dr1715 { // dr1715: 3.9 #endif } +namespace dr1722 { // dr1722: 9 +#if __cplusplus >= 201103L +void f() { + const auto lambda = [](int x) { return x + 1; }; + // Without the DR applied, this static_assert would fail. + static_assert( + noexcept((int (*)(int))(lambda)), + "Lambda-to-function-pointer conversion is expected to be noexcept"); +} +#endif +} // namespace dr1722 + namespace dr1734 { // dr1734: no #if __cplusplus >= 201103L struct A { @@ -111,17 +123,14 @@ namespace dr1758 { // dr1758: 3.7 #endif } -namespace dr1722 { // dr1722: 9 +namespace dr1762 { // dr1762: 14 #if __cplusplus >= 201103L -void f() { - const auto lambda = [](int x) { return x + 1; }; - // Without the DR applied, this static_assert would fail. - static_assert( - noexcept((int (*)(int))(lambda)), - "Lambda-to-function-pointer conversion is expected to be noexcept"); -} + float operator ""_E(const char *); + // expected-error@+2 {{invalid suffix on literal; C++11 requires a space between literal and identifier}} + // expected-warning@+1 {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}} + float operator ""E(const char *); #endif -} // namespace dr1722 +} namespace dr1778 { // dr1778: 9 // Superseded by P1286R2. @@ -137,12 +146,3 @@ namespace dr1778 { // dr1778: 9 static_assert(noexcept(D()), ""); #endif } - -namespace dr1762 { // dr1762: 14 -#if __cplusplus >= 201103L - float operator ""_E(const char *); - // expected-error@+2 {{invalid suffix on literal; C++11 requires a space between literal and identifier}} - // expected-warning@+1 {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}} - float operator ""E(const char *); -#endif -} diff --git a/clang/test/CXX/drs/dr20xx.cpp b/clang/test/CXX/drs/dr20xx.cpp index 61fdb81..2d3398c 100644 --- a/clang/test/CXX/drs/dr20xx.cpp +++ b/clang/test/CXX/drs/dr20xx.cpp @@ -59,6 +59,34 @@ namespace dr2026 { // dr2026: 11 } } +namespace dr2061 { // dr2061: yes +#if __cplusplus >= 201103L + namespace A { + inline namespace b { + namespace C { + // 'f' is the example from the DR. 'S' is an example where if we didn't + // properly handle the two being the same, we would get an incomplete + // type error during attempted instantiation. + template void f(); + template struct S; + } + } + } + + namespace A { + namespace C { + template<> void f() { } + template<> struct S { }; + } + } + + void use() { + A::C::f(); + A::C::S s; + } +#endif // C++11 +} + namespace dr2076 { // dr2076: 13 #if __cplusplus >= 201103L namespace std_example { @@ -320,31 +348,3 @@ namespace dr2094 { // dr2094: 5 static_assert(__is_trivially_assignable(A, const A&), ""); static_assert(__is_trivially_assignable(B, const B&), ""); } - -namespace dr2061 { // dr2061: yes -#if __cplusplus >= 201103L - namespace A { - inline namespace b { - namespace C { - // 'f' is the example from the DR. 'S' is an example where if we didn't - // properly handle the two being the same, we would get an incomplete - // type error during attempted instantiation. - template void f(); - template struct S; - } - } - } - - namespace A { - namespace C { - template<> void f() { } - template<> struct S { }; - } - } - - void use() { - A::C::f(); - A::C::S s; - } -#endif // C++11 -} diff --git a/clang/test/CXX/drs/dr22xx.cpp b/clang/test/CXX/drs/dr22xx.cpp index 91be4b5..c14c1f1 100644 --- a/clang/test/CXX/drs/dr22xx.cpp +++ b/clang/test/CXX/drs/dr22xx.cpp @@ -3,19 +3,6 @@ // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -namespace dr2229 { // dr2229: 7 -struct AnonBitfieldQualifiers { - const unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} - volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} - const volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} - - unsigned : 1; - const unsigned i1 : 1; - volatile unsigned i2 : 1; - const volatile unsigned i3 : 1; -}; -} - #if __cplusplus >= 201103L namespace dr2211 { // dr2211: 8 void f() { @@ -27,13 +14,17 @@ void f() { } #endif -namespace dr2292 { // dr2292: 9 -#if __cplusplus >= 201103L - template using id = T; - void test(int *p) { - p->template id::~id(); - } -#endif +namespace dr2229 { // dr2229: 7 +struct AnonBitfieldQualifiers { + const unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} + volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} + const volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} + + unsigned : 1; + const unsigned i1 : 1; + volatile unsigned i2 : 1; + const volatile unsigned i3 : 1; +}; } namespace dr2233 { // dr2233: 11 @@ -123,3 +114,12 @@ namespace CheckAfterMerging2 { } #endif } // namespace dr2233 + +namespace dr2292 { // dr2292: 9 +#if __cplusplus >= 201103L + template using id = T; + void test(int *p) { + p->template id::~id(); + } +#endif +} diff --git a/clang/test/CXX/drs/dr23xx.cpp b/clang/test/CXX/drs/dr23xx.cpp index c77df0a..ac44899 100644 --- a/clang/test/CXX/drs/dr23xx.cpp +++ b/clang/test/CXX/drs/dr23xx.cpp @@ -5,6 +5,39 @@ // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s // RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s +#if __cplusplus >= 201103L +namespace dr2303 { // dr2303: 12 +template +struct A; +template <> +struct A<> {}; +template +struct A : A {}; +struct B : A {}; +struct C : A, A {}; // expected-warning {{direct base 'A' is inaccessible}} +struct D : A, A {}; // expected-warning {{direct base 'A' is inaccessible}} +struct E : A {}; +struct F : B, E {}; + +template +void f(const A &) { + static_assert(sizeof...(T) == 2, "Should only match A"); +} +template +void f2(const A *); + +void g() { + f(B{}); // This is no longer ambiguous. + B b; + f2(&b); + f(C{}); + f(D{}); + f(F{}); // expected-error {{ambiguous conversion from derived class}} +} +} //namespace dr2303 +#endif + +// dr2331: na #if __cplusplus >= 201103L namespace dr2338 { // dr2338: 12 @@ -101,6 +134,20 @@ namespace dr2358 { // dr2358: 16 } #endif +namespace dr2370 { // dr2370: no +namespace N { +typedef int type; +void g(type); +void h(type); +} // namespace N +class C { + typedef N::type N_type; + // FIXME: `type` should be searched for in N + // friend void N::g(type); + friend void N::h(N_type); +}; +} // namespace dr2370 + #if __cplusplus >= 201707L // Otherwise, if the qualified-id std::tuple_size names a complete class // type **with a member value**, the expression std::tuple_size::value shall @@ -122,6 +169,8 @@ void wrong_value() { auto [x, y] = Bad2(); } // expected-error {{decomposes into } // namespace dr2386 #endif +// dr2385: na + namespace dr2387 { // dr2387: 9 #if __cplusplus >= 201402L template int a = 0; @@ -139,56 +188,6 @@ namespace dr2387 { // dr2387: 9 #endif } -#if __cplusplus >= 201103L -namespace dr2303 { // dr2303: 12 -template -struct A; -template <> -struct A<> {}; -template -struct A : A {}; -struct B : A {}; -struct C : A, A {}; // expected-warning {{direct base 'A' is inaccessible}} -struct D : A, A {}; // expected-warning {{direct base 'A' is inaccessible}} -struct E : A {}; -struct F : B, E {}; - -template -void f(const A &) { - static_assert(sizeof...(T) == 2, "Should only match A"); -} -template -void f2(const A *); - -void g() { - f(B{}); // This is no longer ambiguous. - B b; - f2(&b); - f(C{}); - f(D{}); - f(F{}); // expected-error {{ambiguous conversion from derived class}} -} -} //namespace dr2303 -#endif - -// dr2331: na - -namespace dr2370 { // dr2370: no -namespace N { -typedef int type; -void g(type); -void h(type); -} // namespace N -class C { - typedef N::type N_type; - // FIXME: `type` should be searched for in N - // friend void N::g(type); - friend void N::h(N_type); -}; -} // namespace dr2370 - -// dr2385: na - namespace dr2394 { // dr2394: 15 struct A {}; diff --git a/clang/test/CXX/drs/dr26xx.cpp b/clang/test/CXX/drs/dr26xx.cpp index f2ec677..175e27e 100644 --- a/clang/test/CXX/drs/dr26xx.cpp +++ b/clang/test/CXX/drs/dr26xx.cpp @@ -36,6 +36,22 @@ void f() { } +namespace dr2631 { // dr2631: 16 + constexpr int g(); + consteval int f() { + return g(); + } + int k(int x = f()) { + return x; + } + constexpr int g() { + return 42; + } + int test() { + return k(); + } +} + namespace dr2635 { // dr2635: 16 template concept UnaryC = true; @@ -110,19 +126,3 @@ void f() { brachiosaur |= neck; // OK } } - -namespace dr2631 { // dr2631: 16 - constexpr int g(); - consteval int f() { - return g(); - } - int k(int x = f()) { - return x; - } - constexpr int g() { - return 42; - } - int test() { - return k(); - } -} diff --git a/clang/test/CXX/drs/dr9xx.cpp b/clang/test/CXX/drs/dr9xx.cpp index cce0b6e..2c1d620 100644 --- a/clang/test/CXX/drs/dr9xx.cpp +++ b/clang/test/CXX/drs/dr9xx.cpp @@ -14,35 +14,6 @@ namespace std { }; } -namespace dr990 { // dr990: 3.5 -#if __cplusplus >= 201103L - struct A { // expected-note 2{{candidate}} - A(std::initializer_list); // expected-note {{candidate}} - }; - struct B { - A a; - }; - B b1 { }; - B b2 { 1 }; // expected-error {{no viable conversion from 'int' to 'A'}} - B b3 { { 1 } }; - - struct C { - C(); - C(int); - C(std::initializer_list) = delete; // expected-note {{here}} - }; - C c1[3] { 1 }; // ok - C c2[3] { 1, {2} }; // expected-error {{call to deleted}} - - struct D { - D(); - D(std::initializer_list); - D(std::initializer_list); - }; - D d{}; -#endif -} - namespace dr948 { // dr948: 3.7 #if __cplusplus >= 201103L class A { @@ -118,3 +89,32 @@ namespace dr974 { // dr974: yes } #endif } + +namespace dr990 { // dr990: 3.5 +#if __cplusplus >= 201103L + struct A { // expected-note 2{{candidate}} + A(std::initializer_list); // expected-note {{candidate}} + }; + struct B { + A a; + }; + B b1 { }; + B b2 { 1 }; // expected-error {{no viable conversion from 'int' to 'A'}} + B b3 { { 1 } }; + + struct C { + C(); + C(int); + C(std::initializer_list) = delete; // expected-note {{here}} + }; + C c1[3] { 1 }; // ok + C c2[3] { 1, {2} }; // expected-error {{call to deleted}} + + struct D { + D(); + D(std::initializer_list); + D(std::initializer_list); + }; + D d{}; +#endif +} -- 2.7.4