1 // RUN: %clang_cc1 -std=c++98 %s -verify=expected,cxx98,cxx98-14 -fexceptions -fcxx-exceptions -pedantic-errors -Wno-bind-to-temporary-copy
2 // RUN: %clang_cc1 -std=c++11 %s -verify=expected,since-cxx11,cxx98-14,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
3 // RUN: %clang_cc1 -std=c++14 %s -verify=expected,since-cxx11,cxx98-14,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
4 // RUN: %clang_cc1 -std=c++17 %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
5 // RUN: %clang_cc1 -std=c++20 %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
6 // RUN: %clang_cc1 -std=c++23 %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
7 // RUN: %clang_cc1 -std=c++2c %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
9 #if __cplusplus == 199711L
10 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
11 // cxx98-error@-1 {{variadic macros are a C99 feature}}
14 namespace cwg1
{ // cwg1: no
15 namespace X
{ extern "C" void cwg1_f(int a
= 1); }
16 namespace Y
{ extern "C" void cwg1_f(int a
= 1); }
17 using X::cwg1_f
; using Y::cwg1_f
;
20 // FIXME: This should be rejected, due to the ambiguous default argument.
27 // FIXME: This should be rejected, due to the ambiguous default argument.
35 void X::z(int = 1) {} // #cwg1-z
38 // expected-error@-1 {{redefinition of default argument}}
39 // expected-note@#cwg1-z {{previous definition is here}}
47 // FIXME: This should be rejected, due to the ambiguous default argument.
54 // FIXME: This should be rejected, due to the ambiguous default argument.
59 namespace cwg3
{ // cwg3: yes
60 template<typename T
> struct A
{};
61 template<typename T
> void f(T
) { A
<T
> a
; } // #cwg3-f-T
63 template<> struct A
<int> {};
64 // expected-error@-1 {{explicit specialization of 'cwg3::A<int>' after instantiation}}
65 // expected-note@#cwg3-f-T {{implicit instantiation first required here}}
68 namespace cwg4
{ // cwg4: 2.8
70 static void cwg4_f(int) {}
71 static void cwg4_f(float) {}
72 void cwg4_g(int) {} // #cwg4-g-int
74 // expected-error@-1 {{conflicting types for 'cwg4_g'}}
75 // expected-note@#cwg4-g-int {{previous definition is here}}
79 namespace cwg5
{ // cwg5: 3.1
85 const volatile B b
= a
;
89 struct E
{ operator D
&(); } e
;
93 namespace cwg7
{ // cwg7: 3.4
94 class A
{ public: ~A(); };
95 class B
: virtual private A
{}; // #cwg7-B
96 class C
: public B
{} c
; // #cwg7-C
97 // expected-error@#cwg7-C {{inherited virtual base class 'A' has private destructor}}
98 // expected-note@#cwg7-C {{in implicit default constructor for 'cwg7::C' first required here}}
99 // expected-note@#cwg7-B {{declared private here}}
100 // expected-error@#cwg7-C {{inherited virtual base class 'A' has private destructor}}
101 // expected-note@#cwg7-C {{in implicit destructor for 'cwg7::C' first required here}}
102 // expected-note@#cwg7-B {{declared private here}}
103 class VeryDerivedC
: public B
, virtual public A
{} vdc
;
105 class X
{ ~X(); }; // #cwg7-X
106 class Y
: X
{ ~Y() {} };
107 // expected-error@-1 {{base class 'X' has private destructor}}
108 // expected-note@#cwg7-X {{implicitly declared private here}}
110 namespace PR16370
{ // This regressed the first time CWG7 was fixed.
111 struct S1
{ virtual ~S1(); };
114 struct S4
: virtual S2
{};
123 namespace cwg8
{ // cwg8: dup 45
126 static const int k
= 5;
128 template<typename
, int, void (A::*)()> struct T
;
132 A::T
<A::U
, A::k
, &A::f
> *A::g() { return 0; }
135 namespace cwg9
{ // cwg9: 2.8
141 struct N
: protected B
{ // #cwg9-N
144 int R1() { return n
.m
; }
145 // expected-error@-1 {{'m' is a protected member of 'cwg9::B'}}
146 // expected-note@#cwg9-N {{constrained by protected inheritance here}}
147 // expected-note@#cwg9-m {{member is declared here}}
148 int R2() { return n
.m
; }
151 namespace cwg10
{ // cwg10: dup 45
159 namespace cwg11
{ // cwg11: yes
160 template<typename T
> struct A
: T
{
164 template<typename T
> struct B
: T
{
167 // expected-error@-1 {{unknown type name 'V'}}
169 struct X
{ typedef int U
; };
173 namespace cwg12
{ // cwg12: sup 239
178 // Under CWG12, these call two different functions.
179 // Under CWG239, they call the same function.
185 namespace cwg13
{ // cwg13: no
186 extern "C" void f(int);
189 template<typename T
> struct A
{
192 template<typename T
> int h(void (T
));
194 A
<int> a1(f
); // FIXME: We should reject this.
196 int a3
= h(f
); // FIXME: We should reject this.
200 namespace cwg14
{ // cwg14: 3.4
201 namespace X
{ extern "C" int cwg14_f(); }
202 namespace Y
{ extern "C" int cwg14_f(); }
209 friend int Y::cwg14_f();
212 extern "C" int cwg14_f() { return c
.k
; }
215 namespace X
{ typedef int T
; typedef int U
; } // #cwg14-X-U
216 namespace Y
{ typedef int T
; typedef long U
; } // #cwg14-Y-U
217 T t
; // ok, same type both times
219 // expected-error@-1 {{reference to 'U' is ambiguous}}
220 // expected-note@#cwg14-X-U {{candidate found by name lookup is 'cwg14::X::U'}}
221 // expected-note@#cwg14-Y-U {{candidate found by name lookup is 'cwg14::Y::U'}}
224 namespace cwg15
{ // cwg15: yes
225 template<typename T
> void f(int); // #cwg15-f-decl-first
226 template<typename T
> void f(int = 0);
227 // expected-error@-1 {{default arguments cannot be added to a function template that has already been declared}}
228 // expected-note@#cwg15-f-decl-first {{previous template declaration is here}}
231 namespace cwg16
{ // cwg16: 2.8
232 class A
{ // #cwg16-A
233 void f(); // #cwg16-A-f-decl
236 class B
: A
{}; // #cwg16-B
240 // expected-error@-1 {{'f' is a private member of 'cwg16::A'}}
241 // expected-note@#cwg16-B {{constrained by implicitly private inheritance here}}
242 // expected-note@#cwg16-A-f-decl {{member is declared here}}
243 A::f(); // #cwg16-A-f-call
244 // expected-error@#cwg16-A-f-call {{'A' is a private member of 'cwg16::A'}}
245 // expected-note@#cwg16-B {{constrained by implicitly private inheritance here}}
246 // expected-note@#cwg16-A {{member is declared here}}
247 // expected-error@#cwg16-A-f-call {{cannot cast 'cwg16::C' to its private base class 'cwg16::A'}}
248 // expected-note@#cwg16-B {{implicitly declared private here}}
253 namespace cwg17
{ // cwg17: yes
260 int A::f() { return b
.n
; }
262 int g() { return n
; }
268 namespace cwg19
{ // cwg19: 3.1
272 struct B
: protected A
{ // #cwg19-B
276 int get1() { return c
.n
; }
277 // expected-error@-1 {{'n' is a protected member of 'cwg19::A'}}
278 // expected-note@#cwg19-B {{constrained by protected inheritance here}}
279 // expected-note@#cwg19-n {{member is declared here}}
280 int get2() { return ((A
&)c
).n
; } // ok, A is an accessible base of B from here
284 namespace cwg20
{ // cwg20: 2.8
289 X(const X
&); // #cwg20-X-ctor
293 // expected-error@-1 {{calling a private constructor of class 'cwg20::X'}}
294 // expected-note@#cwg20-X-ctor {{declared private here}}
297 namespace cwg21
{ // cwg21: 3.4
298 template<typename T
> struct A
;
300 template<typename T
= int> friend struct A
;
301 // expected-error@-1 {{default template argument not permitted on a friend template}}
302 template<typename T
= int> friend struct B
;
303 // expected-error@-1 {{default template argument not permitted on a friend template}}
307 namespace cwg22
{ // cwg22: sup 481
308 template<typename cwg22_T
= cwg22_T
> struct X
;
309 // expected-error@-1 {{unknown type name 'cwg22_T'}}
311 template<typename T
= T
> struct Y
;
314 namespace cwg23
{ // cwg23: yes
315 template<typename T
> void f(T
, T
); // #cwg23-f-T-T
316 template<typename T
> void f(T
, int); // #cwg23-f-T-int
317 void g() { f(0, 0); }
318 // expected-error@-1 {{call to 'f' is ambiguous}}
319 // expected-note@#cwg23-f-T-T {{candidate function [with T = int]}}
320 // expected-note@#cwg23-f-T-int {{candidate function [with T = int]}}
325 namespace cwg25
{ // cwg25: yes
328 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
329 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
331 void (A::*f
)() throw (int);
332 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
333 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
334 void (A::*g
)() throw () = f
;
335 // cxx98-14-error@-1 {{target exception specification is not superset of source}}
336 // since-cxx17-error@-2 {{different exception specifications}}
337 void (A::*g2
)() throw () = 0;
338 void (A::*h
)() throw (int, char) = f
;
339 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
340 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
341 void (A::*i
)() throw () = &A::f
;
342 // cxx98-14-error@-1 {{target exception specification is not superset of source}}
343 // since-cxx17-error@-2 {{different exception specifications}}
344 void (A::*i2
)() throw () = 0;
345 void (A::*j
)() throw (int, char) = &A::f
;
346 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
347 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
350 // cxx98-14-error@-1 {{target exception specification is not superset of source}}
351 // since-cxx17-error@-2 {{different exception specifications}}
354 // cxx98-14-error@-1 {{target exception specification is not superset of source}}
355 // since-cxx17-error@-2 {{different exception specifications}}
360 namespace cwg26
{ // cwg26: yes
361 struct A
{ A(A
, const A
& = A()); };
362 // expected-error@-1 {{copy constructor must pass its first argument by reference}}
365 // FIXME: In C++98, we diagnose this twice.
366 B(const B
&, B
= B());
367 // cxx98-14-error@-1 {{recursive evaluation of default argument}}
368 // cxx98-14-note@-2 {{default argument used here}}
369 // cxx98-error@-3 {{recursive evaluation of default argument}}
370 // cxx98-note@-4 {{default argument used here}}
374 C(const C
&, C
= f());
375 // expected-error@-1 {{recursive evaluation of default argument}}
376 // expected-note@-2 {{default argument used here}}
380 namespace cwg27
{ // cwg27: yes
387 namespace cwg29
{ // cwg29: 3.4
388 void cwg29_f0(); // #cwg29-f0
389 void g0() { void cwg29_f0(); }
390 extern "C++" void g0_cxx() { void cwg29_f0(); }
391 extern "C" void g0_c() { void cwg29_f0(); }
392 // expected-error@-1 {{declaration of 'cwg29_f0' has a different language linkage}}
393 // expected-note@#cwg29-f0 {{previous declaration is here}}
395 extern "C" void cwg29_f1(); // #cwg29-f1
396 void g1() { void cwg29_f1(); }
397 extern "C" void g1_c() { void cwg29_f1(); }
398 extern "C++" void g1_cxx() { void cwg29_f1(); }
399 // expected-error@-1 {{declaration of 'cwg29_f1' has a different language linkage}}
400 // expected-note@#cwg29-f1 {{previous declaration is here}}
402 void g2() { void cwg29_f2(); } // #cwg29-f2
403 extern "C" void cwg29_f2();
404 // expected-error@-1 {{declaration of 'cwg29_f2' has a different language linkage}}
405 // expected-note@#cwg29-f2 {{previous declaration is here}}
407 extern "C" void g3() { void cwg29_f3(); } // #cwg29-f3
408 extern "C++" void cwg29_f3();
409 // expected-error@-1 {{declaration of 'cwg29_f3' has a different language linkage}}
410 // expected-note@#cwg29-f3 {{previous declaration is here}}
412 extern "C++" void g4() { void cwg29_f4(); } // #cwg29-f4
413 extern "C" void cwg29_f4();
414 // expected-error@-1 {{declaration of 'cwg29_f4' has a different language linkage}}
415 // expected-note@#cwg29-f4 {{previous declaration is here}}
417 extern "C" void g5();
418 extern "C++" void cwg29_f5();
420 void cwg29_f5(); // ok, g5 is extern "C" but we're not inside the linkage-specification here.
423 extern "C++" void g6();
424 extern "C" void cwg29_f6();
426 void cwg29_f6(); // ok, g6 is extern "C" but we're not inside the linkage-specification here.
429 extern "C" void g7();
430 extern "C++" void cwg29_f7(); // #cwg29-f7
431 extern "C" void g7() {
433 // expected-error@-1 {{declaration of 'cwg29_f7' has a different language linkage}}
434 // expected-note@#cwg29-f7 {{previous declaration is here}}
437 extern "C++" void g8();
438 extern "C" void cwg29_f8(); // #cwg29-f8
439 extern "C++" void g8() {
441 // expected-error@-1 {{declaration of 'cwg29_f8' has a different language linkage}}
442 // expected-note@#cwg29-f8 {{previous declaration is here}}
446 namespace cwg30
{ // cwg30: sup 468 c++11
448 template<int> static int f();
450 // FIXME: It's not clear whether CWG468 applies to C++98 too.
451 int x
= A::template f
<0>();
452 // cxx98-error@-1 {{'template' keyword outside of a template}}
453 int y
= a
.template f
<0>();
454 // cxx98-error@-1 {{'template' keyword outside of a template}}
455 int z
= p
->template f
<0>();
456 // cxx98-error@-1 {{'template' keyword outside of a template}}
459 namespace cwg31
{ // cwg31: 2.8
462 void operator delete(void*); // #cwg31-delete
464 // We would call X::operator delete if X() threw (even though it can't,
465 // and even though we allocated the X using ::operator delete).
467 // expected-error@-1 {{'operator delete' is a private member of 'cwg31::X'}}
468 // expected-note@#cwg31-delete {{declared private here}}
473 namespace cwg33
{ // cwg33: 9
474 namespace X
{ struct S
; void f(void (*)(S
)); } // #cwg33-f-S
475 namespace Y
{ struct T
; void f(void (*)(T
)); } // #cwg33-f-T
477 template<typename Z
> Z
g(Y::T
);
479 // expected-error@-1 {{call to 'f' is ambiguous}}
480 // expected-note@#cwg33-f-S {{candidate function}}
481 // expected-note@#cwg33-f-T {{candidate function}}
483 template<typename T
> void t(X::S
);
484 template<typename T
, typename U
= void> void u(X::S
);
485 // expected-error@-1 0-1 {{default template arguments for a function template are a C++11 extension}}
486 void templ() { f(t
<int>); f(u
<int>); }
488 // Even though v<int> cannot select the first overload, ADL considers it
489 // and adds namespace Z to the set of associated namespaces, and then picks
490 // Z::f even though that function has nothing to do with any associated type.
491 namespace Z
{ struct Q
; void f(void(*)()); }
492 template<int> Z::Q
v();
493 template<typename
> void v();
494 void unrelated_templ() { f(v
<int>); }
496 namespace dependent
{
498 template<class T
> struct Y
{
499 friend int operator+(X
, void(*)(Y
)) {}
502 template<typename T
> void f(Y
<T
>);
503 int use
= X() + f
<int>;
504 // expected-error@-1 {{invalid operands to binary expression ('X' and 'void (Y<int>)')}}
509 struct Y
{ friend int operator+(Q
, Y (*)()); };
510 struct X
{ template<typename
> static Y
f(); };
511 int m
= Q() + X().f
<int>; // ok
512 int n
= Q() + (&(X().f
<int>)); // ok
519 namespace cwg36
{ // cwg36: 2.8
547 struct D
: virtual B
, virtual C
549 using B::i
; // #cwg36-ex2-B-i-first
551 // expected-error@-1 {{redeclaration of using declaration}}
552 // expected-note@#cwg36-ex2-B-i-first {{previous using declaration}}
554 using C::i
; // #cwg36-ex2-C-i-first
556 // expected-error@-1 {{redeclaration of using declaration}}
557 // expected-note@#cwg36-ex2-C-i-first {{previous using declaration}}
559 using B::j
; // #cwg36-ex2-B-j-first
561 // expected-error@-1 {{redeclaration of using declaration}}
562 // expected-note@#cwg36-ex2-B-j-first {{previous using declaration}}
564 using C::j
; // #cwg36-ex2-C-j-first
566 // expected-error@-1 {{redeclaration of using declaration}}
567 // expected-note@#cwg36-ex2-C-j-first {{previous using declaration}}
585 struct D
: virtual B
<T
>, virtual C
<T
>
587 using B
<T
>::i
; // #cwg36-ex3-B-i-first
589 // expected-error@-1 {{redeclaration of using declaration}}
590 // expected-note@#cwg36-ex3-B-i-first {{previous using declaration}}
592 using C
<T
>::i
; // #cwg36-ex3-C-i-first
594 // expected-error@-1 {{redeclaration of using declaration}}
595 // expected-note@#cwg36-ex3-C-i-first {{previous using declaration}}
597 using B
<T
>::j
; // #cwg36-ex3-B-j-first
599 // expected-error@-1 {{redeclaration of using declaration}}
600 // expected-note@#cwg36-ex3-B-j-first {{previous using declaration}}
602 using C
<T
>::j
; // #cwg36-ex3-C-j-first
604 // expected-error@-1 {{redeclaration of using declaration}}
605 // expected-note@#cwg36-ex3-C-j-first {{previous using declaration}}
616 using E
<T
>::k
; // #cwg36-E-k-first
618 // expected-error@-1 {{redeclaration of using declaration}}
619 // expected-note@#cwg36-E-k-first {{previous using declaration}}
626 namespace cwg38
{ // cwg38: yes
627 template<typename T
> struct X
{};
628 template<typename T
> X
<T
> operator+(X
<T
> a
, X
<T
> b
) { return a
; }
629 template X
<int> operator+<int>(X
<int>, X
<int>);
632 namespace cwg39
{ // cwg39: no
634 struct A
{ int &f(int); };
644 int &x(int); // #cwg39-A-x-decl
645 static int &y(int); // #cwg39-A-y-decl
650 struct B
: A
, virtual V
{
651 using A::x
; // #cwg39-using-A-x
653 using A::y
; // #cwg39-using-A-y
654 static float &y(float);
658 struct C
: A
, B
, virtual V
{} c
;
659 /* expected-warning@-1
660 {{direct base 'A' is inaccessible due to ambiguity:
661 struct cwg39::example2::C -> A
662 struct cwg39::example2::C -> B -> A}} */
664 // expected-error@-1 {{member 'x' found in multiple base classes of different types}}
665 // expected-note@#cwg39-A-x-decl {{member found by ambiguous name lookup}}
666 // expected-note@#cwg39-using-A-x {{member found by ambiguous name lookup}}
668 // FIXME: This is valid, because we find the same static data member either way.
670 // expected-error@-1 {{member 'y' found in multiple base classes of different types}}
671 // expected-note@#cwg39-A-y-decl {{member found by ambiguous name lookup}}
672 // expected-note@#cwg39-using-A-y {{member found by ambiguous name lookup}}
677 struct A
{ static int f(); };
678 struct B
: virtual A
{ using A::f
; };
679 struct C
: virtual A
{ using A::f
; };
680 struct D
: B
, C
{} d
;
685 struct A
{ int n
; }; // #cwg39-ex4-A-n
688 struct D
: B
, C
{ int f() { return n
; } };
690 {{non-static member 'n' found in multiple base-class subobjects of type 'A':
691 struct cwg39::example4::D -> B -> A
692 struct cwg39::example4::D -> C -> A}} */
693 // expected-note@#cwg39-ex4-A-n {{member found by ambiguous name lookup}}
697 // FIXME: This is valid.
698 struct A
{ int n
; }; // #cwg39-A-n
702 int k
= sizeof(D::n
); // #cwg39-sizeof
703 /* expected-error@#cwg39-sizeof
704 {{non-static member 'n' found in multiple base-class subobjects of type 'A':
705 struct cwg39::PR5916::D -> B -> A
706 struct cwg39::PR5916::D -> C -> A}} */
707 // expected-note@#cwg39-A-n {{member found by ambiguous name lookup}}
709 // expected-error@#cwg39-sizeof {{unknown type name}}
710 #if __cplusplus >= 201103L
713 {{non-static member 'n' found in multiple base-class subobjects of type 'A':
714 struct cwg39::PR5916::D -> B -> A
715 struct cwg39::PR5916::D -> C -> A}} */
716 // expected-note@#cwg39-A-n {{member found by ambiguous name lookup}}
723 namespace cwg41
{ // cwg41: yes
727 namespace cwg42
{ // cwg42: yes
728 struct A
{ static const int k
= 0; };
729 struct B
: A
{ static const int k
= A::k
; };
734 namespace cwg44
{ // cwg44: sup 727
736 template<int> void f();
737 template<> void f
<0>();
741 namespace cwg45
{ // cwg45: yes
749 namespace cwg46
{ // cwg46: yes
750 template<typename
> struct A
{ template<typename
> struct B
{}; };
751 template template struct A
<int>::B
<int>;
752 // expected-error@-1 {{expected unqualified-id}}
755 namespace cwg47
{ // cwg47: sup 329
756 template<typename T
> struct A
{
757 friend void f() { T t
; } // #cwg47-f
758 // expected-error@-1 {{redefinition of 'f'}}
759 // expected-note@#cwg47-b {{in instantiation of template class 'cwg47::A<float>' requested here}}
760 // expected-note@#cwg47-f {{previous definition is here}}
763 A
<float> b
; // #cwg47-b
769 namespace cwg48
{ // cwg48: yes
772 static const int m
= 0;
773 static const int n
= 0;
774 static const int o
= 0;
778 // FIXME: We should produce a 'has internal linkage but is not defined'
779 // diagnostic for 'S::n'.
785 namespace cwg49
{ // cwg49: 2.8
786 template<int*> struct A
{}; // #cwg49-A
788 #if __has_feature(cxx_constexpr)
791 int *const p
= &k
; // #cwg49-p
794 // cxx98-error@#cwg49-b {{non-type template argument referring to object 'p' with internal linkage is a C++11 extension}}
795 // cxx98-note@#cwg49-p {{non-type template argument refers to object here}}
796 // cxx98-14-error@#cwg49-b {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}}
797 // cxx98-14-note@#cwg49-A {{template parameter is declared here}}
798 int *q
= &k
; // #cwg49-q
800 // cxx98-error@#cwg49-c {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}}
801 // cxx98-note@#cwg49-A {{template parameter is declared here}}
802 // cxx11-14-error@#cwg49-c {{non-type template argument of type 'int *' is not a constant expression}}
803 // cxx11-14-note@#cwg49-c {{read of non-constexpr variable 'q' is not allowed in a constant expression}}
804 // cxx11-14-note@#cwg49-q {{declared here}}
805 // cxx11-14-note@#cwg49-A {{template parameter is declared here}}
806 // since-cxx17-error@#cwg49-c {{non-type template argument is not a constant expression}}
807 // since-cxx17-note@#cwg49-c {{read of non-constexpr variable 'q' is not allowed in a constant expression}}
808 // since-cxx17-note@#cwg49-q {{declared here}}
811 namespace cwg50
{ // cwg50: yes
812 struct X
; // #cwg50-X
815 X
*r
= static_cast<X
*>(p
);
816 X
*s
= const_cast<X
*>(p
);
817 X
*t
= reinterpret_cast<X
*>(p
);
818 X
*u
= dynamic_cast<X
*>(p
);
819 // expected-error@-1 {{'cwg50::X' is an incomplete type}}
820 // expected-note@#cwg50-X {{forward declaration of 'cwg50::X'}}
823 namespace cwg51
{ // cwg51: 2.8
833 namespace cwg52
{ // cwg52: 2.8
834 struct A
{ int n
; }; // #cwg52-A
835 struct B
: private A
{} b
; // #cwg52-B
836 int k
= b
.A::n
; // #cwg52-k
837 // FIXME: This first diagnostic is very strangely worded, and seems to be bogus.
838 // expected-error@#cwg52-k {{'A' is a private member of 'cwg52::A'}}
839 // expected-note@#cwg52-B {{constrained by private inheritance here}}
840 // expected-note@#cwg52-A {{member is declared here}}
841 // expected-error@#cwg52-k {{cannot cast 'struct B' to its private base class 'cwg52::A'}}
842 // expected-note@#cwg52-B {{declared private here}}
845 namespace cwg53
{ // cwg53: yes
847 enum E
{ e
} x
= static_cast<E
>(n
);
850 namespace cwg54
{ // cwg54: 2.8
851 struct A
{ int a
; } a
;
852 struct V
{ int v
; } v
;
853 struct B
: private A
, virtual V
{ int b
; } b
; // #cwg54-B
855 A
&sab
= static_cast<A
&>(b
);
856 // expected-error@-1 {{cannot cast 'struct B' to its private base class 'A'}}
857 // expected-note@#cwg54-B {{declared private here}}
858 A
*spab
= static_cast<A
*>(&b
);
859 // expected-error@-1 {{cannot cast 'struct B' to its private base class 'A'}}
860 // expected-note@#cwg54-B {{declared private here}}
861 int A::*smab
= static_cast<int A::*>(&B::b
);
862 // expected-error@-1 {{cannot cast 'cwg54::B' to its private base class 'A'}}
863 // expected-note@#cwg54-B {{declared private here}}
864 B
&sba
= static_cast<B
&>(a
);
865 // expected-error@-1 {{cannot cast private base class 'cwg54::A' to 'cwg54::B'}}
866 // expected-note@#cwg54-B {{declared private here}}
867 B
*spba
= static_cast<B
*>(&a
);
868 // expected-error@-1 {{cannot cast private base class 'cwg54::A' to 'cwg54::B'}}
869 // expected-note@#cwg54-B {{declared private here}}
870 int B::*smba
= static_cast<int B::*>(&A::a
);
871 // expected-error@-1 {{cannot cast private base class 'cwg54::A' to 'B'}}
872 // expected-note@#cwg54-B {{declared private here}}
874 V
&svb
= static_cast<V
&>(b
);
875 V
*spvb
= static_cast<V
*>(&b
);
876 int V::*smvb
= static_cast<int V::*>(&B::b
);
877 // expected-error@-1 {{conversion from pointer to member of class 'cwg54::B' to pointer to member of class 'V' via virtual base 'cwg54::V' is not allowed}}
878 B
&sbv
= static_cast<B
&>(v
);
879 // expected-error@-1 {{cannot cast 'struct V' to 'B &' via virtual base 'cwg54::V'}}
880 B
*spbv
= static_cast<B
*>(&v
);
881 // expected-error@-1 {{cannot cast 'cwg54::V *' to 'B *' via virtual base 'cwg54::V'}}
882 int B::*smbv
= static_cast<int B::*>(&V::v
);
883 // expected-error@-1 {{conversion from pointer to member of class 'cwg54::V' to pointer to member of class 'B' via virtual base 'cwg54::V' is not allowed}}
887 int A::*cmab
= (int A::*)(&B::b
);
890 int B::*cmba
= (int B::*)(&A::a
);
894 int V::*cmvb
= (int V::*)(&B::b
);
895 // expected-error@-1 {{conversion from pointer to member of class 'cwg54::B' to pointer to member of class 'V' via virtual base 'cwg54::V' is not allowed}}
897 // expected-error@-1 {{cannot cast 'struct V' to 'B &' via virtual base 'cwg54::V'}}
899 // expected-error@-1 {{cannot cast 'cwg54::V *' to 'B *' via virtual base 'cwg54::V'}}
900 int B::*cmbv
= (int B::*)(&V::v
);
901 // expected-error@-1 {{conversion from pointer to member of class 'cwg54::V' to pointer to member of class 'B' via virtual base 'cwg54::V' is not allowed}}
904 namespace cwg55
{ // cwg55: yes
906 static_assert(e
+ 1 == 6, "");
909 namespace cwg56
{ // cwg56: yes
911 typedef int T
; // #cwg56-typedef-int-T-first
913 // expected-error@-1 {{redefinition of 'T'}}
914 // expected-note@#cwg56-typedef-int-T-first {{previous definition is here}}
918 typedef X X
; // #cwg56-typedef-X-X-first
920 // expected-error@-1 {{redefinition of 'X'}}
921 // expected-note@#cwg56-typedef-X-X-first {{previous definition is here}}
925 namespace cwg58
{ // cwg58: 3.1
926 // FIXME: Ideally, we should have a CodeGen test for this.
927 #if __cplusplus >= 201103L
928 enum E1
{ E1_0
= 0, E1_1
= 1 };
929 enum E2
{ E2_0
= 0, E2_m1
= -1 };
930 struct X
{ E1 e1
: 1; E2 e2
: 1; };
931 static_assert(X
{E1_1
, E2_m1
}.e1
== 1, "");
932 static_assert(X
{E1_1
, E2_m1
}.e2
== -1, "");
936 namespace cwg59
{ // cwg59: yes
937 #pragma clang diagnostic push
938 #pragma clang diagnostic ignored "-Wdeprecated-volatile"
939 template<typename T
> struct convert_to
{ operator T() const; };
940 struct A
{}; // #cwg59-A
941 struct B
: A
{}; // #cwg59-B
943 A a1
= convert_to
<A
>();
944 A a2
= convert_to
<A
&>();
945 A a3
= convert_to
<const A
>();
946 A a4
= convert_to
<const volatile A
>();
947 // cxx98-14-error@-1 {{no viable constructor copying variable of type 'const volatile cwg59::A'}}
948 // cxx98-14-note@#cwg59-A {{candidate constructor (the implicit copy constructor) not viable: 1st argument ('const volatile cwg59::A') would lose volatile qualifier}}
949 // cxx11-14-note@#cwg59-A {{candidate constructor (the implicit move constructor) not viable: 1st argument ('const volatile cwg59::A') would lose const and volatile qualifiers}}
950 // cxx98-14-note@#cwg59-A {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
951 A a5
= convert_to
<const volatile A
&>();
952 // expected-error@-1 {{no viable constructor copying variable of type 'const volatile cwg59::A'}}
953 // expected-note@#cwg59-A {{candidate constructor (the implicit copy constructor) not viable: 1st argument ('const volatile cwg59::A') would lose volatile qualifier}}
954 // since-cxx11-note@#cwg59-A {{candidate constructor (the implicit move constructor) not viable: 1st argument ('const volatile cwg59::A') would lose const and volatile qualifiers}}
955 // expected-note@#cwg59-A {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
957 B b1
= convert_to
<B
>();
958 B b2
= convert_to
<B
&>();
959 B b3
= convert_to
<const B
>();
960 B b4
= convert_to
<const volatile B
>();
961 // cxx98-14-error@-1 {{no viable constructor copying variable of type 'const volatile cwg59::B'}}
962 // cxx98-14-note@#cwg59-B {{candidate constructor (the implicit copy constructor) not viable: 1st argument ('const volatile cwg59::B') would lose volatile qualifier}}
963 // cxx11-14-note@#cwg59-B {{candidate constructor (the implicit move constructor) not viable: 1st argument ('const volatile cwg59::B') would lose const and volatile qualifiers}}
964 // cxx98-14-note@#cwg59-B {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
965 B b5
= convert_to
<const volatile B
&>();
966 // expected-error@-1 {{no viable constructor copying variable of type 'const volatile cwg59::B'}}
967 // expected-note@#cwg59-B {{candidate constructor (the implicit copy constructor) not viable: 1st argument ('const volatile cwg59::B') would lose volatile qualifier}}
968 // since-cxx11-note@#cwg59-B {{candidate constructor (the implicit move constructor) not viable: 1st argument ('const volatile cwg59::B') would lose const and volatile qualifiers}}
969 // expected-note@#cwg59-B {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
971 A c1
= convert_to
<B
>();
972 A c2
= convert_to
<B
&>();
973 A c3
= convert_to
<const B
>();
974 A c4
= convert_to
<const volatile B
>();
975 // expected-error@-1 {{no viable constructor copying variable of type 'const volatile cwg59::B'}}
976 // expected-note@#cwg59-A {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const volatile cwg59::B' to 'const A &' for 1st argument}}
977 // since-cxx11-note@#cwg59-A {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'const volatile cwg59::B' to 'A &&' for 1st argument}}
978 // expected-note@#cwg59-A {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
979 A c5
= convert_to
<const volatile B
&>();
980 // expected-error@-1 {{no viable constructor copying variable of type 'const volatile cwg59::B'}}
981 // expected-note@#cwg59-A {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const volatile cwg59::B' to 'const A &' for 1st argument}}
982 // since-cxx11-note@#cwg59-A {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'const volatile cwg59::B' to 'A &&' for 1st argument}}
983 // expected-note@#cwg59-A {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
985 int n1
= convert_to
<int>();
986 int n2
= convert_to
<int&>();
987 int n3
= convert_to
<const int>();
988 int n4
= convert_to
<const volatile int>();
989 int n5
= convert_to
<const volatile int&>();
990 #pragma clang diagnostic pop
993 namespace cwg60
{ // cwg60: yes
1000 namespace cwg61
{ // cwg61: 3.4
1008 // This is (presumably) valid, because x.f does not refer to an overloaded
1012 // expected-error@-1 {{cannot create a non-constant pointer to member function}}
1014 // expected-error@-1 {{cannot create a non-constant pointer to member function}}
1015 } // namespace cwg61
1017 namespace cwg62
{ // cwg62: 2.9
1019 struct { int n
; } b
;
1021 template<typename T
> struct X
{};
1022 template<typename T
> T
get() { return get
<T
>(); }
1023 template<typename T
> int take(T
) { return 0; }
1028 typedef struct { } *NoNameForLinkagePtr
; // #cwg62-unnamed
1029 NoNameForLinkagePtr noNameForLinkagePtr
;
1032 NoNameForLinkagePtr p
;
1035 X
<NoNameForLinkagePtr
> x2
;
1036 // cxx98-error@-1 {{template argument uses unnamed type}}
1037 // cxx98-note@#cwg62-unnamed {{unnamed type used in template argument was declared here}}
1038 X
<const NoNameForLinkagePtr
> x3
;
1039 // cxx98-error@-1 {{template argument uses unnamed type}}
1040 // cxx98-note@#cwg62-unnamed {{unnamed type used in template argument was declared here}}
1041 NoNameForLinkagePtr p1
= get
<NoNameForLinkagePtr
>();
1042 // cxx98-error@-1 {{template argument uses unnamed type}}
1043 // cxx98-note@#cwg62-unnamed {{unnamed type used in template argument was declared here}}
1044 NoNameForLinkagePtr p2
= get
<const NoNameForLinkagePtr
>();
1045 // cxx98-error@-1 {{template argument uses unnamed type}}
1046 // cxx98-note@#cwg62-unnamed {{unnamed type used in template argument was declared here}}
1047 int n1
= take(noNameForLinkagePtr
);
1048 // cxx98-error@-1 {{template argument uses unnamed type}}
1049 // cxx98-note@#cwg62-unnamed {{unnamed type used in template argument was declared here}}
1054 struct NoLinkage
{};
1056 // cxx98-error@-1 {{template argument uses local type }}
1057 X
<const NoLinkage
> b
;
1058 // cxx98-error@-1 {{template argument uses local type }}
1060 // cxx98-error@-1 {{template argument uses local type }}
1061 get
<const NoLinkage
>();
1062 // cxx98-error@-1 {{template argument uses local type }}
1063 X
<void (*)(NoLinkage
A::*)> c
;
1064 // cxx98-error@-1 {{template argument uses local type }}
1065 X
<int NoLinkage::*> d
;
1066 // cxx98-error@-1 {{template argument uses local type }}
1068 } // namespace cwg62
1070 namespace cwg63
{ // cwg63: yes
1071 template<typename T
> struct S
{ typename
T::error e
; };
1074 } // namespace cwg63
1076 namespace cwg64
{ // cwg64: yes
1077 template<class T
> void f(T
);
1078 template<class T
> void f(T
*);
1079 template<> void f(int*);
1080 template<> void f
<int>(int*);
1081 template<> void f(int);
1082 } // namespace cwg64
1086 namespace cwg66
{ // cwg66: no
1088 int f(int n
); // #cwg66-f-first
1095 // FIXME: The first two calls here should be accepted.
1097 // expected-error@-1 {{no matching function for call to 'f'}}
1098 // expected-note@#cwg66-f-first {{candidate function not viable: requires single argument 'n', but no arguments were provided}}
1101 // expected-error@-1 {{no matching function for call to 'f'}}
1102 // expected-note@#cwg66-f-first {{candidate function not viable: requires single argument 'n', but 2 arguments were provided}}
1103 } // namespace cwg66
1107 namespace cwg68
{ // cwg68: 2.8
1108 template<typename T
> struct X
{};
1109 struct ::cwg68::X
<int> x1
;
1110 struct ::cwg68::template X
<int> x2
;
1111 // cxx98-error@-1 {{'template' keyword outside of a template}}
1113 friend struct X
<int>;
1114 friend struct ::cwg68::X
<char>;
1115 friend struct ::cwg68::template X
<double>;
1116 // cxx98-error@-1 {{'template' keyword outside of a template}}
1120 friend struct ::cwg68::template X
<double>;
1121 friend typename ::cwg68::X
<double>;
1122 // cxx98-error@-1 {{unelaborated friend declaration is a C++11 extension; specify 'struct' to befriend 'typename ::cwg68::X<double>'}}
1124 } // namespace cwg68
1126 namespace cwg69
{ // cwg69: 9
1127 template<typename T
> static void f() {} // #cwg69-f
1128 // FIXME: Should we warn here?
1129 inline void g() { f
<int>(); }
1130 extern template void f
<char>();
1131 // cxx98-error@-1 {{extern templates are a C++11 extension}}
1132 // expected-error@-2 {{explicit instantiation declaration of 'f' with internal linkage}}
1133 template<void(*)()> struct Q
{};
1135 // cxx98-error@-1 {{non-type template argument referring to function 'f<int>' with internal linkage is a C++11 extension}}
1136 // cxx98-note@#cwg69-f {{non-type template argument refers to function here}}
1137 } // namespace cwg69
1139 namespace cwg70
{ // cwg70: yes
1140 template<int> struct A
{};
1141 template<int I
, int J
> int f(int (&)[I
+ J
], A
<I
>, A
<J
>);
1143 int k
= f(arr
, A
<3>(), A
<4>());
1144 } // namespace cwg70
1149 namespace cwg73
{ // cwg73: sup 1652
1150 #if __cplusplus >= 201103L
1152 static_assert(&a
+ 1 != &b
, "");
1153 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
1154 // expected-note@-2 {{comparison against pointer '&a + 1' that points past the end of a complete object has unspecified value}}
1156 } // namespace cwg73
1158 namespace cwg74
{ // cwg74: yes
1160 int (*p
)[k
] = new int[k
][k
];
1161 } // namespace cwg74
1163 namespace cwg75
{ // cwg75: yes
1166 // expected-error@-1 {{non-const static data member must be initialized out of line}}
1168 } // namespace cwg75
1170 namespace cwg76
{ // cwg76: yes
1171 const volatile int n
= 1;
1172 static_assert(n
, "");
1173 // expected-error@-1 {{static assertion expression is not an integral constant expression}}
1174 // expected-note@-2 {{read of volatile-qualified type 'const volatile int' is not allowed in a constant expression}}
1175 } // namespace cwg76
1177 namespace cwg77
{ // cwg77: yes
1182 } // namespace cwg77
1184 namespace cwg78
{ // cwg78: sup ????
1185 // Under CWG78, this is valid, because 'k' has static storage duration, so is
1186 // zero-initialized.
1188 // expected-error@-1 {{default initialization of an object of const type 'const int'}}
1189 } // namespace cwg78
1193 namespace cwg80
{ // cwg80: 2.9
1199 // expected-error@-1 {{member 'B' has the same name as its class}}
1203 // expected-error@-1 {{member 'C' has the same name as its class}}
1209 // expected-error@-1 {{member 'D' has the same name as its class}}
1211 } // namespace cwg80
1216 namespace cwg83
{ // cwg83: yes
1217 int &f(const char*);
1220 } // namespace cwg83
1222 namespace cwg84
{ // cwg84: yes
1224 struct A
{ operator B() const; };
1227 B(B
&); // #cwg84-copy-ctor
1228 B(C
); // #cwg84-ctor-from-C
1232 // Cannot use B(C) / operator C() pair to construct the B from the B temporary
1233 // here. In C++17, we initialize the B object directly using 'A::operator B()'.
1235 // cxx98-14-error@-1 {{no viable constructor copying variable of type 'B'}}
1236 // cxx98-14-note@#cwg84-copy-ctor {{candidate constructor not viable: expects an lvalue for 1st argument}}
1237 // cxx98-14-note@#cwg84-ctor-from-C {{candidate constructor not viable: no known conversion from 'B' to 'C' for 1st argument}}
1238 } // namespace cwg84
1240 namespace cwg85
{ // cwg85: 3.4
1243 struct B
{}; // #cwg85-B-def
1245 // expected-error@-1 {{class member cannot be redeclared}}
1246 // expected-note@#cwg85-B-def {{previous declaration is here}}
1249 union U
{}; // #cwg85-U-def
1251 // expected-error@-1 {{class member cannot be redeclared}}
1252 // expected-note@#cwg85-U-def {{previous declaration is here}}
1254 #if __cplusplus >= 201103L
1256 enum E1
: int { e1
}; // #cwg85-E1-def
1258 // expected-error@-1 {{class member cannot be redeclared}}
1259 // expected-note@#cwg85-E1-def {{previous declaration is here}}
1262 enum class E2
{ e2
}; // #cwg85-E2-def
1264 // expected-error@-1 {{class member cannot be redeclared}}
1265 // expected-note@#cwg85-E2-def {{previous declaration is here}}
1269 template <typename T
>
1271 struct B
{}; // #cwg85-C-B-def
1273 // expected-error@-1 {{class member cannot be redeclared}}
1274 // expected-note@#cwg85-C-B-def {{previous declaration is here}}
1276 } // namespace cwg85
1280 namespace cwg87
{ // cwg87: no
1281 // FIXME: Superseded by cwg1975
1282 template<typename T
> struct X
{};
1283 // FIXME: This is invalid.
1284 X
<void() throw()> x
;
1285 // This is valid under cwg87 but not under cwg1975.
1286 X
<void(void() throw())> y
;
1287 } // namespace cwg87
1289 namespace cwg88
{ // cwg88: 2.8
1290 template<typename T
> struct S
{
1291 static const int a
= 1; // #cwg88-a
1294 template<> const int S
<int>::a
= 4;
1295 // expected-error@-1 {{static data member 'a' already has an initializer}}
1296 // expected-note@#cwg88-a {{previous initialization is here}}
1297 template<> const int S
<int>::b
= 4;
1298 } // namespace cwg88
1302 namespace cwg90
{ // cwg90: yes
1304 template<typename T
> friend void cwg90_f(T
);
1307 template<typename T
> friend void cwg90_g(T
);
1318 // expected-error@-1 {{use of undeclared identifier 'cwg90_f'}}
1320 // expected-error@-1 {{use of undeclared identifier 'cwg90_f'}}
1323 // expected-error@-1 {{use of undeclared identifier 'cwg90_f'}}
1326 // expected-error@-1 {{use of undeclared identifier 'cwg90_g'}}
1332 // expected-error@-1 {{use of undeclared identifier 'cwg90_g'}}
1334 } // namespace cwg90
1336 namespace cwg91
{ // cwg91: yes
1337 union U
{ friend int f(U
); };
1339 } // namespace cwg91
1341 namespace cwg92
{ // cwg92: 4 c++17
1342 void f() throw(int, float);
1343 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1344 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1345 void (*p
)() throw(int) = &f
; // #cwg92-p
1346 // since-cxx17-error@#cwg92-p {{ISO C++17 does not allow dynamic exception specifications}}
1347 // since-cxx17-note@#cwg92-p {{use 'noexcept(false)' instead}}
1348 // cxx98-14-error@#cwg92-p {{target exception specification is not superset of source}}
1349 // since-cxx17-warning@#cwg92-p {{target exception specification is not superset of source}}
1350 void (*q
)() throw(int);
1351 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1352 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1353 void (**pp
)() throw() = &q
;
1354 // cxx98-14-error@-1 {{exception specifications are not allowed beyond a single level of indirection}}
1355 // since-cxx17-error@-2 {{cannot initialize a variable of type 'void (**)() throw()' with an rvalue of type 'void (**)() throw(int)'}}
1357 void g(void() throw()); // #cwg92-g
1358 // cxx98-14-warning@-1 {{mangled name of 'g' will change in C++17 due to non-throwing exception specification in function signature}}
1361 // cxx98-14-error@-1 {{target exception specification is not superset of source}}
1362 // since-cxx17-error@-2 {{no matching function for call to 'g'}}
1363 // since-cxx17-note@#cwg92-g {{candidate function not viable: no known conversion from 'void () throw(int, float)' to 'void (*)() throw()' for 1st argument}}
1365 // cxx98-14-error@-1 {{target exception specification is not superset of source}}
1366 // since-cxx17-error@-2 {{no matching function for call to 'g'}}
1367 // since-cxx17-note@#cwg92-g {{candidate function not viable: no known conversion from 'void (*)() throw(int)' to 'void (*)() throw()' for 1st argument}}
1370 // Prior to C++17, this is OK because the exception specification is not
1371 // considered in this context. In C++17, we *do* perform an implicit
1372 // conversion (which performs initialization), and the exception specification
1373 // is part of the type of the parameter, so this is invalid.
1374 template<void() throw()> struct X
{};
1376 // since-cxx17-error@-1 {{value of type 'void (*)() throw(int, float)' is not implicitly convertible to 'void (*)() throw()'}}
1378 template<void() throw(int)> struct Y
{};
1379 // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
1380 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
1382 } // namespace cwg92
1386 namespace cwg94
{ // cwg94: yes
1387 struct A
{ static const int n
= 5; };
1389 } // namespace cwg94
1391 namespace cwg95
{ // cwg95: 3.3
1398 static void f(); // #cwg95-C-f
1400 struct A
*p
; // cwg95::A, not cwg95::N::A.
1402 A
*q
= N::p
; // ok, same type
1403 struct B
{ void f() { N::C::f(); } };
1404 // expected-error@-1 {{'f' is a private member of 'cwg95::N::C'}}
1405 // expected-note@#cwg95-C-f {{implicitly declared private here}}
1406 } // namespace cwg95
1408 namespace cwg96
{ // cwg96: sup P1787
1411 template<typename T
> int f(T
);
1412 template<typename T
> struct S
{};
1414 template<template<typename
> class X
> struct B
{};
1416 template<typename T
>
1418 int k1
= a
.template f
<int>(0);
1419 // FIXME: This is ill-formed, because 'f' is not a template-id and does not
1420 // name a class template.
1421 // FIXME: What about alias templates?
1422 int k2
= a
.template f(1);
1423 // expected-error@-1 {{a template argument list is expected after a name prefixed by the template keyword}}
1424 A::template S
<int> s
;
1427 } // namespace cwg96
1429 namespace cwg97
{ // cwg97: yes
1431 static const int a
= false;
1432 static const int b
= !a
;
1434 } // namespace cwg97
1436 namespace cwg98
{ // cwg98: yes
1441 // expected-error@-1 {{cannot jump from switch statement to this case label}}
1442 // expected-note@#cwg98-try {{jump bypasses initialization of try block}}
1445 } catch (...) { // #cwg98-catch
1447 // expected-error@-1 {{cannot jump from switch statement to this case label}}
1448 // expected-note@#cwg98-catch {{jump bypasses initialization of catch block}}
1454 // expected-error@-1 {{cannot jump from this goto statement to its label}}
1455 // expected-note@#cwg98-try {{jump bypasses initialization of try block}}
1458 // expected-error@-1 {{cannot jump from this goto statement to its label}}
1459 // expected-note@#cwg98-catch {{jump bypasses initialization of catch block}}
1462 } // namespace cwg98
1464 namespace cwg99
{ // cwg99: sup 214
1465 template<typename T
> void f(T
&);
1466 template<typename T
> int &f(const T
&);
1469 } // namespace cwg99