diff --git a/clang/test/CXX/drs/cwg0xx.cpp b/clang/test/CXX/drs/cwg0xx.cpp index 6d3a3238d4f3..793ef5c7e2fd 100644 --- a/clang/test/CXX/drs/cwg0xx.cpp +++ b/clang/test/CXX/drs/cwg0xx.cpp @@ -484,7 +484,7 @@ namespace cwg33 { // cwg33: 9 template void t(X::S); template void u(X::S); - // expected-error@-1 0-1 {{default template arguments for a function template are a C++11 extension}} + // cxx98-error@-1 {{default template arguments for a function template are a C++11 extension}} void templ() { f(t); f(u); } // Even though v cannot select the first overload, ADL considers it @@ -1042,16 +1042,16 @@ namespace cwg62 { // cwg62: 2.9 // cxx98-note@#cwg62-unnamed {{unnamed type used in template argument was declared here}} NoNameForLinkagePtr p1 = get(); // cxx98-error@-1 {{template argument uses unnamed type}} + // cxx98-note@-2 {{while substituting explicitly-specified template arguments into function template 'get'}} // cxx98-note@#cwg62-unnamed {{unnamed type used in template argument was declared here}} - // cxx98-note@-3 {{while substituting explicitly-specified template arguments}} NoNameForLinkagePtr p2 = get(); // cxx98-error@-1 {{template argument uses unnamed type}} + // cxx98-note@-2 {{while substituting explicitly-specified template arguments into function template 'get'}} // cxx98-note@#cwg62-unnamed {{unnamed type used in template argument was declared here}} - // cxx98-note@-3 {{while substituting explicitly-specified template arguments}} int n1 = take(noNameForLinkagePtr); // cxx98-error@-1 {{template argument uses unnamed type}} + // cxx98-note@-2 {{while substituting deduced template arguments into function template 'take' [with T = NoNameForLinkagePtr]}} // cxx98-note@#cwg62-unnamed {{unnamed type used in template argument was declared here}} - // cxx98-note@-3 {{while substituting deduced template arguments}} X x4; @@ -1378,9 +1378,10 @@ namespace cwg92 { // cwg92: 4 c++17 // considered in this context. In C++17, we *do* perform an implicit // conversion (which performs initialization), and the exception specification // is part of the type of the parameter, so this is invalid. - template struct X {}; // since-cxx17-note {{template parameter is declared here}} + template struct X {}; // #cwg92-X X<&f> xp; // since-cxx17-error@-1 {{value of type 'void (*)() throw(int, float)' is not implicitly convertible to 'void (*)() throw()'}} + // since-cxx17-note@#cwg92-X {{template parameter is declared here}} template struct Y {}; // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}} @@ -1440,33 +1441,7 @@ namespace cwg97 { // cwg97: 2.7 }; } // namespace cwg97 -namespace cwg98 { // cwg98: 2.7 - void test(int n) { - switch (n) { - try { // #cwg98-try - case 0: - // expected-error@-1 {{cannot jump from switch statement to this case label}} - // expected-note@#cwg98-try {{jump bypasses initialization of try block}} - x: - throw n; - } catch (...) { // #cwg98-catch - case 1: - // expected-error@-1 {{cannot jump from switch statement to this case label}} - // expected-note@#cwg98-catch {{jump bypasses initialization of catch block}} - y: - throw n; - } - case 2: - goto x; - // expected-error@-1 {{cannot jump from this goto statement to its label}} - // expected-note@#cwg98-try {{jump bypasses initialization of try block}} - case 3: - goto y; - // expected-error@-1 {{cannot jump from this goto statement to its label}} - // expected-note@#cwg98-catch {{jump bypasses initialization of catch block}} - } - } -} // namespace cwg98 +// cwg98 is in cwg98.cpp namespace cwg99 { // cwg99: sup 214 template void f(T&); diff --git a/clang/test/CXX/drs/cwg10xx.cpp b/clang/test/CXX/drs/cwg10xx.cpp index c5b96c4ab8ff..f0aaa174d6c0 100644 --- a/clang/test/CXX/drs/cwg10xx.cpp +++ b/clang/test/CXX/drs/cwg10xx.cpp @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++11 %s -verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors +// RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors namespace std { __extension__ typedef __SIZE_TYPE__ size_t; @@ -41,8 +41,9 @@ namespace cwg1004 { // cwg1004: 5 // This example (from the standard) is actually ill-formed, because // name lookup of "T::template A" names the constructor. template class U = T::template A> struct Third { }; - // expected-error@-1 {{is a constructor name}} - // expected-note@#cwg1004-t {{in instantiation of default argument}} + // expected-error@-1 {{ISO C++ specifies that qualified reference to 'A' is a constructor name rather than a template name in this context, despite preceding 'typename' keyword}} + // cxx98-note@#cwg1004-t {{in instantiation of default argument for 'Third >' required here}} + // since-cxx11-note@#cwg1004-t {{in instantiation of default argument for 'Third>' required here}} Third > t; // #cwg1004-t } // namespace cwg1004 diff --git a/clang/test/CXX/drs/cwg13xx.cpp b/clang/test/CXX/drs/cwg13xx.cpp index 0f97c484becd..29d66ffb9241 100644 --- a/clang/test/CXX/drs/cwg13xx.cpp +++ b/clang/test/CXX/drs/cwg13xx.cpp @@ -79,47 +79,40 @@ namespace cwg1310 { // cwg1310: 5 W::W w1b; // expected-error@-1 {{qualified reference to 'W' is a constructor name rather than a template name in this context}} W::W::X w1bx; +#if __cplusplus >= 201103L typename W::W w2a; - // expected-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a type in this context, despite preceding 'typename' keyword}} - // cxx98-error@-2 {{'typename' outside of a template is a C++11 extension}} + // since-cxx11-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a type in this context, despite preceding 'typename' keyword}} typename W::W::X w2ax; - // cxx98-error@-1 {{'typename' outside of a template is a C++11 extension}} typename W::W w2b; - // expected-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'typename' keyword}} - // cxx98-error@-2 {{'typename' outside of a template is a C++11 extension}} + // since-cxx11-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'typename' keyword}} typename W::W::X w2bx; - // cxx98-error@-1 {{'typename' outside of a template is a C++11 extension}} W::template W w3; - // expected-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'template' keyword}} - // cxx98-error@-2 {{'template' keyword outside of a template}} + // since-cxx11-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'template' keyword}} W::template W::X w3x; - // cxx98-error@-1 {{'template' keyword outside of a template}} typename W::template W w4; - // expected-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'template' keyword}} - // cxx98-error@-2 {{'template' keyword outside of a template}} - // cxx98-error@-3 {{'typename' outside of a template is a C++11 extension}} + // since-cxx11-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'template' keyword}} typename W::template W::X w4x; - // cxx98-error@-1 {{'template' keyword outside of a template}} - // cxx98-error@-2 {{'typename' outside of a template is a C++11 extension}} +#endif TT::W> tt1; // expected-error@-1 {{qualified reference to 'W' is a constructor name rather than a type in this context}} TTy::W> tt1a; // expected-error@-1 {{qualified reference to 'W' is a constructor name rather than a type in this context}} - TT::template W> tt2; - // expected-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'template' keyword}} - // cxx98-error@-2 {{'template' keyword outside of a template}} TT::WBase> tt3; TTy::WBase> tt3a; +#if __cplusplus >= 201103L + TT::template W> tt2; + // since-cxx11-error@-1 {{ISO C++ specifies that qualified reference to 'W' is a constructor name rather than a template name in this context, despite preceding 'template' keyword}} TT::template WBase> tt4; - // cxx98-error@-1 {{'template' keyword outside of a template}} +#endif W w; (void)w.W::W::n; (void)w.W::W::n; (void)w.W::W::n; +#if __cplusplus >= 201103L (void)w.W::template W::n; - // cxx98-error@-1 {{'template' keyword outside of a template}} +#endif } template @@ -260,19 +253,18 @@ namespace cwg1330 { // cwg1330: 4 c++11 static_assert(!noexcept(B().g()), ""); #endif +#if __cplusplus <= 201402L template int f() throw(typename T::error) { return 0; } // #cwg1330-f - // expected-error@#cwg1330-f {{type 'int' cannot be used prior to '::' because it has no members}} + // cxx98-14-error@#cwg1330-f {{type 'int' cannot be used prior to '::' because it has no members}} // cxx98-note@#cwg1330-f-int {{in instantiation of function template specialization 'cwg1330::f' requested here}} - // since-cxx11-note@#cwg1330-f-int {{in instantiation of exception specification for 'f' requested here}} + // cxx11-14-note@#cwg1330-f-int {{in instantiation of exception specification for 'f' requested here}} + // cxx11-14-error@#cwg1330-f {{type 'char' cannot be used prior to '::' because it has no members}} + // cxx11-14-note@#cwg1330-f-char {{in instantiation of exception specification for 'f' requested here}} + // cxx11-14-error@#cwg1330-f {{type 'float' cannot be used prior to '::' because it has no members}} + // cxx11-14-note@#cwg1330-f-float {{in instantiation of exception specification for 'f' requested here}} // cxx98-14-error@#cwg1330-f {{type 'short' cannot be used prior to '::' because it has no members}} - // cxx98-14-note@#cwg1330-f-short {{in instantiation of function template specialization 'cwg1330::f' requested here}} // cxx11-14-note@#cwg1330-f {{in instantiation of exception specification for 'f' requested here}} - // since-cxx11-error@#cwg1330-f {{type 'char' cannot be used prior to '::' because it has no members}} - // since-cxx11-note@#cwg1330-f-char {{in instantiation of exception specification for 'f' requested here}} - // since-cxx11-error@#cwg1330-f {{type 'float' cannot be used prior to '::' because it has no members}} - // since-cxx11-note@#cwg1330-f-float {{in instantiation of exception specification for 'f' requested here}} - // since-cxx17-error@#cwg1330-f {{ISO C++17 does not allow dynamic exception specifications}} - // since-cxx17-note@#cwg1330-f {{use 'noexcept(false)' instead}} + // cxx98-14-note@#cwg1330-f-short {{in instantiation of function template specialization 'cwg1330::f' requested here}} // An exception-specification is needed even if the function is only used in // an unevaluated operand. @@ -282,9 +274,7 @@ namespace cwg1330 { // cwg1330: 4 c++11 bool f3 = noexcept(f()); /// #cwg1330-f-float #endif template int f(); // #cwg1330-f-short - // since-cxx17-error@#cwg1330-f {{type 'short' cannot be used prior to '::' because it has no members}} - // since-cxx17-note@#cwg1330-f {{in instantiation of exception specification for 'f' requested here}} - // since-cxx17-note@#cwg1330-f-short {{in instantiation of function template specialization 'cwg1330::f' requested here}} +#endif template struct C { C() throw(typename T::type); // #cwg1330-C @@ -358,22 +348,17 @@ namespace cwg1346 { // cwg1346: 3.5 } template void f(); // #cwg1346-f -#if __cplusplus >= 201103L +#if __cplusplus >= 201402L void init_capture() { [a(1)] {} (); - // cxx11-error@-1 {{initialized lambda captures are a C++14 extension}} [b(1, 2)] {} (); - // cxx11-error@-1 {{initialized lambda captures are a C++14 extension}} - // since-cxx11-error@-2 {{initializer for lambda capture 'b' contains multiple expressions}} + // since-cxx14-error@-1 {{initializer for lambda capture 'b' contains multiple expressions}} [c({})] {} (); - // cxx11-error@-1 {{initialized lambda captures are a C++14 extension}} - // since-cxx11-error@-2 {{cannot deduce type for lambda capture 'c' from parenthesized initializer list}} + // since-cxx14-error@-1 {{cannot deduce type for lambda capture 'c' from parenthesized initializer list}} [d({1})] {} (); - // cxx11-error@-1 {{initialized lambda captures are a C++14 extension}} - // since-cxx11-error@-2 {{cannot deduce type for lambda capture 'd' from parenthesized initializer list}} + // since-cxx14-error@-1 {{cannot deduce type for lambda capture 'd' from parenthesized initializer list}} [e({1, 2})] {} (); - // cxx11-error@-1 {{initialized lambda captures are a C++14 extension}} - // since-cxx11-error@-2 {{cannot deduce type for lambda capture 'e' from parenthesized initializer list}} + // since-cxx14-error@-1 {{cannot deduce type for lambda capture 'e' from parenthesized initializer list}} } #endif } // namespace cwg1346 diff --git a/clang/test/CXX/drs/cwg15xx.cpp b/clang/test/CXX/drs/cwg15xx.cpp index 8e3e49dc42ce..e97584c293cc 100644 --- a/clang/test/CXX/drs/cwg15xx.cpp +++ b/clang/test/CXX/drs/cwg15xx.cpp @@ -38,23 +38,41 @@ namespace cwg1512 { // cwg1512: 4 template void composite_pointer_type_is_ord() { composite_pointer_type_is_base(); - typedef __typeof(val() < val()) cmp; // #cwg1512-lt - // since-cxx17-warning@#cwg1512-lt {{ordered comparison of function pointers ('int (*)() noexcept' and 'int (*)()')}} - // since-cxx17-note@#cwg1512-noexcept-1st {{in instantiation of function template specialization 'cwg1512::composite_pointer_type_is_ord' requested here}} - // since-cxx17-warning@#cwg1512-lt {{ordered comparison of function pointers ('int (*)()' and 'int (*)() noexcept')}} - // since-cxx17-note@#cwg1512-noexcept-2nd {{in instantiation of function template specialization 'cwg1512::composite_pointer_type_is_ord' requested here}} + typedef __typeof(val() < val()) cmp; typedef __typeof(val() <= val()) cmp; - // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)() noexcept' and 'int (*)()')}} - // since-cxx17-warning@-2 {{ordered comparison of function pointers ('int (*)()' and 'int (*)() noexcept')}} typedef __typeof(val() > val()) cmp; - // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)() noexcept' and 'int (*)()')}} - // since-cxx17-warning@-2 {{ordered comparison of function pointers ('int (*)()' and 'int (*)() noexcept')}} typedef __typeof(val() >= val()) cmp; - // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)() noexcept' and 'int (*)()')}} - // since-cxx17-warning@-2 {{ordered comparison of function pointers ('int (*)()' and 'int (*)() noexcept')}} typedef bool cmp; } +#if __cplusplus >= 201703L + void composite_pointer_type_is_ord_2() { + composite_pointer_type_is_base(); + + typedef __typeof(val() < val()) cmp; + // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)() noexcept' and 'int (*)()')}} + typedef __typeof(val() <= val()) cmp; + // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)() noexcept' and 'int (*)()')}} + typedef __typeof(val() > val()) cmp; + // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)() noexcept' and 'int (*)()')}} + typedef __typeof(val() >= val()) cmp; + // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)() noexcept' and 'int (*)()')}} + + composite_pointer_type_is_base(); + + typedef __typeof(val() < val()) cmp; + // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)()' and 'int (*)() noexcept')}} + typedef __typeof(val() <= val()) cmp; + // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)()' and 'int (*)() noexcept')}} + typedef __typeof(val() > val()) cmp; + // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)()' and 'int (*)() noexcept')}} + typedef __typeof(val() >= val()) cmp; + // since-cxx17-warning@-1 {{ordered comparison of function pointers ('int (*)()' and 'int (*)() noexcept')}} + + typedef bool cmp; + } +#endif + template void composite_pointer_type_is_unord(int = 0) { composite_pointer_type_is_base(); @@ -100,8 +118,6 @@ namespace cwg1512 { // cwg1512: 4 // since-cxx20-warning@-1 {{volatile-qualified return type 'volatile int' is deprecated}} #if __cplusplus >= 201703L - composite_pointer_type_is_ord(); // #cwg1512-noexcept-1st - composite_pointer_type_is_ord(); // #cwg1512-noexcept-2nd composite_pointer_type_is_unord(); composite_pointer_type_is_unord(); // FIXME: This looks like a standard defect; these should probably all have type 'int (B::*)()'. @@ -157,15 +173,15 @@ namespace cwg1512 { // cwg1512: 4 // since-cxx11-note@#cwg1512-Wrap {{first operand was implicitly converted to type 'std::nullptr_t'}} // since-cxx11-note@#cwg1512-Wrap {{second operand was implicitly converted to type 'int *'}} void(Wrap() > Wrap()); - // since-cxx11-error@-1 {{invalid operands}} + // since-cxx11-error@-1 {{invalid operands to binary expression ('Wrap' (aka 'Wrap') and 'Wrap')}} // since-cxx11-note@#cwg1512-Wrap {{first operand was implicitly converted to type 'std::nullptr_t'}} // since-cxx11-note@#cwg1512-Wrap{{second operand was implicitly converted to type 'int *'}} void(Wrap() <= Wrap()); - // since-cxx11-error@-1 {{invalid operands}} + // since-cxx11-error@-1 {{invalid operands to binary expression ('Wrap' (aka 'Wrap') and 'Wrap')}} // since-cxx11-note@#cwg1512-Wrap {{first operand was implicitly converted to type 'std::nullptr_t'}} // since-cxx11-note@#cwg1512-Wrap {{second operand was implicitly converted to type 'int *'}} void(Wrap() >= Wrap()); - // since-cxx11-error@-1 {{invalid operands}} + // since-cxx11-error@-1 {{invalid operands to binary expression ('Wrap' (aka 'Wrap') and 'Wrap')}} // since-cxx11-note@#cwg1512-Wrap {{first operand was implicitly converted to type 'std::nullptr_t'}} // since-cxx11-note@#cwg1512-Wrap {{second operand was implicitly converted to type 'int *'}} } @@ -309,16 +325,14 @@ namespace std_example { // since-cxx11-note@#cwg1518-x {{passing argument to parameter 't' here}} } - void test() { - f(); // #cwg1518-f-A - f(); // #cwg1518-f-B - f(); // #cwg1518-f-C - f(); // #cwg1518-f-D - g(); // #cwg1518-g-A - g(); // #cwg1518-g-B - g(); // #cwg1518-g-C - g(); // #cwg1518-g-D - } + template void f(); // #cwg1518-f-A + template void f(); // #cwg1518-f-B + template void f(); // #cwg1518-f-C + template void f(); // #cwg1518-f-D + template void g(); // #cwg1518-g-A + template void g(); // #cwg1518-g-B + template void g(); // #cwg1518-g-C + template void g(); // #cwg1518-g-D } #endif // __cplusplus >= 201103L } // namespace cwg1518 @@ -426,8 +440,8 @@ namespace cwg1573 { // cwg1573: 3.9 constexpr F f = F(0); // since-cxx11-error@-1 {{constexpr variable 'f' must be initialized by a constant expression}} // cxx11-20-note@-2 {{constructor inherited from base class 'C' cannot be used in a constant expression; derived class cannot be implicitly initialized}} - // since-cxx23-note@-3 {{in implicit initialization for inherited constructor of 'F'}} // since-cxx23-note@#cwg1573-F {{non-constexpr constructor 'C' cannot be used in a constant expression}} + // since-cxx23-note@-4 {{in implicit initialization for inherited constructor of 'F'}} // cxx11-20-note@#cwg1573-F {{declared here}} // since-cxx23-note@#cwg1573-C {{declared here}} @@ -564,16 +578,18 @@ namespace cwg1584 { // cwg1584: 7 drafting 2015-05 // Deducing function types from cv-qualified types template void f(const T *); // #cwg1584-f template void g(T *, const T * = 0); -template void h(T *) { T::error; } -// expected-error@-1 {{type 'void ()' cannot be used prior to '::' because it has no members}} -// expected-note@#cwg1584-h {{in instantiation of function template specialization 'cwg1584::h' requested here}} -template void h(const T *); +template void h(T *) = delete; // #cwg1584-h-T +// cxx98-error@-1 {{deleted function definitions are a C++11 extension}} +template void h(const T *); // #cwg1584-h-const-T void i() { f(&i); // expected-error@-1 {{no matching function for call to 'f'}} // expected-note@#cwg1584-f {{candidate template ignored: could not match 'const T *' against 'void (*)()'}} g(&i); - h(&i); // #cwg1584-h + h(&i); + // expected-error@-1 {{call to deleted function 'h'}} + // expected-note@#cwg1584-h-T {{candidate function [with T = void ()] has been explicitly deleted}} + // expected-note@#cwg1584-h-const-T {{candidate template ignored: could not match 'const T *' against 'void (*)()'}} } template struct tuple_size { diff --git a/clang/test/CXX/drs/cwg16xx.cpp b/clang/test/CXX/drs/cwg16xx.cpp index 1a36aba859e5..efb743871d52 100644 --- a/clang/test/CXX/drs/cwg16xx.cpp +++ b/clang/test/CXX/drs/cwg16xx.cpp @@ -266,12 +266,14 @@ namespace cwg1658 { // cwg1658: 5 struct A { A(A&); }; struct B : virtual A { virtual void f() = 0; }; struct C : virtual A { virtual void f(); }; - struct D : A { virtual void f() = 0; }; // since-cxx23-note {{previous declaration is here}} + struct D : A { virtual void f() = 0; }; // #cwg1658-D struct X { friend B::B(const B&) throw(); friend C::C(C&); - friend D::D(D&); // since-cxx23-error {{non-constexpr declaration of 'D' follows constexpr declaration}} + friend D::D(D&); + // since-cxx23-error@-1 {{non-constexpr declaration of 'D' follows constexpr declaration}} + // since-cxx23-note@#cwg1658-D {{previous declaration is here}} }; } @@ -373,7 +375,6 @@ namespace cwg1687 { // cwg1687: 7 int *a = To() + 100.0; // expected-error@-1 {{invalid operands to binary expression ('To' and 'double')}} // expected-note@#cwg1687-op-T {{first operand was implicitly converted to type 'int *'}} - // since-cxx20-note@#cwg1687-op-T {{second operand was implicitly converted to type 'cwg1687::E2'}} int *b = To() + To(); // expected-error@-1 {{invalid operands to binary expression ('To' and 'To')}} // expected-note@#cwg1687-op-T {{first operand was implicitly converted to type 'int *'}} @@ -384,7 +385,8 @@ namespace cwg1687 { // cwg1687: 7 enum E2 {}; auto c = To() <=> To(); // since-cxx20-error@-1 {{invalid operands to binary expression ('To' and 'To')}} - // since-cxx20-note@#cwg1687-op-T {{operand was implicitly converted to type 'cwg1687::E}} + // since-cxx20-note@#cwg1687-op-T {{first operand was implicitly converted to type 'cwg1687::E1'}} + // since-cxx20-note@#cwg1687-op-T {{second operand was implicitly converted to type 'cwg1687::E2'}} #endif } // namespace cwg1687 @@ -458,13 +460,13 @@ namespace cwg1696 { // cwg1696: 7 }; struct A2 { - A2() = default; - // since-cxx14-error@-1 {{reference member 'v' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}} - // since-cxx14-note-re@#cwg1696-A2-b {{in defaulted default constructor for {{.*}} first required here}} - // since-cxx14-note@#cwg1696-A2-a {{initializing field 'v' with default member initializer}} A2(int v) : v(v) {} // since-cxx14-warning@-1 {{binding reference member 'v' to stack allocated parameter 'v'}} - // since-cxx14-note@#cwg1696-A2-a {{reference member declared here}} + // since-cxx14-note@#cwg1696-A2-a {{reference member declared here}} + A2() = default; + // since-cxx14-error@-1 {{reference member 'v' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}} + // since-cxx14-note-re@#cwg1696-A2-b {{in defaulted default constructor for {{.*}} first required here}} + // since-cxx14-note@#cwg1696-A2-a {{initializing field 'v' with default member initializer}} const int &v = 42; // #cwg1696-A2-a }; A2 a1; // #cwg1696-A2-b diff --git a/clang/test/CXX/drs/cwg1736.cpp b/clang/test/CXX/drs/cwg1736.cpp new file mode 100644 index 000000000000..25b9fcb747ec --- /dev/null +++ b/clang/test/CXX/drs/cwg1736.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -std=c++98 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify=expected,cxx98 +// RUN: %clang_cc1 -std=c++11 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify=expected,since-cxx11 +// RUN: %clang_cc1 -std=c++14 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify=expected,since-cxx11 +// RUN: %clang_cc1 -std=c++17 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify=expected,since-cxx11 +// RUN: %clang_cc1 -std=c++20 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify=expected,since-cxx11 +// RUN: %clang_cc1 -std=c++23 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify=expected,since-cxx11 +// RUN: %clang_cc1 -std=c++2c %s -fexceptions -fcxx-exceptions -pedantic-errors -verify=expected,since-cxx11 + +// cxx98-no-diagnostics + +namespace cwg1736 { // cwg1736: 3.9 +#if __cplusplus >= 201103L +struct S { + template S(T t) { + struct L : S { + using S::S; + }; + typename T::type value; + // since-cxx11-error@-1 {{type 'int' cannot be used prior to '::' because it has no members}} + // since-cxx11-note@#cwg1736-l {{in instantiation of function template specialization 'cwg1736::S::S' requested here}} + // since-cxx11-note@#cwg1736-s {{in instantiation of function template specialization 'cwg1736::S::S' requested here}} + L l(value); // #cwg1736-l + } +}; +struct Q { typedef int type; } q; +S s(q); // #cwg1736-s +#endif +} // namespace cwg1736 diff --git a/clang/test/CXX/drs/cwg17xx.cpp b/clang/test/CXX/drs/cwg17xx.cpp index 8c4f916a606a..cafa21dc17ee 100644 --- a/clang/test/CXX/drs/cwg17xx.cpp +++ b/clang/test/CXX/drs/cwg17xx.cpp @@ -98,24 +98,7 @@ static_assert(__is_trivially_copyable(A), ""); #endif } // namespace cwg1734 -namespace cwg1736 { // cwg1736: 3.9 -#if __cplusplus >= 201103L -struct S { - template S(T t) { - struct L : S { - using S::S; - }; - typename T::type value; - // since-cxx11-error@-1 {{type 'int' cannot be used prior to '::' because it has no members}} - // since-cxx11-note@#cwg1736-l {{in instantiation of function template specialization 'cwg1736::S::S' requested here}} - // since-cxx11-note@#cwg1736-s {{in instantiation of function template specialization 'cwg1736::S::S' requested here}} - L l(value); // #cwg1736-l - } -}; -struct Q { typedef int type; } q; -S s(q); // #cwg1736-s -#endif -} // namespace cwg1736 +// cwg1736 is in cwg1736.cpp namespace cwg1738 { // cwg1738: sup P0136R1 #if __cplusplus >= 201103L diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp index c0363fa467ea..f8f85611498f 100644 --- a/clang/test/CXX/drs/cwg18xx.cpp +++ b/clang/test/CXX/drs/cwg18xx.cpp @@ -213,8 +213,8 @@ namespace cwg1815 { // cwg1815: 20 struct B { int &&r = 0; }; // #cwg1815-B // since-cxx14-error@-1 {{reference member 'r' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}} - // since-cxx14-note@#cwg1815-B {{initializing field 'r' with default member initializer}} // since-cxx14-note@#cwg1815-b {{in implicit default constructor for 'cwg1815::B' first required here}} + // since-cxx14-note@#cwg1815-B {{initializing field 'r' with default member initializer}} B b; // #cwg1815-b #if __cplusplus >= 201703L @@ -584,16 +584,16 @@ void cwg1891() { // cwg1891: 4 typedef decltype(b) B; static_assert(!__is_trivially_constructible(A), ""); - // since-cxx20-error@-1 {{failed}} + // since-cxx20-error-re@-1 {{static assertion failed due to requirement '!__is_trivially_constructible((lambda at {{.+}}))':}} static_assert(!__is_trivially_constructible(B), ""); // C++20 allows default construction for non-capturing lambdas (P0624R2). A x; - // cxx11-17-error@-1 {{no matching constructor for initialization of 'A' (aka '(lambda at}} + // cxx11-17-error-re@-1 {{no matching constructor for initialization of 'A' (aka '(lambda at {{.+}})')}} // cxx11-17-note@#cwg1891-a {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}} // cxx11-17-note@#cwg1891-a {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}} B y; - // since-cxx11-error@-1 {{no matching constructor for initialization of 'B' (aka '(lambda at}} + // since-cxx11-error-re@-1 {{no matching constructor for initialization of 'B' (aka '(lambda at {{.+}})')}} // since-cxx11-note@#cwg1891-b {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}} // since-cxx11-note@#cwg1891-b {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}} diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp index 066a429ea1c5..359a194b1fdb 100644 --- a/clang/test/CXX/drs/cwg1xx.cpp +++ b/clang/test/CXX/drs/cwg1xx.cpp @@ -213,8 +213,7 @@ namespace cwg115 { // cwg115: 3.0 &f; // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} // expected-note@#cwg115-f {{possible target for call}} - &f; - // expected-warning@-1 {{expression result unused}} + (void)&f; &g; // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} // expected-note@#cwg115-g-int {{possible target for call}} @@ -242,8 +241,7 @@ namespace cwg115 { // cwg115: 3.0 &s.f; // expected-error@-1 {{cannot create a non-constant pointer to member function}} - &s.f; - // expected-warning@-1 {{expression result unused}} + (void)&s.f; &s.g; // expected-error@-1 {{cannot create a non-constant pointer to member function}} } @@ -269,8 +267,7 @@ namespace cwg115 { // cwg115: 3.0 &s.f; // expected-error@-1 {{cannot create a non-constant pointer to member function}} - &s.f; - // expected-warning@-1 {{expression result unused}} + (void)&s.f; &s.g; // expected-error@-1 {{cannot create a non-constant pointer to member function}} } @@ -290,8 +287,7 @@ namespace cwg115 { // cwg115: 3.0 &with_default; // since-cxx11-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} // since-cxx11-note@#cwg115-with-default {{possible target for call}} - &with_default<>; - // since-cxx11-warning@-1 {{expression result unused}} + (void)&with_default<>; } #endif } // namespace cwg115 @@ -467,15 +463,17 @@ namespace cwg127 { // cwg127: 2.9 template struct A { A() { throw 0; } void *operator new(size_t, const char * = 0); - void operator delete(void *, const char *) { T::error; } // #cwg127-delete-const-char - // expected-error@#cwg127-delete-const-char {{type 'void' cannot be used prior to '::' because it has no members}} - // expected-note@#cwg127-p {{in instantiation of member function 'cwg127::A::operator delete' requested here}} - // expected-error@#cwg127-delete-const-char {{type 'int' cannot be used prior to '::' because it has no members}} - // expected-note@#cwg127-q {{in instantiation of member function 'cwg127::A::operator delete' requested here}} - void operator delete(void *) { T::error; } + void operator delete(void *, const char *) = delete; // #cwg127-delete-char + // cxx98-error@-1 {{deleted function definitions are a C++11 extension}} + void operator delete(void *) = delete; + // cxx98-error@-1 {{deleted function definitions are a C++11 extension}} }; - A *p = new A; // #cwg127-p - A *q = new ("") A; // #cwg127-q + A *p = new A; + // expected-error@-1 {{attempt to use a deleted function}} + // expected-note@#cwg127-delete-char {{'operator delete' has been explicitly marked deleted here}} + A *q = new ("") A; + // expected-error@-1 {{attempt to use a deleted function}} + // expected-note@#cwg127-delete-char {{'operator delete' has been explicitly marked deleted here}} } // namespace cwg127 namespace cwg128 { // cwg128: 2.7 @@ -706,7 +704,8 @@ namespace cwg141 { // cwg141: 3.1 // FIXME: we issue a useful diagnostic first, then some bogus ones. b.f(); // expected-error@-1 {{no member named 'f' in 'cwg141::B'}} - // expected-error@-2 +{{}} + // expected-error-re@-2 {{{{.*}}}} + // expected-error-re@-3 {{{{.*}}}} (void)b.S::n; } template struct C { @@ -1253,9 +1252,11 @@ namespace cwg180 { // cwg180: 2.8 namespace cwg181 { // cwg181: 2.7 namespace X { template