1 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -Wno-bind-to-temporary-copy
2 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
3 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
4 // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
6 namespace dr1 { // dr1: no
7 namespace X { extern "C" void dr1_f(int a = 1); }
8 namespace Y { extern "C" void dr1_f(int a = 1); }
9 using X::dr1_f; using Y::dr1_f;
12 // FIXME: This should be rejected, due to the ambiguous default argument.
19 // FIXME: This should be rejected, due to the ambiguous default argument.
27 void X::z(int = 1) {} // expected-note {{previous}}
29 void z(int = 1); // expected-error {{redefinition of default argument}}
37 // FIXME: This should be rejected, due to the ambiguous default argument.
44 // FIXME: This should be rejected, due to the ambiguous default argument.
49 namespace dr3 { // dr3: yes
50 template<typename T> struct A {};
51 template<typename T> void f(T) { A<T> a; } // expected-note {{implicit instantiation}}
53 template<> struct A<int> {}; // expected-error {{explicit specialization of 'dr3::A<int>' after instantiation}}
56 namespace dr4 { // dr4: yes
58 static void dr4_f(int) {}
59 static void dr4_f(float) {}
60 void dr4_g(int) {} // expected-note {{previous}}
61 void dr4_g(float) {} // expected-error {{conflicting types}}
65 namespace dr5 { // dr5: yes
71 const volatile B b = a;
75 struct E { operator D&(); } e;
79 namespace dr7 { // dr7: yes
80 class A { public: ~A(); };
81 class B : virtual private A {}; // expected-note 2 {{declared private here}}
82 class C : public B {} c; // expected-error 2 {{inherited virtual base class 'dr7::A' has private destructor}} \
83 // expected-note {{implicit default constructor for 'dr7::C' first required here}} \
84 // expected-note {{implicit destructor for 'dr7::C' first required here}}
85 class VeryDerivedC : public B, virtual public A {} vdc;
87 class X { ~X(); }; // expected-note {{here}}
88 class Y : X { ~Y() {} }; // expected-error {{private destructor}}
90 namespace PR16370 { // This regressed the first time DR7 was fixed.
91 struct S1 { virtual ~S1(); };
94 struct S4 : virtual S2 {};
103 namespace dr8 { // dr8: dup 45
106 static const int k = 5;
108 template<typename, int, void (A::*)()> struct T;
112 A::T<A::U, A::k, &A::f> *A::g() { return 0; }
115 namespace dr9 { // dr9: yes
118 int m; // expected-note {{here}}
121 struct N : protected B { // expected-note 2{{protected}}
124 int R1() { return n.m; } // expected-error {{protected base class}} expected-error {{protected member}}
125 int R2() { return n.m; }
128 namespace dr10 { // dr10: dup 45
136 namespace dr11 { // dr11: yes
137 template<typename T> struct A : T {
141 template<typename T> struct B : T {
143 V v; // expected-error {{unknown type name}}
145 struct X { typedef int U; };
149 namespace dr12 { // dr12: sup 239
154 // Under DR12, these call two different functions.
155 // Under DR239, they call the same function.
161 namespace dr13 { // dr13: no
162 extern "C" void f(int);
165 template<typename T> struct A {
168 template<typename T> int h(void (T));
170 A<int> a1(f); // FIXME: We should reject this.
172 int a3 = h(f); // FIXME: We should reject this.
176 namespace dr14 { // dr14: yes
177 namespace X { extern "C" int dr14_f(); }
178 namespace Y { extern "C" int dr14_f(); }
185 friend int Y::dr14_f();
188 extern "C" int dr14_f() { return c.k; }
191 namespace X { typedef int T; typedef int U; } // expected-note {{candidate}}
192 namespace Y { typedef int T; typedef long U; } // expected-note {{candidate}}
193 T t; // ok, same type both times
194 U u; // expected-error {{ambiguous}}
197 namespace dr15 { // dr15: yes
198 template<typename T> void f(int); // expected-note {{previous}}
199 template<typename T> void f(int = 0); // expected-error {{default arguments cannot be added}}
202 namespace dr16 { // dr16: yes
203 class A { // expected-note {{here}}
204 void f(); // expected-note {{here}}
207 class B : A {}; // expected-note 4{{here}}
210 f(); // expected-error {{private member}} expected-error {{private base}}
211 A::f(); // expected-error {{private member}} expected-error {{private base}}
216 namespace dr17 { // dr17: yes
223 int A::f() { return b.n; }
225 int g() { return n; }
231 namespace dr19 { // dr19: yes
233 int n; // expected-note {{here}}
235 struct B : protected A { // expected-note {{here}}
239 int get1() { return c.n; } // expected-error {{protected member}}
240 int get2() { return ((A&)c).n; } // ok, A is an accessible base of B from here
244 namespace dr20 { // dr20: yes
249 X(const X&); // expected-note {{here}}
252 X x = f(); // expected-error {{private}}
255 namespace dr21 { // dr21: yes
256 template<typename T> struct A;
258 template<typename T = int> friend struct A; // expected-error {{default template argument not permitted on a friend template}}
259 template<typename T = int> friend struct B; // expected-error {{default template argument not permitted on a friend template}}
263 namespace dr22 { // dr22: sup 481
264 template<typename dr22_T = dr22_T> struct X; // expected-error {{unknown type name 'dr22_T'}}
266 template<typename T = T> struct Y;
269 namespace dr23 { // dr23: yes
270 template<typename T> void f(T, T); // expected-note {{candidate}}
271 template<typename T> void f(T, int); // expected-note {{candidate}}
272 void g() { f(0, 0); } // expected-error {{ambiguous}}
277 namespace dr25 { // dr25: yes
279 void f() throw(int); // expected-error 0-1{{ISO C++1z does not allow}} expected-note 0-1{{use 'noexcept}}
281 void (A::*f)() throw (int); // expected-error 0-1{{ISO C++1z does not allow}} expected-note 0-1{{use 'noexcept}}
282 void (A::*g)() throw () = f;
283 #if __cplusplus <= 201402L
284 // expected-error@-2 {{is not superset of source}}
286 // expected-error@-4 {{different exception specifications}}
288 void (A::*g2)() throw () = 0;
289 void (A::*h)() throw (int, char) = f; // expected-error 0-1{{ISO C++1z does not allow}} expected-note 0-1{{use 'noexcept}}
290 void (A::*i)() throw () = &A::f;
291 #if __cplusplus <= 201402L
292 // expected-error@-2 {{is not superset of source}}
294 // expected-error@-4 {{different exception specifications}}
296 void (A::*i2)() throw () = 0;
297 void (A::*j)() throw (int, char) = &A::f; // expected-error 0-1{{ISO C++1z does not allow}} expected-note 0-1{{use 'noexcept}}
300 #if __cplusplus <= 201402L
301 // expected-error@-2 {{is not superset of source}}
303 // expected-error@-4 {{different exception specifications}}
307 #if __cplusplus <= 201402L
308 // expected-error@-2 {{is not superset of source}}
310 // expected-error@-4 {{different exception specifications}}
316 namespace dr26 { // dr26: yes
317 struct A { A(A, const A & = A()); }; // expected-error {{must pass its first argument by reference}}
319 B(); // expected-note 0-1{{candidate}}
320 B(const B &, B = B());
321 #if __cplusplus <= 201402L
322 // expected-error@-2 {{no matching constructor}} expected-note@-2 {{candidate}} expected-note@-2 {{here}}
327 C(const C &, C = f()); // expected-error {{no matching constructor}} expected-note {{candidate}} expected-note {{here}}
331 namespace dr27 { // dr27: yes
338 namespace dr29 { // dr29: 3.4
339 void dr29_f0(); // expected-note {{here}}
340 void g0() { void dr29_f0(); }
341 extern "C++" void g0_cxx() { void dr29_f0(); }
342 extern "C" void g0_c() { void dr29_f0(); } // expected-error {{different language linkage}}
344 extern "C" void dr29_f1(); // expected-note {{here}}
345 void g1() { void dr29_f1(); }
346 extern "C" void g1_c() { void dr29_f1(); }
347 extern "C++" void g1_cxx() { void dr29_f1(); } // expected-error {{different language linkage}}
349 void g2() { void dr29_f2(); } // expected-note {{here}}
350 extern "C" void dr29_f2(); // expected-error {{different language linkage}}
352 extern "C" void g3() { void dr29_f3(); } // expected-note {{here}}
353 extern "C++" void dr29_f3(); // expected-error {{different language linkage}}
355 extern "C++" void g4() { void dr29_f4(); } // expected-note {{here}}
356 extern "C" void dr29_f4(); // expected-error {{different language linkage}}
358 extern "C" void g5();
359 extern "C++" void dr29_f5();
361 void dr29_f5(); // ok, g5 is extern "C" but we're not inside the linkage-specification here.
364 extern "C++" void g6();
365 extern "C" void dr29_f6();
367 void dr29_f6(); // ok, g6 is extern "C" but we're not inside the linkage-specification here.
370 extern "C" void g7();
371 extern "C++" void dr29_f7(); // expected-note {{here}}
372 extern "C" void g7() {
373 void dr29_f7(); // expected-error {{different language linkage}}
376 extern "C++" void g8();
377 extern "C" void dr29_f8(); // expected-note {{here}}
378 extern "C++" void g8() {
379 void dr29_f8(); // expected-error {{different language linkage}}
383 namespace dr30 { // dr30: sup 468 c++11
385 template<int> static int f();
387 int x = A::template f<0>();
388 int y = a.template f<0>();
389 int z = p->template f<0>();
390 #if __cplusplus < 201103L
391 // FIXME: It's not clear whether DR468 applies to C++98 too.
392 // expected-error@-5 {{'template' keyword outside of a template}}
393 // expected-error@-5 {{'template' keyword outside of a template}}
394 // expected-error@-5 {{'template' keyword outside of a template}}
398 namespace dr31 { // dr31: yes
401 void operator delete(void*); // expected-note {{here}}
403 // We would call X::operator delete if X() threw (even though it can't,
404 // and even though we allocated the X using ::operator delete).
405 X *p = new X; // expected-error {{private}}
410 namespace dr33 { // dr33: yes
411 namespace X { struct S; void f(void (*)(S)); } // expected-note {{candidate}}
412 namespace Y { struct T; void f(void (*)(T)); } // expected-note {{candidate}}
414 template<typename Z> Z g(Y::T);
415 void h() { f(&g); } // expected-error {{ambiguous}}
422 namespace dr38 { // dr38: yes
423 template<typename T> struct X {};
424 template<typename T> X<T> operator+(X<T> a, X<T> b) { return a; }
425 template X<int> operator+<int>(X<int>, X<int>);
428 namespace dr39 { // dr39: no
430 struct A { int &f(int); };
440 int &x(int); // expected-note {{found}}
441 static int &y(int); // expected-note {{found}}
446 struct B : A, virtual V {
447 using A::x; // expected-note {{found}}
449 using A::y; // expected-note {{found}}
450 static float &y(float);
454 struct C : A, B, virtual V {} c; // expected-warning {{direct base 'dr39::example2::A' is inaccessible due to ambiguity:\n struct dr39::example2::C -> struct dr39::example2::A\n struct dr39::example2::C -> struct dr39::example2::B -> struct dr39::example2::A}}
455 int &x = c.x(0); // expected-error {{found in multiple base classes}}
456 // FIXME: This is valid, because we find the same static data member either way.
457 int &y = c.y(0); // expected-error {{found in multiple base classes}}
462 struct A { static int f(); };
463 struct B : virtual A { using A::f; };
464 struct C : virtual A { using A::f; };
465 struct D : B, C {} d;
470 struct A { int n; }; // expected-note {{found}}
473 struct D : B, C { int f() { return n; } }; // expected-error {{found in multiple base-class}}
477 // FIXME: This is valid.
478 struct A { int n; }; // expected-note +{{found}}
482 int k = sizeof(D::n); // expected-error {{found in multiple base}} expected-error {{unknown type name}}
483 #if __cplusplus >= 201103L
484 decltype(D::n) n; // expected-error {{found in multiple base}}
491 namespace dr41 { // dr41: yes
495 namespace dr42 { // dr42: yes
496 struct A { static const int k = 0; };
497 struct B : A { static const int k = A::k; };
502 namespace dr44 { // dr44: yes
504 template<int> void f();
505 template<> void f<0>(); // expected-error {{explicit specialization of 'f' in class scope}}
509 namespace dr45 { // dr45: yes
517 namespace dr46 { // dr46: yes
518 template<typename> struct A { template<typename> struct B {}; };
519 template template struct A<int>::B<int>; // expected-error {{expected unqualified-id}}
522 namespace dr47 { // dr47: sup 329
523 template<typename T> struct A {
524 friend void f() { T t; } // expected-error {{redefinition}} expected-note {{previous}}
527 A<float> b; // expected-note {{instantiation of}}
533 namespace dr48 { // dr48: yes
536 static const int m = 0;
537 static const int n = 0;
538 static const int o = 0;
542 // FIXME: We should produce a 'has internal linkage but is not defined'
543 // diagnostic for 'S::n'.
549 namespace dr49 { // dr49: yes
550 template<int*> struct A {}; // expected-note 0-2{{here}}
552 #if __has_feature(cxx_constexpr)
555 int *const p = &k; // expected-note 0-2{{here}}
558 #if __cplusplus <= 201402L
559 // expected-error@-2 {{must have its address taken}}
561 #if __cplusplus < 201103L
562 // expected-error@-5 {{internal linkage}}
566 #if __cplusplus < 201103L
567 // expected-error@-2 {{must have its address taken}}
569 // expected-error@-4 {{constant expression}}
570 // expected-note@-5 {{read of non-constexpr}}
571 // expected-note@-7 {{declared here}}
575 namespace dr50 { // dr50: yes
576 struct X; // expected-note {{forward}}
579 X *r = static_cast<X*>(p);
580 X *s = const_cast<X*>(p);
581 X *t = reinterpret_cast<X*>(p);
582 X *u = dynamic_cast<X*>(p); // expected-error {{incomplete}}
585 namespace dr51 { // dr51: yes
595 namespace dr52 { // dr52: yes
596 struct A { int n; }; // expected-note {{here}}
597 struct B : private A {} b; // expected-note 2{{private}}
598 // FIXME: This first diagnostic is very strangely worded, and seems to be bogus.
599 int k = b.A::n; // expected-error {{'A' is a private member of 'dr52::A'}}
600 // expected-error@-1 {{cannot cast 'struct B' to its private base}}
603 namespace dr53 { // dr53: yes
605 enum E { e } x = static_cast<E>(n);
608 namespace dr54 { // dr54: yes
609 struct A { int a; } a;
610 struct V { int v; } v;
611 struct B : private A, virtual V { int b; } b; // expected-note 6{{private here}}
613 A &sab = static_cast<A&>(b); // expected-error {{private base}}
614 A *spab = static_cast<A*>(&b); // expected-error {{private base}}
615 int A::*smab = static_cast<int A::*>(&B::b); // expected-error {{private base}}
616 B &sba = static_cast<B&>(a); // expected-error {{private base}}
617 B *spba = static_cast<B*>(&a); // expected-error {{private base}}
618 int B::*smba = static_cast<int B::*>(&A::a); // expected-error {{private base}}
620 V &svb = static_cast<V&>(b);
621 V *spvb = static_cast<V*>(&b);
622 int V::*smvb = static_cast<int V::*>(&B::b); // expected-error {{virtual base}}
623 B &sbv = static_cast<B&>(v); // expected-error {{virtual base}}
624 B *spbv = static_cast<B*>(&v); // expected-error {{virtual base}}
625 int B::*smbv = static_cast<int B::*>(&V::v); // expected-error {{virtual base}}
629 int A::*cmab = (int A::*)(&B::b);
632 int B::*cmba = (int B::*)(&A::a);
636 int V::*cmvb = (int V::*)(&B::b); // expected-error {{virtual base}}
637 B &cbv = (B&)(v); // expected-error {{virtual base}}
638 B *cpbv = (B*)(&v); // expected-error {{virtual base}}
639 int B::*cmbv = (int B::*)(&V::v); // expected-error {{virtual base}}
642 namespace dr55 { // dr55: yes
644 int test[(e + 1 == 6) ? 1 : -1];
647 namespace dr56 { // dr56: yes
649 typedef int T; // expected-note {{previous}}
650 typedef int T; // expected-error {{redefinition}}
654 typedef X X; // expected-note {{previous}}
655 typedef X X; // expected-error {{redefinition}}
659 namespace dr58 { // dr58: yes
660 // FIXME: Ideally, we should have a CodeGen test for this.
661 #if __cplusplus >= 201103L
662 enum E1 { E1_0 = 0, E1_1 = 1 };
663 enum E2 { E2_0 = 0, E2_m1 = -1 };
664 struct X { E1 e1 : 1; E2 e2 : 1; };
665 static_assert(X{E1_1, E2_m1}.e1 == 1, "");
666 static_assert(X{E1_1, E2_m1}.e2 == -1, "");
670 namespace dr59 { // dr59: yes
671 template<typename T> struct convert_to { operator T() const; };
672 struct A {}; // expected-note 5+{{candidate}}
673 struct B : A {}; // expected-note 0+{{candidate}}
675 A a1 = convert_to<A>();
676 A a2 = convert_to<A&>();
677 A a3 = convert_to<const A>();
678 A a4 = convert_to<const volatile A>();
679 #if __cplusplus <= 201402L
680 // expected-error@-2 {{no viable}}
682 A a5 = convert_to<const volatile A&>(); // expected-error {{no viable}}
684 B b1 = convert_to<B>();
685 B b2 = convert_to<B&>();
686 B b3 = convert_to<const B>();
687 B b4 = convert_to<const volatile B>();
688 #if __cplusplus <= 201402L
689 // expected-error@-2 {{no viable}}
691 B b5 = convert_to<const volatile B&>(); // expected-error {{no viable}}
693 A c1 = convert_to<B>();
694 A c2 = convert_to<B&>();
695 A c3 = convert_to<const B>();
696 A c4 = convert_to<const volatile B>(); // expected-error {{no viable}}
697 A c5 = convert_to<const volatile B&>(); // expected-error {{no viable}}
699 int n1 = convert_to<int>();
700 int n2 = convert_to<int&>();
701 int n3 = convert_to<const int>();
702 int n4 = convert_to<const volatile int>();
703 int n5 = convert_to<const volatile int&>();
706 namespace dr60 { // dr60: yes
713 namespace dr61 { // dr61: yes
721 // This is (presumably) valid, because x.f does not refer to an overloaded
724 void (*q)() = &y.f; // expected-error {{cannot create a non-constant pointer to member function}}
725 void (*r)() = y.f; // expected-error {{cannot create a non-constant pointer to member function}}
728 namespace dr62 { // dr62: yes
732 template<typename T> struct X {};
733 template<typename T> T get() { return get<T>(); }
734 template<typename T> int take(T) { return 0; }
739 typedef struct { } *NoNameForLinkagePtr;
740 #if __cplusplus < 201103L
741 // expected-note@-2 5{{here}}
743 NoNameForLinkagePtr noNameForLinkagePtr;
746 NoNameForLinkagePtr p;
749 X<NoNameForLinkagePtr> x2;
750 X<const NoNameForLinkagePtr> x3;
751 NoNameForLinkagePtr p1 = get<NoNameForLinkagePtr>();
752 NoNameForLinkagePtr p2 = get<const NoNameForLinkagePtr>();
753 int n1 = take(noNameForLinkagePtr);
754 #if __cplusplus < 201103L
755 // expected-error@-6 {{uses unnamed type}}
756 // expected-error@-6 {{uses unnamed type}}
757 // expected-error@-6 {{uses unnamed type}}
758 // expected-error@-6 {{uses unnamed type}}
759 // expected-error@-6 {{uses unnamed type}}
767 X<const NoLinkage> b;
769 get<const NoLinkage>();
770 X<void (*)(NoLinkage A::*)> c;
771 X<int NoLinkage::*> d;
772 #if __cplusplus < 201103L
773 // expected-error@-7 {{uses local type}}
774 // expected-error@-7 {{uses local type}}
775 // expected-error@-7 {{uses local type}}
776 // expected-error@-7 {{uses local type}}
777 // expected-error@-7 {{uses local type}}
778 // expected-error@-7 {{uses local type}}
783 namespace dr63 { // dr63: yes
784 template<typename T> struct S { typename T::error e; };
789 namespace dr64 { // dr64: yes
790 template<class T> void f(T);
791 template<class T> void f(T*);
792 template<> void f(int*);
793 template<> void f<int>(int*);
794 template<> void f(int);
799 namespace dr66 { // dr66: no
801 int f(int n); // expected-note 2{{candidate}}
808 // FIXME: The first two calls here should be accepted.
809 int a = f(); // expected-error {{no matching function}}
811 int c = f(1, 2); // expected-error {{no matching function}}
816 namespace dr68 { // dr68: yes
817 template<typename T> struct X {};
818 struct ::dr68::X<int> x1;
819 struct ::dr68::template X<int> x2;
820 #if __cplusplus < 201103L
821 // expected-error@-2 {{'template' keyword outside of a template}}
824 friend struct X<int>;
825 friend struct ::dr68::X<char>;
826 friend struct ::dr68::template X<double>;
827 #if __cplusplus < 201103L
828 // expected-error@-2 {{'template' keyword outside of a template}}
833 friend struct ::dr68::template X<double>;
834 friend typename ::dr68::X<double>;
835 #if __cplusplus < 201103L
836 // expected-error@-2 {{C++11 extension}}
841 namespace dr69 { // dr69: yes
842 template<typename T> static void f() {}
843 // FIXME: Should we warn here?
844 inline void g() { f<int>(); }
845 // FIXME: This should be rejected, per [temp.explicit]p11.
846 extern template void f<char>();
847 #if __cplusplus < 201103L
848 // expected-error@-2 {{C++11 extension}}
850 template<void(*)()> struct Q {};
852 #if __cplusplus < 201103L
853 // expected-error@-2 {{internal linkage}} expected-note@-11 {{here}}
857 namespace dr70 { // dr70: yes
858 template<int> struct A {};
859 template<int I, int J> int f(int (&)[I + J], A<I>, A<J>);
861 int k = f(arr, A<3>(), A<4>());
867 #if __cplusplus >= 201103L
868 namespace dr73 { // dr73: no
869 // The resolution to dr73 is unworkable. Consider:
871 static_assert(&a + 1 != &b, ""); // expected-error {{not an integral constant expression}}
875 namespace dr74 { // dr74: yes
877 int (*p)[k] = new int[k][k];
880 namespace dr75 { // dr75: yes
882 static int n = 0; // expected-error {{non-const}}
886 namespace dr76 { // dr76: yes
887 const volatile int n = 1;
888 int arr[n]; // expected-error +{{variable length array}}
891 namespace dr77 { // dr77: yes
898 namespace dr78 { // dr78: sup ????
899 // Under DR78, this is valid, because 'k' has static storage duration, so is
901 const int k; // expected-error {{default initialization of an object of const}}
906 namespace dr80 { // dr80: yes
911 static int B; // expected-error {{same name as its class}}
914 int C; // expected-note {{hidden by}}
915 // FIXME: These diagnostics aren't very good.
916 C(); // expected-error {{must use 'struct' tag to refer to}} expected-error {{expected member name}}
920 int D; // expected-error {{same name as its class}}
927 namespace dr83 { // dr83: yes
933 namespace dr84 { // dr84: yes
935 struct A { operator B() const; };
938 B(B&); // expected-note 0-1{{candidate}}
939 B(C); // expected-note 0-1{{no known conversion from 'dr84::B' to 'dr84::C'}}
943 // Cannot use B(C) / operator C() pair to construct the B from the B temporary
944 // here. In C++1z, we initialize the B object directly using 'A::operator B()'.
946 #if __cplusplus <= 201402L
947 // expected-error@-2 {{no viable}}
951 namespace dr85 { // dr85: yes
954 struct B {}; // expected-note{{previous declaration is here}}
955 struct B; // expected-error{{class member cannot be redeclared}}
958 union U {}; // expected-note{{previous declaration is here}}
959 union U; // expected-error{{class member cannot be redeclared}}
961 #if __cplusplus >= 201103L
963 enum E1 : int { e1 }; // expected-note{{previous declaration is here}}
964 enum E1 : int; // expected-error{{class member cannot be redeclared}}
967 enum class E2 { e2 }; // expected-note{{previous declaration is here}}
968 enum class E2; // expected-error{{class member cannot be redeclared}}
972 template <typename T>
974 struct B {}; // expected-note{{previous declaration is here}}
975 struct B; // expected-error{{class member cannot be redeclared}}
981 namespace dr87 { // dr87: no
982 // FIXME: Superseded by dr1975
983 template<typename T> struct X {};
984 // FIXME: This is invalid.
986 // This is valid under dr87 but not under dr1975.
987 X<void(void() throw())> y;
990 namespace dr88 { // dr88: yes
991 template<typename T> struct S {
992 static const int a = 1; // expected-note {{previous}}
995 template<> const int S<int>::a = 4; // expected-error {{already has an initializer}}
996 template<> const int S<int>::b = 4;
1001 namespace dr90 { // dr90: yes
1003 template<typename T> friend void dr90_f(T);
1006 template<typename T> friend void dr90_g(T);
1016 dr90_f(B::C()); // expected-error {{undeclared identifier}}
1017 dr90_f(B::D()); // expected-error {{undeclared identifier}}
1019 dr90_f(F()); // expected-error {{undeclared identifier}}
1021 dr90_g(A()); // expected-error {{undeclared identifier}}
1026 dr90_g(F()); // expected-error {{undeclared identifier}}
1030 namespace dr91 { // dr91: yes
1031 union U { friend int f(U); };
1035 namespace dr92 { // dr92: 4.0 c++17
1036 void f() throw(int, float); // expected-error 0-1{{ISO C++1z does not allow}} expected-note 0-1{{use 'noexcept}}
1037 void (*p)() throw(int) = &f; // expected-error 0-1{{ISO C++1z does not allow}} expected-note 0-1{{use 'noexcept}}
1038 #if __cplusplus <= 201402L
1039 // expected-error@-2 {{target exception specification is not superset of source}}
1041 // expected-warning@-4 {{target exception specification is not superset of source}}
1043 void (*q)() throw(int); // expected-error 0-1{{ISO C++1z does not allow}} expected-note 0-1{{use 'noexcept}}
1044 void (**pp)() throw() = &q;
1045 #if __cplusplus <= 201402L
1046 // expected-error@-2 {{exception specifications are not allowed}}
1048 // expected-error@-4 {{cannot initialize}}
1051 void g(void() throw()); // expected-note 0-2 {{no known conversion}} expected-warning 0-1{{mangled name of 'g' will change in C++17}}
1053 g(f); // expected-error-re {{{{is not superset|no matching function}}}}
1054 g(q); // expected-error-re {{{{is not superset|no matching function}}}}
1057 // Prior to C++17, this is OK because the exception specification is not
1058 // considered in this context. In C++17, we *do* perform an implicit
1059 // conversion (which performs initialization), and the exception specification
1060 // is part of the type of the parameter, so this is invalid.
1061 template<void() throw()> struct X {};
1063 #if __cplusplus > 201402L
1064 // expected-error@-2 {{not implicitly convertible}}
1067 template<void() throw(int)> struct Y {}; // expected-error 0-1{{ISO C++1z does not allow}} expected-note 0-1{{use 'noexcept}}
1073 namespace dr94 { // dr94: yes
1074 struct A { static const int n = 5; };
1078 namespace dr95 { // dr95: yes
1085 static void f(); // expected-note {{here}}
1087 struct A *p; // dr95::A, not dr95::N::A.
1089 A *q = N::p; // ok, same type
1090 struct B { void f() { N::C::f(); } }; // expected-error {{private}}
1093 namespace dr96 { // dr96: no
1096 template<typename T> int f(T);
1097 template<typename T> struct S {};
1099 template<template<typename> class X> struct B {};
1101 template<typename T>
1103 int k1 = a.template f<int>(0);
1104 // FIXME: This is ill-formed, because 'f' is not a template-id and does not
1105 // name a class template.
1106 // FIXME: What about alias templates?
1107 int k2 = a.template f(1);
1108 A::template S<int> s;
1113 namespace dr97 { // dr97: yes
1115 static const int a = false;
1116 static const int b = !a;
1120 namespace dr98 { // dr98: yes
1123 try { // expected-note 2{{bypasses}}
1124 case 0: // expected-error {{cannot jump}}
1127 } catch (...) { // expected-note 2{{bypasses}}
1128 case 1: // expected-error {{cannot jump}}
1133 goto x; // expected-error {{cannot jump}}
1135 goto y; // expected-error {{cannot jump}}
1140 namespace dr99 { // dr99: sup 214
1141 template<typename T> void f(T&);
1142 template<typename T> int &f(const T&);