xref: /llvm-project/clang/test/CXX/drs/cwg26xx.cpp (revision b46fcb9fa32f24660b1b8858d5c4cbdb76ef9d8b)
1574e9584SMital Ashok // RUN: %clang_cc1 -std=c++98 -pedantic-errors %s -verify=expected,cxx98
2574e9584SMital Ashok // RUN: %clang_cc1 -std=c++11 -pedantic-errors %s -verify=expected,since-cxx11,cxx11
3574e9584SMital Ashok // RUN: %clang_cc1 -std=c++14 -pedantic-errors %s -verify=expected,since-cxx11
4574e9584SMital Ashok // RUN: %clang_cc1 -std=c++17 -pedantic-errors %s -verify=expected,since-cxx11
5574e9584SMital Ashok // RUN: %clang_cc1 -std=c++20 -pedantic-errors %s -verify=expected,since-cxx11,since-cxx20
6574e9584SMital Ashok // RUN: %clang_cc1 -std=c++23 -pedantic-errors %s -verify=expected,since-cxx11,since-cxx20,since-cxx23
7574e9584SMital Ashok // RUN: %clang_cc1 -std=c++2c -pedantic-errors %s -verify=expected,since-cxx11,since-cxx20,since-cxx23
8d358b2deSVlad Serebrennikov 
9574e9584SMital Ashok #if __cplusplus == 199711L
10574e9584SMital Ashok #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
11574e9584SMital Ashok // cxx98-error@-1 {{variadic macros are a C99 feature}}
12574e9584SMital Ashok #endif
13574e9584SMital Ashok 
14574e9584SMital Ashok namespace std {
15574e9584SMital Ashok #if __cplusplus >= 202002L
16574e9584SMital Ashok   struct strong_ordering {
17574e9584SMital Ashok     int n;
18574e9584SMital Ashok     constexpr operator int() const { return n; }
19574e9584SMital Ashok     static const strong_ordering less, equal, greater;
20574e9584SMital Ashok   };
21574e9584SMital Ashok   constexpr strong_ordering strong_ordering::less{-1},
22574e9584SMital Ashok       strong_ordering::equal{0}, strong_ordering::greater{1};
23574e9584SMital Ashok #endif
24574e9584SMital Ashok 
25574e9584SMital Ashok   typedef short int16_t;
26574e9584SMital Ashok   typedef unsigned short uint16_t;
27574e9584SMital Ashok   typedef int int32_t;
28574e9584SMital Ashok   typedef unsigned uint32_t;
29574e9584SMital Ashok   typedef long long int64_t;
30574e9584SMital Ashok   // cxx98-error@-1 {{'long long' is a C++11 extension}}
31574e9584SMital Ashok   typedef unsigned long long uint64_t;
32574e9584SMital Ashok   // cxx98-error@-1 {{'long long' is a C++11 extension}}
33574e9584SMital Ashok   static_assert(sizeof(int16_t) == 2 && sizeof(int32_t) == 4 && sizeof(int64_t) == 8, "Some tests rely on these sizes");
34574e9584SMital Ashok 
35574e9584SMital Ashok   template<typename T> T declval();
36463e61a0SVlad Serebrennikov } // namespace std
37d358b2deSVlad Serebrennikov 
38bc4d50f0SVlad Serebrennikov namespace cwg2621 { // cwg2621: sup 2877
39d358b2deSVlad Serebrennikov #if __cplusplus >= 202002L
40d358b2deSVlad Serebrennikov enum class E { a };
41d358b2deSVlad Serebrennikov namespace One {
42d358b2deSVlad Serebrennikov using E_t = E;
43d358b2deSVlad Serebrennikov using enum E_t; // typedef ok
44d358b2deSVlad Serebrennikov auto v = a;
45d358b2deSVlad Serebrennikov }
46d358b2deSVlad Serebrennikov namespace Two {
47d358b2deSVlad Serebrennikov using cwg2621::E;
48bc4d50f0SVlad Serebrennikov int E; // ignored by type-only lookup
49d358b2deSVlad Serebrennikov using enum E;
50d358b2deSVlad Serebrennikov }
51d358b2deSVlad Serebrennikov #endif
52463e61a0SVlad Serebrennikov } // namespace cwg2621
53d358b2deSVlad Serebrennikov 
54574e9584SMital Ashok namespace cwg2627 { // cwg2627: 20
55574e9584SMital Ashok #if __cplusplus >= 202002L
56574e9584SMital Ashok struct C {
57574e9584SMital Ashok   long long i : 8;
58574e9584SMital Ashok   friend auto operator<=>(C, C) = default;
59574e9584SMital Ashok };
60574e9584SMital Ashok 
61574e9584SMital Ashok void f() {
62574e9584SMital Ashok   C x{1}, y{2};
63574e9584SMital Ashok   static_cast<void>(x <=> y);
64574e9584SMital Ashok   static_cast<void>(x.i <=> y.i);
65574e9584SMital Ashok }
66574e9584SMital Ashok 
67574e9584SMital Ashok template<typename T>
68574e9584SMital Ashok struct CDependent {
69574e9584SMital Ashok   T i : 8;
70574e9584SMital Ashok   friend auto operator<=>(CDependent, CDependent) = default;
71574e9584SMital Ashok };
72574e9584SMital Ashok 
73574e9584SMital Ashok template<typename T>
74574e9584SMital Ashok concept three_way_comparable = requires(T t) { { t <=> t }; };
75574e9584SMital Ashok template<typename T>
76574e9584SMital Ashok concept bf_three_way_comparable = requires(T t) { { t.i <=> t.i }; };
77574e9584SMital Ashok static_assert(three_way_comparable<CDependent<long long>>);
78574e9584SMital Ashok static_assert(bf_three_way_comparable<CDependent<long long>>);
79574e9584SMital Ashok #endif
80574e9584SMital Ashok 
81574e9584SMital Ashok #if __cplusplus >= 201103L
82574e9584SMital Ashok template<typename T, int N>
83574e9584SMital Ashok struct D {
84574e9584SMital Ashok   T i : N;
85574e9584SMital Ashok };
86574e9584SMital Ashok 
87574e9584SMital Ashok template<typename T, int N>
88574e9584SMital Ashok D<T, N> d();
89574e9584SMital Ashok 
90574e9584SMital Ashok std::int32_t d1{ d<std::int64_t, 31>().i };
91574e9584SMital Ashok std::int32_t d2{ d<std::int64_t, 32>().i };
92574e9584SMital Ashok std::int32_t d3{ d<std::int64_t, 33>().i };
93574e9584SMital Ashok // since-cxx11-error@-1 {{non-constant-expression cannot be narrowed from type 'long long' to 'std::int32_t' (aka 'int') in initializer list}}
94574e9584SMital Ashok //   since-cxx11-note@-2 {{insert an explicit cast to silence this issue}}
95574e9584SMital Ashok 
96574e9584SMital Ashok std::int16_t d6{ d<int, 16>().i };
97574e9584SMital Ashok std::int16_t d7{ d<unsigned, 15>().i };
98574e9584SMital Ashok std::int16_t d8{ d<unsigned, 16>().i };
99574e9584SMital Ashok // since-cxx11-error@-1 {{non-constant-expression cannot be narrowed from type 'unsigned int' to 'std::int16_t' (aka 'short') in initializer list}}
100574e9584SMital Ashok //   since-cxx11-note@-2 {{insert an explicit cast to silence this issue}}
101574e9584SMital Ashok std::uint16_t d9{ d<unsigned, 16>().i };
102574e9584SMital Ashok std::uint16_t da{ d<int, 1>().i };
103574e9584SMital Ashok // since-cxx11-error@-1 {{non-constant-expression cannot be narrowed from type 'int' to 'std::uint16_t' (aka 'unsigned short') in initializer list}}
104574e9584SMital Ashok //   since-cxx11-note@-2 {{insert an explicit cast to silence this issue}}
105574e9584SMital Ashok 
106574e9584SMital Ashok bool db{ d<unsigned, 1>().i };
107574e9584SMital Ashok bool dc{ d<int, 1>().i };
108574e9584SMital Ashok // since-cxx11-error@-1 {{non-constant-expression cannot be narrowed from type 'int' to 'bool' in initializer list}}
109574e9584SMital Ashok //   since-cxx11-note@-2 {{insert an explicit cast to silence this issue}}
110574e9584SMital Ashok 
111574e9584SMital Ashok template<typename Target, typename Source>
112574e9584SMital Ashok constexpr decltype(Target{ std::declval<Source>().i }, false) is_narrowing(int) { return false; }
113574e9584SMital Ashok template<typename Target, typename Source>
114574e9584SMital Ashok constexpr bool is_narrowing(long) { return true; }
115574e9584SMital Ashok 
116574e9584SMital Ashok static_assert(!is_narrowing<std::int16_t, D<int, 16>>(0), "");
117574e9584SMital Ashok static_assert(!is_narrowing<std::int16_t, D<unsigned, 15>>(0), "");
118574e9584SMital Ashok static_assert(is_narrowing<std::int16_t, D<unsigned, 16>>(0), "");
119574e9584SMital Ashok static_assert(!is_narrowing<std::uint16_t, D<unsigned, 16>>(0), "");
120574e9584SMital Ashok static_assert(is_narrowing<std::uint16_t, D<int, 1>>(0), "");
121574e9584SMital Ashok static_assert(!is_narrowing<bool, D<unsigned, 1>>(0), "");
122574e9584SMital Ashok static_assert(is_narrowing<bool, D<int, 1>>(0), "");
123574e9584SMital Ashok 
124574e9584SMital Ashok template<int N>
125574e9584SMital Ashok struct E {
126574e9584SMital Ashok   signed int x : N;
127574e9584SMital Ashok   decltype(std::int16_t{ x }) dependent_narrowing;
128574e9584SMital Ashok   decltype(unsigned{ x }) always_narrowing;
129574e9584SMital Ashok   // since-cxx11-error@-1 {{non-constant-expression cannot be narrowed from type 'int' to 'unsigned int' in initializer list}}
130574e9584SMital Ashok   //   since-cxx11-note@-2 {{insert an explicit cast to silence this issue}}
131574e9584SMital Ashok };
132574e9584SMital Ashok #endif
133574e9584SMital Ashok } // namespace cwg2627
134574e9584SMital Ashok 
135*b46fcb9fSYounan Zhang namespace cwg2628 { // cwg2628: 20
136d358b2deSVlad Serebrennikov #if __cplusplus >= 202002L
137d358b2deSVlad Serebrennikov template <bool A = false, bool B = false>
138d358b2deSVlad Serebrennikov struct foo {
139*b46fcb9fSYounan Zhang   constexpr foo() requires (!A && !B) = delete; // #cwg2628-ctor
140*b46fcb9fSYounan Zhang   constexpr foo() requires (A || B) = delete;
141d358b2deSVlad Serebrennikov };
142d358b2deSVlad Serebrennikov 
143d358b2deSVlad Serebrennikov void f() {
144d358b2deSVlad Serebrennikov   foo fooable; // #cwg2628-fooable
145*b46fcb9fSYounan Zhang   // since-cxx20-error@#cwg2628-fooable {{call to deleted}}
146*b46fcb9fSYounan Zhang   //   since-cxx20-note@#cwg2628-ctor {{marked deleted here}}
147d358b2deSVlad Serebrennikov }
148d358b2deSVlad Serebrennikov #endif
149463e61a0SVlad Serebrennikov } // namespace cwg2628
150d358b2deSVlad Serebrennikov 
151d542eb7aSVlad Serebrennikov // cwg2630 is in cwg2630.cpp
152d542eb7aSVlad Serebrennikov 
153d358b2deSVlad Serebrennikov namespace cwg2631 { // cwg2631: 16
154d358b2deSVlad Serebrennikov #if __cplusplus >= 202002L
155d358b2deSVlad Serebrennikov   constexpr int g();
156d358b2deSVlad Serebrennikov   consteval int f() {
157d358b2deSVlad Serebrennikov     return g();
158d358b2deSVlad Serebrennikov   }
159d358b2deSVlad Serebrennikov   int k(int x = f()) {
160d358b2deSVlad Serebrennikov     return x;
161d358b2deSVlad Serebrennikov   }
162d358b2deSVlad Serebrennikov   constexpr int g() {
163d358b2deSVlad Serebrennikov     return 42;
164d358b2deSVlad Serebrennikov   }
165d358b2deSVlad Serebrennikov   int test() {
166d358b2deSVlad Serebrennikov     return k();
167d358b2deSVlad Serebrennikov   }
168d358b2deSVlad Serebrennikov #endif
169463e61a0SVlad Serebrennikov } // namespace cwg2631
170d358b2deSVlad Serebrennikov 
171d358b2deSVlad Serebrennikov namespace cwg2635 { // cwg2635: 16
172d358b2deSVlad Serebrennikov #if __cplusplus >= 202002L
173d358b2deSVlad Serebrennikov template<typename T>
174d358b2deSVlad Serebrennikov concept UnaryC = true;
175d358b2deSVlad Serebrennikov template<typename T, typename U>
176d358b2deSVlad Serebrennikov concept BinaryC = true;
177d358b2deSVlad Serebrennikov 
178d358b2deSVlad Serebrennikov struct S{ int i, j; };
179d358b2deSVlad Serebrennikov S get_S();
180d358b2deSVlad Serebrennikov 
181d358b2deSVlad Serebrennikov template<typename T>
182d358b2deSVlad Serebrennikov T get_T();
183d358b2deSVlad Serebrennikov 
184d358b2deSVlad Serebrennikov void use() {
185d358b2deSVlad Serebrennikov   UnaryC auto [a, b] = get_S();
186d358b2deSVlad Serebrennikov   // since-cxx20-error@-1 {{decomposition declaration cannot be declared with constrained 'auto'}}
187d358b2deSVlad Serebrennikov   BinaryC<int> auto [c, d] = get_S();
188d358b2deSVlad Serebrennikov   // since-cxx20-error@-1 {{decomposition declaration cannot be declared with constrained 'auto'}}
189d358b2deSVlad Serebrennikov }
190d358b2deSVlad Serebrennikov 
191d358b2deSVlad Serebrennikov template<typename T>
192d358b2deSVlad Serebrennikov void TemplUse() {
193d358b2deSVlad Serebrennikov   UnaryC auto [a, b] = get_T<T>();
194d358b2deSVlad Serebrennikov   // since-cxx20-error@-1 {{decomposition declaration cannot be declared with constrained 'auto'}}
195d358b2deSVlad Serebrennikov   BinaryC<T> auto [c, d] = get_T<T>();
196d358b2deSVlad Serebrennikov   // since-cxx20-error@-1 {{decomposition declaration cannot be declared with constrained 'auto'}}
197d358b2deSVlad Serebrennikov }
198d358b2deSVlad Serebrennikov #endif
199463e61a0SVlad Serebrennikov } // namespace cwg2635
200d358b2deSVlad Serebrennikov 
201d358b2deSVlad Serebrennikov // cwg2636: na
202d358b2deSVlad Serebrennikov 
203d358b2deSVlad Serebrennikov namespace cwg2640 { // cwg2640: 16
204d358b2deSVlad Serebrennikov 
205d358b2deSVlad Serebrennikov int \N{Λ} = 0;
206d358b2deSVlad Serebrennikov // expected-error@-1 {{'Λ' is not a valid Unicode character name}}
207d358b2deSVlad Serebrennikov // expected-error@-2 {{expected unqualified-id}}
208d358b2deSVlad Serebrennikov const char* emoji = "\N{��}";
209d358b2deSVlad Serebrennikov // expected-error@-1 {{'��' is not a valid Unicode character name}}
210d358b2deSVlad Serebrennikov //   expected-note@-2 {{did you mean OX ('��' U+1F402)?}}
211d358b2deSVlad Serebrennikov //   expected-note@-3 {{did you mean ANT ('��' U+1F41C)?}}
212d358b2deSVlad Serebrennikov //   expected-note@-4 {{did you mean ARC ('⌒' U+2312)?}}
213d358b2deSVlad Serebrennikov //   expected-note@-5 {{did you mean AXE ('��' U+1FA93)?}}
214d358b2deSVlad Serebrennikov //   expected-note@-6 {{did you mean BAT ('��' U+1F987)?}}
215d358b2deSVlad Serebrennikov 
216d358b2deSVlad Serebrennikov #define z(x) 0
217d358b2deSVlad Serebrennikov #define cwg2640_a z(
218d358b2deSVlad Serebrennikov int x = cwg2640_a\N{abc});
219d358b2deSVlad Serebrennikov // expected-error@-1 {{'abc' is not a valid Unicode character name}}
220d358b2deSVlad Serebrennikov int y = cwg2640_a\N{LOTUS});
221d358b2deSVlad Serebrennikov // expected-error@-1 {{character <U+1FAB7> not allowed in an identifier}}
222d358b2deSVlad Serebrennikov // expected-error@-2 {{use of undeclared identifier 'cwg2640_a��'}}
223d358b2deSVlad Serebrennikov // expected-error@-3 {{extraneous ')' before ';'}}
224463e61a0SVlad Serebrennikov } // namespace cwg2640
225d358b2deSVlad Serebrennikov 
226d358b2deSVlad Serebrennikov // cwg2642: na
227d358b2deSVlad Serebrennikov 
228d358b2deSVlad Serebrennikov namespace cwg2644 { // cwg2644: 8
229d358b2deSVlad Serebrennikov #if __cplusplus >= 201103L
230d358b2deSVlad Serebrennikov auto z = [a = 42](int a) {
231a58dd0e9SVlad Serebrennikov // cxx11-error@-1 {{initialized lambda captures are a C++14 extension}}
232d358b2deSVlad Serebrennikov // since-cxx11-error@-2 {{a lambda parameter cannot shadow an explicitly captured entity}}
233d358b2deSVlad Serebrennikov //   since-cxx11-note@-3 {{variable 'a' is explicitly captured here}}
234d358b2deSVlad Serebrennikov      return 1;
235d358b2deSVlad Serebrennikov };
236d358b2deSVlad Serebrennikov #endif
237463e61a0SVlad Serebrennikov } // namespace cwg2644
238d358b2deSVlad Serebrennikov 
239d358b2deSVlad Serebrennikov namespace cwg2650 { // cwg2650: 17
240463e61a0SVlad Serebrennikov #if __cplusplus >= 202302L
241d358b2deSVlad Serebrennikov template <class T, T> struct S {};
242d358b2deSVlad Serebrennikov template <class T> int f(S<T, T{}>*); // #cwg2650-f
243d358b2deSVlad Serebrennikov class X {
244d358b2deSVlad Serebrennikov   int m;
245d358b2deSVlad Serebrennikov };
246d358b2deSVlad Serebrennikov int i0 = f<X>(0);
247d358b2deSVlad Serebrennikov // since-cxx23-error@-1 {{no matching function for call to 'f'}}
248d358b2deSVlad Serebrennikov //   since-cxx23-note@#cwg2650-f {{type 'X' of non-type template parameter is not a structural type}}
249d358b2deSVlad Serebrennikov #endif
250463e61a0SVlad Serebrennikov } // namespace cwg2650
251d358b2deSVlad Serebrennikov 
252d358b2deSVlad Serebrennikov namespace cwg2653 { // cwg2653: 18
253463e61a0SVlad Serebrennikov #if __cplusplus >= 202302L
254d358b2deSVlad Serebrennikov   struct Test { void f(this const auto& = Test{}); };
255d358b2deSVlad Serebrennikov   // since-cxx23-error@-1 {{the explicit object parameter cannot have a default argument}}
256d358b2deSVlad Serebrennikov   auto L = [](this const auto& = Test{}){};
257d358b2deSVlad Serebrennikov   // since-cxx23-error@-1 {{the explicit object parameter cannot have a default argument}}
258d358b2deSVlad Serebrennikov #endif
259463e61a0SVlad Serebrennikov } // namespace cwg2653
260d358b2deSVlad Serebrennikov 
261d358b2deSVlad Serebrennikov namespace cwg2654 { // cwg2654: 16
262d358b2deSVlad Serebrennikov void f() {
263d358b2deSVlad Serebrennikov     int neck, tail;
264d358b2deSVlad Serebrennikov     volatile int brachiosaur;
265d358b2deSVlad Serebrennikov     brachiosaur += neck;                // OK
266d358b2deSVlad Serebrennikov     brachiosaur -= neck;                // OK
267d358b2deSVlad Serebrennikov     brachiosaur |= neck;                // OK
268d358b2deSVlad Serebrennikov }
269463e61a0SVlad Serebrennikov } // namespace cwg2654
270d358b2deSVlad Serebrennikov 
271d358b2deSVlad Serebrennikov namespace cwg2681 { // cwg2681: 17
272d358b2deSVlad Serebrennikov #if __cplusplus >= 202002L
273d358b2deSVlad Serebrennikov using size_t = decltype(sizeof(int));
274d358b2deSVlad Serebrennikov 
275d358b2deSVlad Serebrennikov template<class T, size_t N>
276d358b2deSVlad Serebrennikov struct H {
277d358b2deSVlad Serebrennikov   T array[N];
278d358b2deSVlad Serebrennikov };
279d358b2deSVlad Serebrennikov template<class T, size_t N>
280d358b2deSVlad Serebrennikov struct I {
281d358b2deSVlad Serebrennikov   volatile T array[N];
282d358b2deSVlad Serebrennikov };
283d358b2deSVlad Serebrennikov template<size_t N>
284d358b2deSVlad Serebrennikov struct J { // #cwg2681-J
285d358b2deSVlad Serebrennikov   unsigned char array[N];
286d358b2deSVlad Serebrennikov };
287d358b2deSVlad Serebrennikov 
288d358b2deSVlad Serebrennikov H h = { "abc" };
289d358b2deSVlad Serebrennikov I i = { "def" };
290d358b2deSVlad Serebrennikov static_assert(__is_same(decltype(h), H<char, 4>));  // Not H<const char, 4>
291d358b2deSVlad Serebrennikov static_assert(__is_same(decltype(i), I<char, 4>));
292d358b2deSVlad Serebrennikov 
293d358b2deSVlad Serebrennikov J j = { "ghi" };
294d358b2deSVlad Serebrennikov // since-cxx20-error@-1 {{no viable constructor or deduction guide}}
295d358b2deSVlad Serebrennikov //   since-cxx20-note@#cwg2681-J {{candidate template ignored: could not match 'J<N>' against 'const char *'}}
2963b639d7dSYounan Zhang //   since-cxx20-note@#cwg2681-J {{implicit deduction guide declared as 'template <size_t N> J(J<N>) -> J<N>'}}
297d358b2deSVlad Serebrennikov //   since-cxx20-note@#cwg2681-J {{candidate template ignored: could not match 'const unsigned char' against 'const char'}}
2983b639d7dSYounan Zhang //   since-cxx20-note@#cwg2681-J {{implicit deduction guide declared as 'template <size_t N> J(const unsigned char (&)[N]) -> J<N>'}}
299d358b2deSVlad Serebrennikov //   since-cxx20-note@#cwg2681-J {{candidate function template not viable: requires 0 arguments, but 1 was provided}}
3003b639d7dSYounan Zhang //   since-cxx20-note@#cwg2681-J {{implicit deduction guide declared as 'template <size_t N> J() -> J<N>'}}
301d358b2deSVlad Serebrennikov #endif
302463e61a0SVlad Serebrennikov } // namespace cwg2681
303d358b2deSVlad Serebrennikov 
304d358b2deSVlad Serebrennikov namespace cwg2672 { // cwg2672: 18
305d358b2deSVlad Serebrennikov #if __cplusplus >= 202002L
306d358b2deSVlad Serebrennikov template <class T>
307d358b2deSVlad Serebrennikov void f(T) requires requires { []() { T::invalid; } (); };
308d358b2deSVlad Serebrennikov // since-cxx20-error@-1 {{type 'int' cannot be used prior to '::' because it has no members}}
309d358b2deSVlad Serebrennikov //   since-cxx20-note@-2 {{while substituting into a lambda expression here}}
310d358b2deSVlad Serebrennikov //   since-cxx20-note@-3 {{in instantiation of requirement here}}
311d358b2deSVlad Serebrennikov //   since-cxx20-note@-4 {{while substituting template arguments into constraint expression here}}
312d358b2deSVlad Serebrennikov //   since-cxx20-note@#cwg2672-f-0 {{while checking constraint satisfaction for template 'f<int>' required here}}
3133972ed57SYounan Zhang //   since-cxx20-note@#cwg2672-f-0 {{in instantiation of function template specialization 'cwg2672::f<int>' requested here}}
314d358b2deSVlad Serebrennikov void f(...);
315d358b2deSVlad Serebrennikov 
316d358b2deSVlad Serebrennikov template <class T>
317d358b2deSVlad Serebrennikov void bar(T) requires requires {
318d358b2deSVlad Serebrennikov    []() -> decltype(T::foo()) {};
319d358b2deSVlad Serebrennikov };
320d358b2deSVlad Serebrennikov void bar(...);
321d358b2deSVlad Serebrennikov 
322d358b2deSVlad Serebrennikov void m() {
323d358b2deSVlad Serebrennikov   f(0); // #cwg2672-f-0
324d358b2deSVlad Serebrennikov   bar(0);
325d358b2deSVlad Serebrennikov }
326d358b2deSVlad Serebrennikov #endif
327463e61a0SVlad Serebrennikov } // namespace cwg2672
328d358b2deSVlad Serebrennikov 
329d358b2deSVlad Serebrennikov namespace cwg2687 { // cwg2687: 18
330463e61a0SVlad Serebrennikov #if __cplusplus >= 202302L
331d358b2deSVlad Serebrennikov struct S{
332d358b2deSVlad Serebrennikov     void f(int);
333d358b2deSVlad Serebrennikov     static void g(int);
334d358b2deSVlad Serebrennikov     void h(this const S&, int);
335d358b2deSVlad Serebrennikov };
336d358b2deSVlad Serebrennikov 
337d358b2deSVlad Serebrennikov void test() {
338d358b2deSVlad Serebrennikov     (&S::f)(1);
339d358b2deSVlad Serebrennikov     // since-cxx23-error@-1 {{called object type 'void (cwg2687::S::*)(int)' is not a function or function pointer}}
340d358b2deSVlad Serebrennikov     (&S::g)(1);
341d358b2deSVlad Serebrennikov     (&S::h)(S(), 1);
342d358b2deSVlad Serebrennikov }
343d358b2deSVlad Serebrennikov #endif
344463e61a0SVlad Serebrennikov } // namespace cwg2687
345d0223b9fScor3ntin 
346d0223b9fScor3ntin namespace cwg2692 { // cwg2692: 19
347d0223b9fScor3ntin #if __cplusplus >= 202302L
348d0223b9fScor3ntin 
349d0223b9fScor3ntin  struct A {
350d0223b9fScor3ntin     static void f(A); // #cwg2692-1
351d0223b9fScor3ntin     void f(this A); // #cwg2692-2
352d0223b9fScor3ntin 
353d0223b9fScor3ntin     void g();
354d0223b9fScor3ntin   };
355d0223b9fScor3ntin 
356d0223b9fScor3ntin   void A::g() {
357d0223b9fScor3ntin     (&A::f)(A());
358eff12650SVlad Serebrennikov     // since-cxx23-error@-1 {{call to 'f' is ambiguous}}
359eff12650SVlad Serebrennikov     //   since-cxx23-note@#cwg2692-1 {{candidate function}}
360eff12650SVlad Serebrennikov     //   since-cxx23-note@#cwg2692-2 {{candidate function}}
361d0223b9fScor3ntin     (&A::f)();
362eff12650SVlad Serebrennikov     // since-cxx23-error@-1 {{no matching function for call to 'f'}}
363eff12650SVlad Serebrennikov     //   since-cxx23-note@#cwg2692-1 {{candidate function not viable: requires 1 argument, but 0 were provided}}
364eff12650SVlad Serebrennikov     //   since-cxx23-note@#cwg2692-2 {{candidate function not viable: requires 1 argument, but 0 were provided}}
365d0223b9fScor3ntin   }
366d0223b9fScor3ntin #endif
367463e61a0SVlad Serebrennikov } // namespace cwg2692
368