1 // RUN: %clang_cc1 -std=c++98 -pedantic-errors -verify=expected,cxx98 %s 2 // RUN: %clang_cc1 -std=c++11 -pedantic-errors -verify=expected,since-cxx11 %s 3 // RUN: %clang_cc1 -std=c++14 -pedantic-errors -verify=expected,since-cxx11 %s 4 // RUN: %clang_cc1 -std=c++17 -pedantic-errors -verify=expected,since-cxx11 %s 5 // RUN: %clang_cc1 -std=c++20 -pedantic-errors -verify=expected,since-cxx11,since-cxx20 %s 6 // RUN: %clang_cc1 -std=c++23 -pedantic-errors -verify=expected,since-cxx11,since-cxx20,since-cxx23 %s 7 // RUN: %clang_cc1 -std=c++2c -pedantic-errors -verify=expected,since-cxx11,since-cxx20,since-cxx23,since-cxx26 %s 8 9 // cxx98-no-diagnostics 10 11 namespace cwg2913 { // cwg2913: 20 12 13 #if __cplusplus >= 202002L 14 15 template<typename T> 16 struct R { 17 R(T); 18 R(T, T); 19 }; 20 21 template<typename T> 22 R(T) -> R<T> requires true; 23 24 template<typename T> 25 R(T, T) requires true -> R<T>; 26 // since-cxx20-error@-1 {{expected function body after function declarator}} 27 28 #endif 29 30 } // namespace cwg2913 31 32 namespace cwg2915 { // cwg2915: 20 33 #if __cplusplus >= 202302L 34 struct A { 35 void f(this void); 36 // since-cxx23-error@-1 {{explicit object parameter cannot have 'void' type}} 37 }; 38 #endif 39 } // namespace cwg2915 40 41 namespace cwg2917 { // cwg2917: 20 review 2024-07-30 42 #if __cplusplus >= 201103L 43 template <typename> 44 class Foo; 45 46 template<class ...> 47 struct C { 48 struct Nested { }; 49 }; 50 51 struct S { 52 template <typename> 53 friend class Foo, int; 54 // since-cxx11-error@-1 {{a friend declaration that befriends a template must contain exactly one type-specifier}} 55 56 template <typename ...Ts> 57 friend class C<Ts>::Nested...; 58 // since-cxx11-error@-1 {{friend declaration expands pack 'Ts' that is declared it its own template parameter list}} 59 }; 60 #endif 61 } // namespace cwg2917 62 63 #if __cplusplus > 202302L 64 namespace std { 65 using size_t = decltype(sizeof(0)); 66 } // namespace std 67 void *operator new(std::size_t, void *p) { return p; } 68 void* operator new[] (std::size_t, void* p) {return p; } 69 #endif 70 71 namespace cwg2922 { // cwg2922: 20 72 #if __cplusplus > 202302L 73 union U { int a, b; }; 74 constexpr U nondeterministic(bool i) { 75 if(i) { 76 U u; 77 new (&u) int(); // #cwg2922-placement-new 78 return u; 79 } 80 return {}; 81 } 82 constexpr U _ = nondeterministic(true); 83 // since-cxx26-error@-1 {{constexpr variable '_' must be initialized by a constant expression}} 84 // since-cxx26-note@#cwg2922-placement-new {{placement new would change type of storage from 'U' to 'int'}} 85 // since-cxx26-note@-3 {{in call to 'nondeterministic(true)'}} 86 #endif 87 } // namespace cwg2922 88