1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
|
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,cxx98-14,cxx11-17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx14,cxx98-14,cxx11-17,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx14,since-cxx17,cxx11-17,since-cxx11,since-cxx14,cxx17 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx14,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx14,since-cxx17,since-cxx20,since-cxx23,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx14,since-cxx17,since-cxx20,since-cxx23,since-cxx11,since-cxx14 -fexceptions -fcxx-exceptions -pedantic-errors
#if __cplusplus == 199711L
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
// cxx98-error@-1 {{variadic macros are a C99 feature}}
#endif
namespace cwg1800 { // cwg1800: 2.9
struct A { union { int n; }; };
static_assert(__is_same(__decltype(&A::n), int A::*), "");
} // namespace cwg1800
namespace cwg1801 { // cwg1801: 2.8
static union {
int i;
};
template <int &> struct S {}; // #cwg1801-S
S<i> V; // #cwg1801-S-i
// cxx98-14-error@-1 {{non-type template argument does not refer to any declaration}}
// cxx98-14-note@#cwg1801-S {{template parameter is declared here}}
// cxx17-error@#cwg1801-S-i {{non-type template argument refers to subobject '.i'}}
} // namespace cwg1801
namespace cwg1802 { // cwg1802: 3.1
#if __cplusplus >= 201103L
// Using a Wikipedia example of surrogate pair:
// https://en.wikipedia.org/wiki/UTF-16#Examples
constexpr char16_t a[3] = u"\U00010437";
static_assert(a[0] == 0xD801, "");
static_assert(a[1] == 0xDC37, "");
static_assert(a[2] == 0x0, "");
#endif
} // namespace cwg1802
namespace cwg1803 { // cwg1803: 2.9
#if __cplusplus >= 201103L
struct A {
enum E : int;
enum E : int {};
enum class EC;
enum class EC {};
enum struct ES;
enum struct ES {};
};
#endif
} // namespace cwg1803
namespace cwg1804 { // cwg1804: 2.7
template <typename, typename>
struct A {
void f1();
template <typename V>
void f2(V);
class B {
void f3();
};
template <typename>
class C {
void f4();
};
};
template <typename U>
struct A<int, U> {
void f1();
template <typename V>
void f2(V);
class B {
void f3();
};
template <typename>
class C {
void f4();
};
};
class D {
int i;
template <typename, typename>
friend struct A;
};
template <typename U>
struct A<double, U> {
void f1();
template <typename V>
void f2(V);
class B {
void f3();
};
template <typename>
class C {
void f4();
};
};
template <typename U>
void A<int, U>::f1() {
D d;
d.i = 0;
}
template <typename U>
void A<double, U>::f1() {
D d;
d.i = 0;
}
template <typename U>
template <typename V>
void A<int, U>::f2(V) {
D d;
d.i = 0;
}
template <typename U>
template <typename V>
void A<double, U>::f2(V) {
D d;
d.i = 0;
}
template <typename U>
void A<int, U>::B::f3() {
D d;
d.i = 0;
}
template <typename U>
void A<double, U>::B::f3() {
D d;
d.i = 0;
}
template <typename U>
template <typename V>
void A<int, U>::C<V>::f4() {
D d;
d.i = 0;
}
template <typename U>
template <typename V>
void A<double, U>::C<V>::f4() {
D d;
d.i = 0;
}
} // namespace cwg1804
// cwg1807 is in cwg1807.cpp
namespace cwg1812 { // cwg1812: no
// NB: dup 1710
#if __cplusplus >= 201103L
template <typename T> struct A {
using B = typename T::C<int>;
// since-cxx11-error@-1 {{use 'template' keyword to treat 'C' as a dependent template name}}
};
#endif
} // namespace cwg1812
namespace cwg1813 { // cwg1813: 7
struct B { int i; };
struct C : B {};
struct D : C {};
struct E : D { char : 4; };
static_assert(__is_standard_layout(B), "");
static_assert(__is_standard_layout(C), "");
static_assert(__is_standard_layout(D), "");
static_assert(!__is_standard_layout(E), "");
struct Q {};
struct S : Q {};
struct T : Q {};
struct U : S, T {};
static_assert(__is_standard_layout(Q), "");
static_assert(__is_standard_layout(S), "");
static_assert(__is_standard_layout(T), "");
static_assert(!__is_standard_layout(U), "");
}
namespace cwg1814 { // cwg1814: 3.1
#if __cplusplus >= 201103L
void test() {
auto lam = [](int x = 42) { return x; };
}
#endif
} // namespace cwg1814
namespace cwg1815 { // cwg1815: 20
#if __cplusplus >= 201402L
struct A { int &&r = 0; };
A a = {};
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}}
B b; // #cwg1815-b
#if __cplusplus >= 201703L
struct C { const int &r = 0; };
constexpr C c = {}; // OK, since cwg1815
static_assert(c.r == 0);
constexpr int f() {
A a = {}; // OK, since cwg1815
return a.r;
}
static_assert(f() == 0);
#endif
#endif
} // namespace cwg1815
// cwg1818 is in cwg1818.cpp
namespace cwg1820 { // cwg1820: 3.5
typedef int A;
typedef int cwg1820::A;
// expected-warning@-1 {{extra qualification on member 'A'}}
// expected-error@-2 {{typedef declarator cannot be qualified}}
namespace B {
typedef int cwg1820::A;
// expected-error@-1 {{cannot define or redeclare 'A' here because namespace 'B' does not enclose namespace 'cwg1820'}}
// expected-error@-2 {{typedef declarator cannot be qualified}}
}
class C1 {
typedef int cwg1820::A;
// expected-error@-1 {{non-friend class member 'A' cannot have a qualified name}}
// expected-error@-2 {{typedef declarator cannot be qualified}}
};
template <typename>
class C2 {
typedef int cwg1820::A;
// expected-error@-1 {{non-friend class member 'A' cannot have a qualified name}}
// expected-error@-2 {{typedef declarator cannot be qualified}}
};
void d1() {
typedef int cwg1820::A;
// expected-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
// expected-error@-2 {{typedef declarator cannot be qualified}}
}
template<typename>
void d2() {
typedef int cwg1820::A;
// expected-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
// expected-error@-2 {{typedef declarator cannot be qualified}}
}
#if __cplusplus >= 201103L
auto e = [] {
typedef int cwg1820::A;
// since-cxx11-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
// since-cxx11-error@-2 {{typedef declarator cannot be qualified}}
};
#endif
} // namespace cwg1820
namespace cwg1821 { // cwg1821: 2.9
struct A {
template <typename> struct B {
void f();
};
template <typename T> void B<T>::f(){};
// expected-error@-1 {{non-friend class member 'f' cannot have a qualified name}}
struct C {
void f();
};
void C::f() {}
// expected-error@-1 {{non-friend class member 'f' cannot have a qualified name}}
};
} // namespace cwg1821
namespace cwg1822 { // cwg1822: 3.1
#if __cplusplus >= 201103L
double a;
auto x = [] (int a) {
static_assert(__is_same(decltype(a), int), "should be resolved to lambda parameter");
};
#endif
} // namespace cwg1822
namespace cwg1824 { // cwg1824: 2.7
template<typename T>
struct A {
T t;
};
struct S {
A<S> f() { return A<S>(); }
};
} // namespace cwg1824
namespace cwg1832 { // cwg1832: 3.0
enum E { // #cwg1832-E
a = static_cast<int>(static_cast<E>(0))
// expected-error@-1 {{'E' is an incomplete type}}
// expected-note@#cwg1832-E {{definition of 'cwg1832::E' is not complete until the closing '}'}}
};
#if __cplusplus >= 201103L
enum E2: decltype(static_cast<E2>(0), 0) {};
// since-cxx11-error@-1 {{unknown type name 'E2'}}
enum class E3: decltype(static_cast<E3>(0), 0) {};
// since-cxx11-error@-1 {{unknown type name 'E3'}}
#endif
} // namespace cwg1832
namespace cwg1837 { // cwg1837: 3.3
#if __cplusplus >= 201103L
template <typename T>
struct Fish { static const bool value = true; };
struct Other {
int p();
auto q() -> decltype(p()) *;
};
class Outer {
friend auto Other::q() -> decltype(this->p()) *;
// since-cxx11-error@-1 {{invalid use of 'this' outside of a non-static member function}}
int g();
int f() {
extern void f(decltype(this->g()) *);
struct Inner {
static_assert(Fish<decltype(this->g())>::value, "");
// since-cxx11-error@-1 {{invalid use of 'this' outside of a non-static member function}}
enum { X = Fish<decltype(this->f())>::value };
// since-cxx11-error@-1 {{invalid use of 'this' outside of a non-static member function}}
struct Inner2 : Fish<decltype(this->g())> { };
// since-cxx11-error@-1 {{invalid use of 'this' outside of a non-static member function}}
friend void f(decltype(this->g()) *);
// since-cxx11-error@-1 {{invalid use of 'this' outside of a non-static member function}}
friend auto Other::q() -> decltype(this->p()) *;
// since-cxx11-error@-1 {{invalid use of 'this' outside of a non-static member function}}
};
return 0;
}
};
struct A {
int f();
bool b = [] {
// since-cxx11-warning@-1 {{address of lambda function pointer conversion operator will always evaluate to 'true'}}
struct Local {
static_assert(sizeof(this->f()) == sizeof(int), "");
};
};
};
#endif
} // namespace cwg1837
namespace cwg1862 { // cwg1862: no
template<class T>
struct A {
struct B {
void e();
};
void f();
struct D {
void g();
};
T h();
template<T U>
T i();
};
template<>
struct A<int> {
struct B {
void e();
};
int f();
struct D {
void g();
};
template<int U>
int i();
};
template<>
struct A<float*> {
int* h();
};
class C {
int private_int;
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 'C'}}
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 'C'}}
// FIXME: this is ill-formed, because A<T>::D does not end with a simple-template-id
template<class T>
friend void A<T>::D::g();
// expected-warning@-1 {{dependent nested name specifier 'A<T>::D' for friend class declaration is not supported; turning off access control for 'C'}}
template<class T>
friend int *A<T*>::h();
// expected-warning@-1 {{dependent nested name specifier 'A<T *>' for friend class declaration is not supported; turning off access control for 'C'}}
template<class T>
template<T U>
friend T A<T>::i();
// expected-warning@-1 {{dependent nested name specifier 'A<T>' for friend class declaration is not supported; turning off access control for 'C'}}
};
C c;
template<class T>
void A<T>::B::e() { (void)c.private_int; }
void A<int>::B::e() { (void)c.private_int; }
template<class T>
void A<T>::f() { (void)c.private_int; }
int A<int>::f() { (void)c.private_int; return 0; }
// FIXME: both definition of 'D::g' are not friends, so they don't have access to 'private_int'
template<class T>
void A<T>::D::g() { (void)c.private_int; }
void A<int>::D::g() { (void)c.private_int; }
template<class T>
T A<T>::h() { (void)c.private_int; }
int* A<float*>::h() { (void)c.private_int; return 0; }
template<class T>
template<T U>
T A<T>::i() { (void)c.private_int; }
template<int U>
int A<int>::i() { (void)c.private_int; }
} // namespace cwg1862
namespace cwg1872 { // cwg1872: 9
#if __cplusplus >= 201103L
template<typename T> struct A : T {
constexpr int f() const { return 0; }
};
struct X {};
struct Y { virtual int f() const; };
struct Z : virtual X {};
constexpr int x = A<X>().f();
constexpr int y = A<Y>().f();
// cxx11-17-error@-1 {{constexpr variable 'y' must be initialized by a constant expression}}
// cxx11-17-note@-2 {{cannot evaluate call to virtual function in a constant expression in C++ standards before C++20}}
#if __cplusplus >= 202002L
static_assert(y == 0);
#endif
// Note, this is invalid even though it would not use virtual dispatch.
constexpr int y2 = A<Y>().A<Y>::f();
// cxx11-17-error@-1 {{constexpr variable 'y2' must be initialized by a constant expression}}
// cxx11-17-note@-2 {{cannot evaluate call to virtual function in a constant expression in C++ standards before C++20}}
#if __cplusplus >= 202002L
static_assert(y2 == 0);
#endif
constexpr int z = A<Z>().f();
// since-cxx11-error@-1 {{constexpr variable 'z' must be initialized by a constant expression}}
// cxx11-20-note@-2 {{non-literal type 'A<Z>' cannot be used in a constant expression}}
// since-cxx23-note@-3 {{cannot construct object of type 'A<cwg1872::Z>' with virtual base class in a constant expression}}
#endif
} // namespace cwg1872
namespace cwg1878 { // cwg1878: 18
#if __cplusplus >= 201402L
#if __cplusplus >= 202002L
template <typename T>
concept C = true;
#endif
struct S {
template <typename T>
operator auto() const { return short(); }
// since-cxx14-error@-1 {{'auto' not allowed in declaration of conversion function template}}
template <typename T>
operator const auto() const { return int(); }
// since-cxx14-error@-1 {{'auto' not allowed in declaration of conversion function template}}
template <typename T>
operator const auto&() const { return char(); }
// since-cxx14-error@-1 {{'auto' not allowed in declaration of conversion function template}}
template <typename T>
operator const auto*() const { return long(); }
// since-cxx14-error@-1 {{'auto' not allowed in declaration of conversion function template}}
template <typename T>
operator decltype(auto)() const { return unsigned(); }
// since-cxx14-error@-1 {{'decltype(auto)' not allowed in declaration of conversion function template}}
#if __cplusplus >= 202002L
template <typename T>
operator C auto() const { return float(); }
// since-cxx20-error@-1 {{'auto' not allowed in declaration of conversion function template}}
template <typename T>
operator C decltype(auto)() const { return double(); }
// since-cxx20-error@-1 {{'decltype(auto)' not allowed in declaration of conversion function template}}
#endif
};
#endif
} // namespace cwg1878
namespace cwg1881 { // cwg1881: 7
struct A { int a : 4; };
struct B : A { int b : 3; };
static_assert(__is_standard_layout(A), "");
static_assert(!__is_standard_layout(B), "");
struct C { int : 0; };
struct D : C { int : 0; };
static_assert(__is_standard_layout(C), "");
static_assert(!__is_standard_layout(D), "");
} // namespace cwg1881
// cwg1884 is in cwg1884.cpp
namespace cwg1890 { // cwg1890: no drafting 2018-06-04
// FIXME: current consensus for CWG2335 is that the examples are well-formed.
namespace ex1 {
#if __cplusplus >= 201402L
struct A {
struct B {
auto foo() { return 0; } // #cwg1890-foo
};
decltype(B().foo()) x;
// since-cxx14-error@-1 {{function 'foo' with deduced return type cannot be used before it is defined}}
// since-cxx14-note@#cwg1890-foo {{'foo' declared here}}
};
#endif
} // namespace ex1
namespace ex2 {
#if __cplusplus >= 201103L
struct Bar {
struct Baz { // #cwg1890-Baz
int a = 0;
};
static_assert(__is_constructible(Baz), "");
// since-cxx11-error@-1 {{static assertion failed due to requirement '__is_constructible(cwg1890::ex2::Bar::Baz)'}}
// since-cxx11-note@#cwg1890-Baz {{'Baz' defined here}}
};
#endif
} // namespace ex2
} // namespace cwg1890
void cwg1891() { // cwg1891: 4
#if __cplusplus >= 201103L
int n;
auto a = []{}; // #cwg1891-a
auto b = [=]{ return n; }; // #cwg1891-b
typedef decltype(a) A;
typedef decltype(b) B;
static_assert(!__is_trivially_constructible(A), "");
// since-cxx20-error@-1 {{failed}}
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-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-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}}
// C++20 allows assignment for non-capturing lambdas (P0624R2).
a = a;
// cxx11-17-error-re@-1 {{{{object of type '\(lambda at .+\)' cannot be assigned because its copy assignment operator is implicitly deleted}}}}
// cxx11-17-note@#cwg1891-a {{lambda expression begins here}}
a = static_cast<A&&>(a);
// cxx11-17-error-re@-1 {{{{object of type '\(lambda at .+\)' cannot be assigned because its copy assignment operator is implicitly deleted}}}}
// cxx11-17-note@#cwg1891-a {{lambda expression begins here}}
b = b;
// since-cxx11-error-re@-1 {{{{object of type '\(lambda at .+\)' cannot be assigned because its copy assignment operator is implicitly deleted}}}}
// since-cxx11-note@#cwg1891-b {{lambda expression begins here}}
b = static_cast<B&&>(b);
// since-cxx11-error-re@-1 {{{{object of type '\(lambda at .+\)' cannot be assigned because its copy assignment operator is implicitly deleted}}}}
// since-cxx11-note@#cwg1891-b {{lambda expression begins here}}
#endif
} // void cwg1891()
namespace cwg1894 { // cwg1894: 3.8
// NB: reusing part of cwg407 test
namespace A {
struct S {};
}
namespace B {
typedef int S;
}
namespace E {
typedef A::S S;
using A::S;
struct S s;
}
namespace F {
typedef A::S S;
}
namespace G {
using namespace A;
using namespace F;
struct S s;
}
namespace H {
using namespace F;
using namespace A;
struct S s;
}
} // namespace cwg1894
namespace cwg1898 { // cwg1898: 2.7
void e(int) {} // #cwg1898-e
void e(int) {}
// expected-error@-1 {{redefinition of 'e'}}
// expected-note@#cwg1898-e {{previous definition is here}}
void e2(int) {}
void e2(long) {} // OK, different type
void f(int) {} // #cwg1898-f
void f(const int) {}
// expected-error@-1 {{redefinition of 'f'}}
// expected-note@#cwg1898-f {{previous definition is here}}
void g(int) {} // #cwg1898-g
void g(volatile int) {}
// since-cxx20-warning@-1 {{volatile-qualified parameter type 'volatile int' is deprecated}}
// expected-error@-2 {{redefinition of 'g'}}
// expected-note@#cwg1898-g {{previous definition is here}}
void h(int *) {} // #cwg1898-h
void h(int[]) {}
// expected-error@-1 {{redefinition of 'h'}}
// expected-note@#cwg1898-h {{previous definition is here}}
void h2(int *) {} // #cwg1898-h2
void h2(int[2]) {}
// expected-error@-1 {{redefinition of 'h2'}}
// expected-note@#cwg1898-h2 {{previous definition is here}}
void h3(int (*)[2]) {} // #cwg1898-h3
void h3(int [3][2]) {}
// expected-error@-1 {{redefinition of 'h3'}}
// expected-note@#cwg1898-h3 {{previous definition is here}}
void h4(int (*)[2]) {}
void h4(int [3][3]) {} // OK, differ in non-top-level extent of array
void i(int *) {}
void i(const int *) {} // OK, pointee cv-qualification is not discarded
void i2(int *) {} // #cwg1898-i2
void i2(int * const) {}
// expected-error@-1 {{redefinition of 'i2'}}
// expected-note@#cwg1898-i2 {{previous definition is here}}
void j(void(*)()) {} // #cwg1898-j
void j(void()) {}
// expected-error@-1 {{redefinition of 'j'}}
// expected-note@#cwg1898-j {{previous definition is here}}
void j2(void(int)) {} // #cwg1898-j2
void j2(void(const int)) {}
// expected-error@-1 {{redefinition of 'j2'}}
// expected-note@#cwg1898-j2 {{previous definition is here}}
struct A {
void k(int) {} // #cwg1898-k
void k(int) {}
// expected-error@-1 {{class member cannot be redeclared}}
// expected-note@#cwg1898-k {{previous definition is here}}
};
struct B : A {
void k(int) {} // OK, shadows A::k
};
void l() {}
void l(...) {}
#if __cplusplus >= 201103L
template <typename T>
void m(T) {}
template <typename... Ts>
void m(Ts...) {}
template <typename T, typename U>
void m2(T, U) {}
template <typename... Ts, typename U>
void m2(Ts..., U) {}
#endif
} // namespace cwg1898
|