diff options
Diffstat (limited to 'clang/test/CXX/drs/dr25xx.cpp')
-rw-r--r-- | clang/test/CXX/drs/dr25xx.cpp | 106 |
1 files changed, 58 insertions, 48 deletions
diff --git a/clang/test/CXX/drs/dr25xx.cpp b/clang/test/CXX/drs/dr25xx.cpp index 0204eca..8c34b03 100644 --- a/clang/test/CXX/drs/dr25xx.cpp +++ b/clang/test/CXX/drs/dr25xx.cpp @@ -1,12 +1,12 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L +// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx20 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx20,since-cxx23 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx20,since-cxx23 -fexceptions -fcxx-exceptions -pedantic-errors + +#if __cplusplus == 199711L // expected-no-diagnostics #endif @@ -17,7 +17,7 @@ template <typename T> struct S { typedef char I; }; enum E2 : S<E2>::I { e }; -// expected-error@-1 {{use of undeclared identifier 'E2'}} +// since-cxx11-error@-1 {{use of undeclared identifier 'E2'}} #endif } // namespace dr2516 @@ -27,24 +27,24 @@ namespace dr2518 { // dr2518: 17 template <class T> void f(T t) { if constexpr (sizeof(T) != sizeof(int)) { -#if __cplusplus < 201703L -// expected-error@-2 {{constexpr if is a C++17 extension}} -#endif - static_assert(false, "must be int-sized"); // expected-error {{must be int-size}} + // cxx11-14-error@-1 {{constexpr if is a C++17 extension}} + static_assert(false, "must be int-sized"); + // since-cxx11-error@-1 {{static assertion failed: must be int-sized}} + // since-cxx11-note@#dr2518-f-c {{in instantiation of function template specialization 'dr2518::f<char>' requested here}} } } void g(char c) { f(0); - f(c); // expected-note {{requested here}} + f(c); // #dr2518-f-c } template <typename Ty> struct S { - static_assert(false); // expected-error {{static assertion failed}} -#if __cplusplus < 201703L -// expected-error@-2 {{'static_assert' with no message is a C++17 extension}} -#endif + static_assert(false); + // cxx11-14-error@-1 {{'static_assert' with no message is a C++17 extension}} + // since-cxx11-error@-2 {{static assertion failed}} + // since-cxx11-note@#dr2518-S-double {{in instantiation of template class 'dr2518::S<double>' requested here}} }; template <> @@ -56,7 +56,7 @@ struct S<float> {}; int test_specialization() { S<int> s1; S<float> s2; - S<double> s3; // expected-note {{in instantiation of template class 'dr2518::S<double>' requested here}} + S<double> s3; // #dr2518-S-double } #endif @@ -67,16 +67,16 @@ namespace dr2521 { // dr2521: 17 #pragma clang diagnostic push #pragma clang diagnostic warning "-Wdeprecated-literal-operator" long double operator"" _\u03C0___(long double); -// expected-warning@-1 {{identifier '_π___' preceded by whitespace in a literal operator declaration is deprecated}} -// expected-warning@-2 {{user-defined literal suffixes containing '__' are reserved}} +// since-cxx11-warning@-1 {{identifier '_π___' preceded by whitespace in a literal operator declaration is deprecated}} +// since-cxx11-warning@-2 {{user-defined literal suffixes containing '__' are reserved}} template <char... Chars> decltype(sizeof 0) operator"" _div(); -// expected-warning@-1 {{identifier '_div' preceded by whitespace in a literal operator declaration is deprecated}} +// since-cxx11-warning@-1 {{identifier '_div' preceded by whitespace in a literal operator declaration is deprecated}} using ::dr2521::operator"" _\u03C0___; using ::dr2521::operator""_div; -// expected-warning@-2 {{identifier '_π___' preceded by whitespace in a literal operator declaration is deprecated}} +// since-cxx11-warning@-2 {{identifier '_π___' preceded by whitespace in a literal operator declaration is deprecated}} #pragma clang diagnostic pop #endif } // namespace dr2521 @@ -85,12 +85,16 @@ using ::dr2521::operator""_div; #if __cplusplus >= 202302L namespace dr2553 { // dr2553: 18 struct B { - virtual void f(this B&); // expected-error {{an explicit object parameter cannot appear in a virtual function}} - static void f(this B&); // expected-error {{an explicit object parameter cannot appear in a static function}} - virtual void g(); // expected-note {{here}} + virtual void f(this B&); + // since-cxx23-error@-1 {{an explicit object parameter cannot appear in a virtual function}} + static void f(this B&); + // since-cxx23-error@-1 {{an explicit object parameter cannot appear in a static function}} + virtual void g(); // #dr2553-g }; struct D : B { - void g(this D&); // expected-error {{an explicit object parameter cannot appear in a virtual function}} + void g(this D&); + // since-cxx23-error@-1 {{an explicit object parameter cannot appear in a virtual function}} + // since-cxx23-note@#dr2553-g {{overridden virtual function is here}} }; } @@ -99,19 +103,25 @@ struct D : B { #if __cplusplus >= 202302L namespace dr2554 { // dr2554: 18 review struct B { - virtual void f(); // expected-note 3{{here}} + virtual void f(); // #dr2554-g }; struct D : B { - void f(this D&); // expected-error {{an explicit object parameter cannot appear in a virtual function}} + void f(this D&); + // since-cxx23-error@-1 {{an explicit object parameter cannot appear in a virtual function}} + // since-cxx23-note@#dr2554-g {{overridden virtual function is here}} }; struct D2 : B { - void f(this B&); // expected-error {{an explicit object parameter cannot appear in a virtual function}} + void f(this B&); + // since-cxx23-error@-1 {{an explicit object parameter cannot appear in a virtual function}} + // since-cxx23-note@#dr2554-g {{overridden virtual function is here}} }; struct T {}; struct D3 : B { - void f(this T&); // expected-error {{an explicit object parameter cannot appear in a virtual function}} + void f(this T&); + // since-cxx23-error@-1 {{an explicit object parameter cannot appear in a virtual function}} + // since-cxx23-note@#dr2554-g {{overridden virtual function is here}} }; } @@ -153,48 +163,48 @@ namespace dr2565 { // dr2565: 16 static_assert(is_referenceable<int>::value); template<typename T, typename U> - concept TwoParams = requires (T *a, U b){ true;}; // #TPC + concept TwoParams = requires (T *a, U b){ true;}; // #dr2565-TPC template<typename T, typename U> - requires TwoParams<T, U> // #TPSREQ + requires TwoParams<T, U> // #dr2565-TPSREQ struct TwoParamsStruct{}; using TPSU = TwoParamsStruct<void, void>; - // expected-error@-1{{constraints not satisfied for class template 'TwoParamsStruct'}} - // expected-note@#TPSREQ{{because 'TwoParams<void, void>' evaluated to false}} - // expected-note@#TPC{{because 'b' would be invalid: argument may not have 'void' type}} + // since-cxx20-error@-1 {{constraints not satisfied for class template 'TwoParamsStruct'}} + // since-cxx20-note@#dr2565-TPSREQ {{because 'TwoParams<void, void>' evaluated to false}} + // since-cxx20-note@#dr2565-TPC {{because 'b' would be invalid: argument may not have 'void' type}} template<typename T, typename ...U> - concept Variadic = requires (U* ... a, T b){ true;}; // #VC + concept Variadic = requires (U* ... a, T b){ true;}; // #dr2565-VC template<typename T, typename ...U> - requires Variadic<T, U...> // #VSREQ + requires Variadic<T, U...> // #dr2565-VSREQ struct VariadicStruct{}; using VSU = VariadicStruct<void, int, char, double>; - // expected-error@-1{{constraints not satisfied for class template 'VariadicStruct'}} - // expected-note@#VSREQ{{because 'Variadic<void, int, char, double>' evaluated to false}} - // expected-note@#VC{{because 'b' would be invalid: argument may not have 'void' type}} + // since-cxx20-error@-1 {{constraints not satisfied for class template 'VariadicStruct'}} + // since-cxx20-note@#dr2565-VSREQ {{because 'Variadic<void, int, char, double>' evaluated to false}} + // since-cxx20-note@#dr2565-VC {{because 'b' would be invalid: argument may not have 'void' type}} template<typename T> - // expected-error@+1 {{unknown type name 'ErrorRequires'}} concept ErrorRequires = requires (ErrorRequires auto x) { + // since-cxx20-error@-1 {{unknown type name 'ErrorRequires'}} x; }; static_assert(ErrorRequires<int>); - // expected-error@-1{{static assertion failed}} - // expected-note@-2{{because substituted constraint expression is ill-formed: constraint depends on a previously diagnosed expression}} + // since-cxx20-error@-1 {{static assertion failed}} + // since-cxx20-note@-2 {{because substituted constraint expression is ill-formed: constraint depends on a previously diagnosed expression}} template<typename T> - // expected-error@+2 {{unknown type name 'NestedErrorInRequires'}} concept NestedErrorInRequires = requires (T x) { requires requires (NestedErrorInRequires auto y) { + // since-cxx20-error@-1 {{unknown type name 'NestedErrorInRequires'}} y; }; }; static_assert(NestedErrorInRequires<int>); - // expected-error@-1{{static assertion failed}} - // expected-note@-2{{because substituted constraint expression is ill-formed: constraint depends on a previously diagnosed expression}} + // expected-error@-1 {{static assertion failed}} + // expected-note@-2 {{because substituted constraint expression is ill-formed: constraint depends on a previously diagnosed expression}} #endif } |