llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) <details> <summary>Changes</summary> [clang][NFC] Refactor expected directives in C++ DRs 600-699 This patch continues the work started with https://github.com/llvm/llvm-project/commit/ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details. --- Patch is 55.30 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74477.diff 1 Files Affected: - (modified) clang/test/CXX/drs/dr6xx.cpp (+418-238) ``````````diff diff --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp index 4cba1f057cb27..37694e3647c63 100644 --- a/clang/test/CXX/drs/dr6xx.cpp +++ b/clang/test/CXX/drs/dr6xx.cpp @@ -1,22 +1,24 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98-17,cxx98-14,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++11 %s -verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11,cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++14 %s -verify=expected,cxx98-17,cxx11-17,cxx98-14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++17 %s -verify=expected,cxx98-17,cxx11-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking +// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking namespace dr600 { // dr600: 2.8 struct S { void f(int); private: - void f(double); // expected-note {{declared private here}} + void f(double); // #dr600-f-double }; void g(S *sp) { sp->f(2); // access control is applied after overload resolution - sp->f(2.2); // expected-error {{is a private member}} + sp->f(2.2); + // expected-error@-1 {{'f' is a private member of 'dr600::S'}} + // expected-note@#dr600-f-double {{declared private here}} } } // namespace dr600 @@ -41,7 +43,8 @@ namespace dr601 { // dr601: yes #endif #if __INT_MAX__ == 0x7FFFFFFF -_Static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); // expected-error {{C11}} +_Static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); +// expected-error@-1 {{'_Static_assert' is a C11 extension}} #endif #if MAX > 0xFFFFFFFFFFFFFFFF && 0x8000000000000000 < -1 @@ -49,7 +52,7 @@ _Static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); // expected-er #endif #if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFFFFFFFFFFFFFF -static_assert(0x8000000000000000 < -1, "0x8000000000000000 should be unsigned"); // expected-error {{C11}} +static_assert(0x8000000000000000 < -1, "0x8000000000000000 should be unsigned"); #endif #undef MAX @@ -74,9 +77,7 @@ namespace dr603 { // dr603: yes template<unsigned char> struct S {}; typedef S<'\001'> S1; typedef S<(1ul << __CHAR_BIT__) + 1> S1; -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be narrowed}} -#endif + // since-cxx11-error@-1 {{cannot be narrowed}} } // dr604: na @@ -85,14 +86,18 @@ namespace dr603 { // dr603: yes namespace dr606 { // dr606: 3.0 #if __cplusplus >= 201103L template<typename T> struct S {}; - template<typename T> void f(S<T> &&); // expected-note {{expects an rvalue}} + template<typename T> void f(S<T> &&); // #dr606-f template<typename T> void g(T &&); - template<typename T> void h(const T &&); // expected-note {{expects an rvalue}} + template<typename T> void h(const T &&); // #dr606-h void test(S<int> s) { - f(s); // expected-error {{no match}} + f(s); + // since-cxx11-error@-1 {{no matching function for call to 'f'}} + // since-cxx11-note@#dr606-f {{candidate function [with T = int] not viable: expects an rvalue for 1st argument}} g(s); - h(s); // expected-error {{no match}} + h(s); + // since-cxx11-error@-1 {{no matching function for call to 'h'}} + // since-cxx11-note@#dr606-h {{candidate function [with T = dr606::S<int>] not viable: expects an rvalue for 1st argument}} g(test); h(test); // ok, an rvalue reference can bind to a function lvalue @@ -152,33 +157,32 @@ namespace dr613 { // dr613: yes c++11 B &g(int); int an1 = sizeof(A::n); + // cxx98-error@-1 {{invalid use of non-static data member 'n'}} int an2 = sizeof(A::n + 1); // valid per dr850 + // cxx98-error@-1 {{invalid use of non-static data member 'n'}} int an3 = sizeof A::n; + // cxx98-error@-1 {{invalid use of non-static data member 'n'}} int an4 = sizeof(f(A::n)); + // cxx98-error@-1 {{invalid use of non-static data member 'n'}} int an5 = sizeof(g(A::n)); + // cxx98-error@-1 {{invalid use of non-static data member 'n'}} const std::type_info &an6 = typeid(A::n); + // cxx98-error@-1 {{invalid use of non-static data member 'n'}} const std::type_info &an7 = typeid(A::n + 1); + // cxx98-error@-1 {{invalid use of non-static data member 'n'}} const std::type_info &an8 = typeid(f(A::n)); - const std::type_info &an9 = typeid(g(A::n)); // expected-error {{non-static}} -#if __cplusplus < 201103L - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} -#endif + // cxx98-error@-1 {{invalid use of non-static data member 'n'}} + const std::type_info &an9 = typeid(g(A::n)); + // expected-error@-1 {{invalid use of non-static data member 'n'}} void A::f() { int an1 = sizeof n; + // cxx98-error@-1 {{invalid use of member 'n' in static member function}} const std::type_info &an2 = typeid(n + 1); -#if __cplusplus < 201103L - // expected-error@-3 {{static}} - // expected-error@-3 {{static}} -#endif - const std::type_info &an3 = typeid(g(n)); // expected-error {{static}} + // cxx98-error@-1 {{invalid use of member 'n' in static member function}} + const std::type_info &an3 = typeid(g(n)); + // cxx98-error@-1 {{invalid use of member 'n' in static member function}} + // since-cxx11-error@-2 {{invalid use of non-static data member 'n'}} } } @@ -219,16 +223,20 @@ namespace dr619 { // dr619: yes struct S { static int x[10]; }; int x[]; - _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}} + _Static_assert(sizeof(x) == sizeof(int) * 10, ""); + // expected-error@-1 {{'_Static_assert' is a C11 extension}} extern int x[]; - _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}} + _Static_assert(sizeof(x) == sizeof(int) * 10, ""); + // expected-error@-1 {{'_Static_assert' is a C11 extension}} int S::x[]; - _Static_assert(sizeof(S::x) == sizeof(int) * 10, ""); // expected-error {{C11}} + _Static_assert(sizeof(S::x) == sizeof(int) * 10, ""); + // expected-error@-1 {{'_Static_assert' is a C11 extension}} void f() { extern int x[]; - sizeof(x); // expected-error {{incomplete}} + sizeof(x); + // expected-error@-1 {{invalid application of 'sizeof' to an incomplete type 'int[]'}} } } @@ -236,8 +244,10 @@ namespace dr619 { // dr619: yes namespace dr621 { // dr621: yes template<typename T> T f(); - template<> int f() {} // expected-note {{previous}} - template<> int f<int>() {} // expected-error {{redefinition}} + template<> int f() {} // #dr621-f + template<> int f<int>() {} + // expected-error@-1 {{redefinition of 'f<int>'}} + // expected-note@#dr621-f {{previous definition is here}} } // dr623: na @@ -247,20 +257,29 @@ namespace dr621 { // dr621: yes namespace dr625 { // dr625: yes template<typename T> struct A {}; - A<auto> x = A<int>(); // expected-error {{'auto' not allowed in template argument}} expected-error 0-1{{extension}} + A<auto> x = A<int>(); + // cxx98-error@-1 {{'auto' type specifier is a C++11 extension}} + // expected-error@-2 {{'auto' not allowed in template argument}} void f(int); - void (*p)(auto) = f; // expected-error {{'auto' not allowed in function prototype}} expected-error 0-1{{extension}} + void (*p)(auto) = f; + // cxx98-error@-1 {{'auto' type specifier is a C++11 extension}} + // expected-error@-2 {{'auto' not allowed in function prototype}} } namespace dr626 { // dr626: yes #define STR(x) #x char c[2] = STR(c); // ok, type matches - wchar_t w[2] = STR(w); // expected-error {{initializing wide char array with non-wide string literal}} + wchar_t w[2] = STR(w); + // expected-error@-1 {{initializing wide char array with non-wide string literal}} } namespace dr627 { // dr627: yes void f() { - true a = 0; // expected-error +{{}} expected-warning {{unused}} + // FIXME: emitted diagnostic have a room for improvement + true a = 0; + // expected-error@-1 {{expected ';' after expression}} + // expected-error@-2 {{use of undeclared identifier 'a'}} + // expected-warning@-3 {{expression result unused}} } } @@ -270,17 +289,12 @@ namespace dr629 { // dr629: 2.9 typedef int T; int n = 1; void f() { - auto T = 2; -#if __cplusplus < 201103L - // expected-error@-2 {{expected unqualified-id}} -#else - // expected-note@-4 {{previous}} -#endif + auto T = 2; // #dr629-T + // cxx98-error@-1 {{expected unqualified-id}} auto T(n); -#if __cplusplus >= 201103L - // expected-error@-2 {{redefinition of 'T'}} -#endif + // since-cxx11-error@-1 {{redefinition of 'T'}} + // since-cxx11-note@#dr629-T {{previous definition is here}} } } @@ -311,17 +325,20 @@ const bool MB_EQ_WC = ',' == L',' && '\\' == L'\\' && '"' == L'"' && '\'' == L'\''; #if __STDC_MB_MIGHT_NEQ_WC__ #ifndef __FreeBSD__ // PR22208, FreeBSD expects us to give a bad (but conforming) answer here. -_Static_assert(!MB_EQ_WC, "__STDC_MB_MIGHT_NEQ_WC__ but all basic source characters have same representation"); // expected-error {{C11}} +_Static_assert(!MB_EQ_WC, "__STDC_MB_MIGHT_NEQ_WC__ but all basic source characters have same representation"); +// expected-error@-1 {{'_Static_assert' is a C11 extension}} #endif #else -_Static_assert(MB_EQ_WC, "!__STDC_MB_MIGHT_NEQ_WC__ but some character differs"); // expected-error {{C11}} +_Static_assert(MB_EQ_WC, "!__STDC_MB_MIGHT_NEQ_WC__ but some character differs"); +// expected-error@-1 {{'_Static_assert' is a C11 extension}} #endif } // dr631: na namespace dr632 { // dr632: yes - struct S { int n; } s = {{5}}; // expected-warning {{braces}} + struct S { int n; } s = {{5}}; + // expected-warning@-1 {{braces around scalar initializer}} } // dr633: na @@ -334,12 +351,15 @@ namespace dr634 { // dr634: yes template<typename T> int (&g(T))[sizeof f(T())]; int (&a)[sizeof(int)] = g(S()); int (&b)[1] = g(0); - int k = f(S()); // expected-error {{cannot pass}} + int k = f(S()); + // cxx98-error@-1 {{cannot pass object of non-POD type 'S' through variadic function; call will abort at runtime}} + // since-cxx11-error@-2 {{cannot pass object of non-trivial type 'S' through variadic function; call will abort at runtime}} } namespace dr635 { // dr635: yes template<typename T> struct A { A(); ~A(); }; - template<typename T> A<T>::A<T>() {} // expected-error {{cannot have template arguments}} + template<typename T> A<T>::A<T>() {} + // expected-error@-1 {{out-of-line constructor for 'A' cannot have template arguments}} template<typename T> A<T>::~A<T>() {} template<typename T> struct B { B(); ~B(); }; @@ -349,22 +369,25 @@ namespace dr635 { // dr635: yes struct C { template<typename T> C(); C(); }; template<typename T> C::C() {} C::C() {} - template<> C::C<int>() {} // expected-error {{constructor name}} expected-error {{unqualified-id}} + template<> C::C<int>() {} + // expected-error@-1 {{qualified reference to 'C' is a constructor name rather than a type in this context}} + // expected-error@-2 {{expected unqualified-id}} /*FIXME: needed for error recovery:*/; template<typename T> struct D { template<typename U> D(); D(); }; - template<typename T> D<T>::D() {} // expected-note {{previous}} + template<typename T> D<T>::D() {} // #dr635-D template<typename T> template<typename U> D<T>::D() {} - template<typename T> D<T>::D<T>() {} // expected-error {{redefinition}} expected-error {{cannot have template arg}} + template<typename T> D<T>::D<T>() {} // #dr635-D-T + // expected-error@#dr635-D-T {{out-of-line constructor for 'D' cannot have template arguments}} + // expected-error@#dr635-D-T {{redefinition of 'D<T>'}} + // expected-note@#dr635-D {{previous definition is here}} } namespace dr637 { // dr637: yes void f(int i) { i = ++i + 1; i = i++ + 1; -#if __cplusplus < 201703L - // expected-warning@-2 {{unsequenced}} -#endif + // cxx98-14-warning@-1 {{multiple unsequenced modifications to 'i'}} } } @@ -380,10 +403,14 @@ namespace dr638 { // dr638: no class X { typedef int type; - template<class T> friend struct A<T>::B; // expected-warning {{not supported}} - template<class T> friend void A<T>::f(); // expected-warning {{not supported}} - template<class T> friend void A<T>::g(); // expected-warning {{not supported}} - template<class T> friend void A<T>::C::h(); // expected-warning {{not supported}} + template<class T> friend struct A<T>::B; + // expected-warning@-1 {{dependent nested name specifier 'A<T>::' for friend class declaration is not supported; turning off access control for 'X'}} + template<class T> friend void A<T>::f(); + // expected-warning@-1 {{dependent nested name specifier 'A<T>::' for friend class declaration is not supported; turning off access control for 'X'}} + template<class T> friend void A<T>::g(); + // expected-warning@-1 {{dependent nested name specifier 'A<T>::' for friend class declaration is not supported; turning off access control for 'X'}} + template<class T> friend void A<T>::C::h(); + // expected-warning@-1 {{dependent nested name specifier 'A<T>::C::' for friend class declaration is not supported; turning off access control for 'X'}} }; template<> struct A<int> { @@ -401,7 +428,8 @@ namespace dr638 { // dr638: no namespace dr639 { // dr639: 3.3 void f(int i) { - void((i = 0) + (i = 0)); // expected-warning {{unsequenced}} + void((i = 0) + (i = 0)); + // expected-warning@-1 {{multiple unsequenced modifications to 'i'}} } } @@ -410,36 +438,46 @@ namespace dr641 { // dr641: yes struct abc; struct xyz { - xyz(); // expected-note 0-1{{candidate}} - xyz(xyz &); // expected-note 0-1{{candidate}} - - operator xyz &() = delete; // expected-error 0-1{{extension}} expected-warning {{will never be used}} - operator abc &() = delete; // expected-error 0-1{{extension}} + xyz(); // #dr641-xyz-ctor + xyz(xyz &); // #dr641-xyz-copy-ctor + + operator xyz &() = delete; + // expected-warning@-1 {{conversion function converting 'dr641::std_example::xyz' to itself will never be used}} + // cxx98-error@-2 {{deleted function definitions are a C++11 extension}} + operator abc &() = delete; + // cxx98-error@-1 {{deleted function definitions are a C++11 extension}} }; struct abc : xyz {}; template<typename T> - void use(T &); // expected-note {{expects an lvalue}} + void use(T &); // #dr641-use void test() { - use<xyz>(xyz()); // expected-error {{no match}} + use<xyz>(xyz()); + // expected-error@-1 {{no matching function for call to 'use'}} + // expected-note@#dr641-use {{candidate function template not viable: expects an lvalue for 1st argument}} use<const xyz>(xyz()); -#if __cplusplus < 201103L - // expected-error-re@-2 {{no viable constructor copying parameter of type '{{.*}}xyz'}} -#endif + // cxx98-error@-1 {{no viable constructor copying parameter of type 'xyz'; C++98 requires a copy constructor when binding a reference to a temporary}} + // cxx98-note@#dr641-xyz-copy-ctor {{candidate constructor not viable: expects an lvalue for 1st argument}} + // cxx98-note@#dr641-xyz-ctor {{candidate constructor not viable: requires 0 arguments, but 1 was provided}} } } template<typename T> struct error { typedef typename T::error type; }; struct A { - template<typename T, typename error<T>::type = 0> operator T() const; // expected-error 0-1{{extension}} + template<typename T, typename error<T>::type = 0> operator T() const; + // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}} }; A a; - void f(A&); // expected-note 2{{candidate}} + void f(A&); // #dr641-f void g(const A ca) { - f(A()); // expected-error {{no match}} - f(ca); // expected-error {{no match}} + f(A()); + // expected-error@-1 {{no matching function for call to 'f'}} + // expected-note@#dr641-f {{candidate function not viable: expects an lvalue for 1st argument}} + f(ca); + // expected-error@-1 {{no matching function for call to 'f'}} + // expected-note@#dr641-f {{candidate function not viable: 1st argument ('const A') would lose const qualifier}} (void)A(); (void)ca; } @@ -450,7 +488,8 @@ namespace dr642 { // dr642: yes const int i = 2; { char i[i]; - _Static_assert(sizeof(i) == 2, ""); // expected-error {{C11}} + _Static_assert(sizeof(i) == 2, ""); + // expected-error@-1 {{'_Static_assert' is a C11 extension}} } } @@ -468,9 +507,12 @@ namespace dr643 { // dr643: 3.2 auto f() -> decltype(this->x); auto f(A &a) -> decltype(a.x); auto g() -> decltype(x); - auto h() -> decltype(this->y); // expected-error {{no member named 'y'}} - auto h(A &a) -> decltype(a.y); // expected-error {{no member named 'y'}} - auto i() -> decltype(y); // expected-error {{undeclared identifier 'y'}} + auto h() -> decltype(this->y); + // since-cxx11-error@-1 {{no member named 'y' in 'dr643::A'}} + auto h(A &a) -> decltype(a.y); + // since-cxx11-error@-1 {{no member named 'y' in 'dr643::A'}} + auto i() -> decltype(y); + // since-cxx11-error@-1 {{use of undeclared identifier 'y'}} int y; }; } @@ -527,40 +569,32 @@ namespace dr647 { // dr647: 3.1 struct A { constexpr virtual void f() const; constexpr virtual void g() const {} -#if __cplusplus <= 201703L - // expected-error@-2 {{virtual function cannot be constexpr}} -#endif + // cxx11-17-error@-1 {{virtual function cannot be constexpr}} }; - struct X { virtual void f() const; }; -#if __cplusplus <= 201703L - // expected-note@-2 {{overridden}} -#endif + struct X { virtual void f() const; }; // #dr647-f struct B : X { constexpr void f() const {} -#if __cplusplus <= 201703L - // expected-error@-2 {{virtual function cannot be constexpr}} -#endif + // cxx11-17-error@-1 {{virtual function cannot be constexpr}} + // cxx11-17-note@#dr647-f {{overridden virtual function is here}} }; - struct NonLiteral { NonLiteral() {} }; // expected-note {{not an aggregate and has no constexpr constructors}} + struct NonLiteral { NonLiteral() {} }; // #dr647-NonLiteral struct C { constexpr C(NonLiteral); - constexpr C(NonLiteral, int) {} // expected-error {{not a literal type}} + constexpr C(NonLiteral, int) {} + // since-cxx11-error@-1 {{constexpr constructor's 1st parameter type 'NonLiteral' is not a literal type}} + // since-cxx11-note@#dr647-NonLiteral {{'NonLiteral' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors}} constexpr C() try {} catch (...) {} -#if __cplusplus <= 201703L - // expected-error@-2 {{function try block in constexpr constructor is a C++20 extension}} -#endif -#if __cplusplus < 201402L - // expected-error@-5 {{use of this statement in a constexpr constructor is a C++14 extension}} -#endif + // cxx11-17-error@-1 {{function try block in constexpr constructor is a C++20 extension}} + // cxx11-error@-2 {{use of this statement in a constexpr constructor is a C++14 extension}} ... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/74477 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits