diff options
Diffstat (limited to 'test/CXX/drs')
-rw-r--r-- | test/CXX/drs/dr0xx.cpp | 1144 | ||||
-rw-r--r-- | test/CXX/drs/dr10xx.cpp | 85 | ||||
-rw-r--r-- | test/CXX/drs/dr118.cpp | 26 | ||||
-rw-r--r-- | test/CXX/drs/dr11xx.cpp | 30 | ||||
-rw-r--r-- | test/CXX/drs/dr12xx.cpp | 80 | ||||
-rw-r--r-- | test/CXX/drs/dr13xx.cpp | 414 | ||||
-rw-r--r-- | test/CXX/drs/dr14xx.cpp | 375 | ||||
-rw-r--r-- | test/CXX/drs/dr158.cpp | 27 | ||||
-rw-r--r-- | test/CXX/drs/dr15xx.cpp | 483 | ||||
-rw-r--r-- | test/CXX/drs/dr16xx.cpp | 367 | ||||
-rw-r--r-- | test/CXX/drs/dr1748.cpp | 35 | ||||
-rw-r--r-- | test/CXX/drs/dr17xx.cpp | 78 | ||||
-rw-r--r-- | test/CXX/drs/dr18xx.cpp | 75 | ||||
-rw-r--r-- | test/CXX/drs/dr19xx.cpp | 193 | ||||
-rw-r--r-- | test/CXX/drs/dr1xx.cpp | 1060 | ||||
-rw-r--r-- | test/CXX/drs/dr20xx.cpp | 30 | ||||
-rw-r--r-- | test/CXX/drs/dr21xx.cpp | 40 | ||||
-rw-r--r-- | test/CXX/drs/dr22xx.cpp | 28 | ||||
-rw-r--r-- | test/CXX/drs/dr2xx.cpp | 1079 | ||||
-rw-r--r-- | test/CXX/drs/dr3xx.cpp | 1380 | ||||
-rw-r--r-- | test/CXX/drs/dr412.cpp | 21 | ||||
-rw-r--r-- | test/CXX/drs/dr4xx.cpp | 1229 | ||||
-rw-r--r-- | test/CXX/drs/dr5xx.cpp | 1016 | ||||
-rw-r--r-- | test/CXX/drs/dr6xx.cpp | 1122 | ||||
-rw-r--r-- | test/CXX/drs/dr7xx.cpp | 92 | ||||
-rw-r--r-- | test/CXX/drs/dr9xx.cpp | 75 |
26 files changed, 0 insertions, 10584 deletions
diff --git a/test/CXX/drs/dr0xx.cpp b/test/CXX/drs/dr0xx.cpp deleted file mode 100644 index 048187814db6..000000000000 --- a/test/CXX/drs/dr0xx.cpp +++ /dev/null @@ -1,1144 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -Wno-bind-to-temporary-copy -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple - -namespace dr1 { // dr1: no - namespace X { extern "C" void dr1_f(int a = 1); } - namespace Y { extern "C" void dr1_f(int a = 1); } - using X::dr1_f; using Y::dr1_f; - void g() { - dr1_f(0); - // FIXME: This should be rejected, due to the ambiguous default argument. - dr1_f(); - } - namespace X { - using Y::dr1_f; - void h() { - dr1_f(0); - // FIXME: This should be rejected, due to the ambiguous default argument. - dr1_f(); - } - } - - namespace X { - void z(int); - } - void X::z(int = 1) {} // expected-note {{previous}} - namespace X { - void z(int = 1); // expected-error {{redefinition of default argument}} - } - - void i(int = 1); - void j() { - void i(int = 1); - using dr1::i; - i(0); - // FIXME: This should be rejected, due to the ambiguous default argument. - i(); - } - void k() { - using dr1::i; - void i(int = 1); - i(0); - // FIXME: This should be rejected, due to the ambiguous default argument. - i(); - } -} - -namespace dr3 { // dr3: yes - template<typename T> struct A {}; - template<typename T> void f(T) { A<T> a; } // expected-note {{implicit instantiation}} - template void f(int); - template<> struct A<int> {}; // expected-error {{explicit specialization of 'dr3::A<int>' after instantiation}} -} - -namespace dr4 { // dr4: yes - extern "C" { - static void dr4_f(int) {} - static void dr4_f(float) {} - void dr4_g(int) {} // expected-note {{previous}} - void dr4_g(float) {} // expected-error {{conflicting types}} - } -} - -namespace dr5 { // dr5: yes - struct A {} a; - struct B { - B(const A&); - B(const B&); - }; - const volatile B b = a; - - struct C { C(C&); }; - struct D : C {}; - struct E { operator D&(); } e; - const C c = e; -} - -namespace dr7 { // dr7: yes - class A { public: ~A(); }; - class B : virtual private A {}; // expected-note 2 {{declared private here}} - class C : public B {} c; // expected-error 2 {{inherited virtual base class 'dr7::A' has private destructor}} \ - // expected-note {{implicit default constructor for 'dr7::C' first required here}} \ - // expected-note {{implicit destructor for 'dr7::C' first required here}} - class VeryDerivedC : public B, virtual public A {} vdc; - - class X { ~X(); }; // expected-note {{here}} - class Y : X { ~Y() {} }; // expected-error {{private destructor}} - - namespace PR16370 { // This regressed the first time DR7 was fixed. - struct S1 { virtual ~S1(); }; - struct S2 : S1 {}; - struct S3 : S2 {}; - struct S4 : virtual S2 {}; - struct S5 : S3, S4 { - S5(); - ~S5(); - }; - S5::S5() {} - } -} - -namespace dr8 { // dr8: dup 45 - class A { - struct U; - static const int k = 5; - void f(); - template<typename, int, void (A::*)()> struct T; - - T<U, k, &A::f> *g(); - }; - A::T<A::U, A::k, &A::f> *A::g() { return 0; } -} - -namespace dr9 { // dr9: yes - struct B { - protected: - int m; // expected-note {{here}} - friend int R1(); - }; - struct N : protected B { // expected-note 2{{protected}} - friend int R2(); - } n; - int R1() { return n.m; } // expected-error {{protected base class}} expected-error {{protected member}} - int R2() { return n.m; } -} - -namespace dr10 { // dr10: dup 45 - class A { - struct B { - A::B *p; - }; - }; -} - -namespace dr11 { // dr11: yes - template<typename T> struct A : T { - using typename T::U; - U u; - }; - template<typename T> struct B : T { - using T::V; - V v; // expected-error {{unknown type name}} - }; - struct X { typedef int U; }; - A<X> ax; -} - -namespace dr12 { // dr12: sup 239 - enum E { e }; - E &f(E, E = e); - void g() { - int &f(int, E = e); - // Under DR12, these call two different functions. - // Under DR239, they call the same function. - int &b = f(e); - int &c = f(1); - } -} - -namespace dr13 { // dr13: no - extern "C" void f(int); - void g(char); - - template<typename T> struct A { - A(void (*fp)(T)); - }; - template<typename T> int h(void (T)); - - A<int> a1(f); // FIXME: We should reject this. - A<char> a2(g); - int a3 = h(f); // FIXME: We should reject this. - int a4 = h(g); -} - -namespace dr14 { // dr14: yes - namespace X { extern "C" int dr14_f(); } - namespace Y { extern "C" int dr14_f(); } - using namespace X; - using namespace Y; - int k = dr14_f(); - - class C { - int k; - friend int Y::dr14_f(); - } c; - namespace Z { - extern "C" int dr14_f() { return c.k; } - } - - namespace X { typedef int T; typedef int U; } // expected-note {{candidate}} - namespace Y { typedef int T; typedef long U; } // expected-note {{candidate}} - T t; // ok, same type both times - U u; // expected-error {{ambiguous}} -} - -namespace dr15 { // dr15: yes - template<typename T> void f(int); // expected-note {{previous}} - template<typename T> void f(int = 0); // expected-error {{default arguments cannot be added}} -} - -namespace dr16 { // dr16: yes - class A { // expected-note {{here}} - void f(); // expected-note {{here}} - friend class C; - }; - class B : A {}; // expected-note 4{{here}} - class C : B { - void g() { - f(); // expected-error {{private member}} expected-error {{private base}} - A::f(); // expected-error {{private member}} expected-error {{private base}} - } - }; -} - -namespace dr17 { // dr17: yes - class A { - int n; - int f(); - struct C; - }; - struct B : A {} b; - int A::f() { return b.n; } - struct A::C : A { - int g() { return n; } - }; -} - -// dr18: sup 577 - -namespace dr19 { // dr19: yes - struct A { - int n; // expected-note {{here}} - }; - struct B : protected A { // expected-note {{here}} - }; - struct C : B {} c; - struct D : B { - int get1() { return c.n; } // expected-error {{protected member}} - int get2() { return ((A&)c).n; } // ok, A is an accessible base of B from here - }; -} - -namespace dr20 { // dr20: yes - class X { - public: - X(); - private: - X(const X&); // expected-note {{here}} - }; - X &f(); - X x = f(); // expected-error {{private}} -} - -namespace dr21 { // dr21: yes - template<typename T> struct A; - struct X { - template<typename T = int> friend struct A; // expected-error {{default template argument not permitted on a friend template}} - template<typename T = int> friend struct B; // expected-error {{default template argument not permitted on a friend template}} - }; -} - -namespace dr22 { // dr22: sup 481 - template<typename dr22_T = dr22_T> struct X; // expected-error {{unknown type name 'dr22_T'}} - typedef int T; - template<typename T = T> struct Y; -} - -namespace dr23 { // dr23: yes - template<typename T> void f(T, T); // expected-note {{candidate}} - template<typename T> void f(T, int); // expected-note {{candidate}} - void g() { f(0, 0); } // expected-error {{ambiguous}} -} - -// dr24: na - -namespace dr25 { // dr25: yes - struct A { - void f() throw(int); // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - }; - void (A::*f)() throw (int); // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void (A::*g)() throw () = f; -#if __cplusplus <= 201402L - // expected-error@-2 {{is not superset of source}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - void (A::*g2)() throw () = 0; - void (A::*h)() throw (int, char) = f; // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void (A::*i)() throw () = &A::f; -#if __cplusplus <= 201402L - // expected-error@-2 {{is not superset of source}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - void (A::*i2)() throw () = 0; - void (A::*j)() throw (int, char) = &A::f; // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void x() { - g2 = f; -#if __cplusplus <= 201402L - // expected-error@-2 {{is not superset of source}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - h = f; - i2 = &A::f; -#if __cplusplus <= 201402L - // expected-error@-2 {{is not superset of source}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - j = &A::f; - } -} - -namespace dr26 { // dr26: yes - struct A { A(A, const A & = A()); }; // expected-error {{must pass its first argument by reference}} - struct B { - B(); // expected-note 0-1{{candidate}} - B(const B &, B = B()); -#if __cplusplus <= 201402L - // expected-error@-2 {{no matching constructor}} expected-note@-2 {{candidate}} expected-note@-2 {{here}} -#endif - }; - struct C { - static C &f(); - C(const C &, C = f()); // expected-error {{no matching constructor}} expected-note {{candidate}} expected-note {{here}} - }; -} - -namespace dr27 { // dr27: yes - enum E { e } n; - E &m = true ? n : n; -} - -// dr28: na lib - -namespace dr29 { // dr29: 3.4 - void dr29_f0(); // expected-note {{here}} - void g0() { void dr29_f0(); } - extern "C++" void g0_cxx() { void dr29_f0(); } - extern "C" void g0_c() { void dr29_f0(); } // expected-error {{different language linkage}} - - extern "C" void dr29_f1(); // expected-note {{here}} - void g1() { void dr29_f1(); } - extern "C" void g1_c() { void dr29_f1(); } - extern "C++" void g1_cxx() { void dr29_f1(); } // expected-error {{different language linkage}} - - void g2() { void dr29_f2(); } // expected-note {{here}} - extern "C" void dr29_f2(); // expected-error {{different language linkage}} - - extern "C" void g3() { void dr29_f3(); } // expected-note {{here}} - extern "C++" void dr29_f3(); // expected-error {{different language linkage}} - - extern "C++" void g4() { void dr29_f4(); } // expected-note {{here}} - extern "C" void dr29_f4(); // expected-error {{different language linkage}} - - extern "C" void g5(); - extern "C++" void dr29_f5(); - void g5() { - void dr29_f5(); // ok, g5 is extern "C" but we're not inside the linkage-specification here. - } - - extern "C++" void g6(); - extern "C" void dr29_f6(); - void g6() { - void dr29_f6(); // ok, g6 is extern "C" but we're not inside the linkage-specification here. - } - - extern "C" void g7(); - extern "C++" void dr29_f7(); // expected-note {{here}} - extern "C" void g7() { - void dr29_f7(); // expected-error {{different language linkage}} - } - - extern "C++" void g8(); - extern "C" void dr29_f8(); // expected-note {{here}} - extern "C++" void g8() { - void dr29_f8(); // expected-error {{different language linkage}} - } -} - -namespace dr30 { // dr30: sup 468 c++11 - struct A { - template<int> static int f(); - } a, *p = &a; - int x = A::template f<0>(); - int y = a.template f<0>(); - int z = p->template f<0>(); -#if __cplusplus < 201103L - // FIXME: It's not clear whether DR468 applies to C++98 too. - // expected-error@-5 {{'template' keyword outside of a template}} - // expected-error@-5 {{'template' keyword outside of a template}} - // expected-error@-5 {{'template' keyword outside of a template}} -#endif -} - -namespace dr31 { // dr31: yes - class X { - private: - void operator delete(void*); // expected-note {{here}} - }; - // We would call X::operator delete if X() threw (even though it can't, - // and even though we allocated the X using ::operator delete). - X *p = new X; // expected-error {{private}} -} - -// dr32: na - -namespace dr33 { // dr33: yes - namespace X { struct S; void f(void (*)(S)); } // expected-note {{candidate}} - namespace Y { struct T; void f(void (*)(T)); } // expected-note {{candidate}} - void g(X::S); - template<typename Z> Z g(Y::T); - void h() { f(&g); } // expected-error {{ambiguous}} -} - -// dr34: na -// dr35: dup 178 -// dr37: sup 475 - -namespace dr38 { // dr38: yes - template<typename T> struct X {}; - template<typename T> X<T> operator+(X<T> a, X<T> b) { return a; } - template X<int> operator+<int>(X<int>, X<int>); -} - -namespace dr39 { // dr39: no - namespace example1 { - struct A { int &f(int); }; - struct B : A { - using A::f; - float &f(float); - } b; - int &r = b.f(0); - } - - namespace example2 { - struct A { - int &x(int); // expected-note {{found}} - static int &y(int); // expected-note {{found}} - }; - struct V { - int &z(int); - }; - struct B : A, virtual V { - using A::x; // expected-note {{found}} - float &x(float); - using A::y; // expected-note {{found}} - static float &y(float); - using V::z; - float &z(float); - }; - 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}} - int &x = c.x(0); // expected-error {{found in multiple base classes}} - // FIXME: This is valid, because we find the same static data member either way. - int &y = c.y(0); // expected-error {{found in multiple base classes}} - int &z = c.z(0); - } - - namespace example3 { - struct A { static int f(); }; - struct B : virtual A { using A::f; }; - struct C : virtual A { using A::f; }; - struct D : B, C {} d; - int k = d.f(); - } - - namespace example4 { - struct A { int n; }; // expected-note {{found}} - struct B : A {}; - struct C : A {}; - struct D : B, C { int f() { return n; } }; // expected-error {{found in multiple base-class}} - } - - namespace PR5916 { - // FIXME: This is valid. - struct A { int n; }; // expected-note +{{found}} - struct B : A {}; - struct C : A {}; - struct D : B, C {}; - int k = sizeof(D::n); // expected-error {{found in multiple base}} expected-error {{unknown type name}} -#if __cplusplus >= 201103L - decltype(D::n) n; // expected-error {{found in multiple base}} -#endif - } -} - -// dr40: na - -namespace dr41 { // dr41: yes - struct S f(S); -} - -namespace dr42 { // dr42: yes - struct A { static const int k = 0; }; - struct B : A { static const int k = A::k; }; -} - -// dr43: na - -namespace dr44 { // dr44: sup 727 - struct A { - template<int> void f(); - template<> void f<0>(); - }; -} - -namespace dr45 { // dr45: yes - class A { - class B {}; - class C : B {}; - C c; - }; -} - -namespace dr46 { // dr46: yes - template<typename> struct A { template<typename> struct B {}; }; - template template struct A<int>::B<int>; // expected-error {{expected unqualified-id}} -} - -namespace dr47 { // dr47: sup 329 - template<typename T> struct A { - friend void f() { T t; } // expected-error {{redefinition}} expected-note {{previous}} - }; - A<int> a; - A<float> b; // expected-note {{instantiation of}} - - void f(); - void g() { f(); } -} - -namespace dr48 { // dr48: yes - namespace { - struct S { - static const int m = 0; - static const int n = 0; - static const int o = 0; - }; - } - int a = S::m; - // FIXME: We should produce a 'has internal linkage but is not defined' - // diagnostic for 'S::n'. - const int &b = S::n; - const int S::o; - const int &c = S::o; -} - -namespace dr49 { // dr49: yes - template<int*> struct A {}; // expected-note 0-2{{here}} - int k; -#if __has_feature(cxx_constexpr) - constexpr -#endif - int *const p = &k; // expected-note 0-2{{here}} - A<&k> a; - A<p> b; -#if __cplusplus <= 201402L - // expected-error@-2 {{must have its address taken}} -#endif -#if __cplusplus < 201103L - // expected-error@-5 {{internal linkage}} -#endif - int *q = &k; - A<q> c; -#if __cplusplus < 201103L - // expected-error@-2 {{must have its address taken}} -#else - // expected-error@-4 {{constant expression}} - // expected-note@-5 {{read of non-constexpr}} - // expected-note@-7 {{declared here}} -#endif -} - -namespace dr50 { // dr50: yes - struct X; // expected-note {{forward}} - extern X *p; - X *q = (X*)p; - X *r = static_cast<X*>(p); - X *s = const_cast<X*>(p); - X *t = reinterpret_cast<X*>(p); - X *u = dynamic_cast<X*>(p); // expected-error {{incomplete}} -} - -namespace dr51 { // dr51: yes - struct A {}; - struct B : A {}; - struct S { - operator A&(); - operator B&(); - } s; - A &a = s; -} - -namespace dr52 { // dr52: yes - struct A { int n; }; // expected-note {{here}} - struct B : private A {} b; // expected-note 2{{private}} - // FIXME: This first diagnostic is very strangely worded, and seems to be bogus. - int k = b.A::n; // expected-error {{'A' is a private member of 'dr52::A'}} - // expected-error@-1 {{cannot cast 'struct B' to its private base}} -} - -namespace dr53 { // dr53: yes - int n = 0; - enum E { e } x = static_cast<E>(n); -} - -namespace dr54 { // dr54: yes - struct A { int a; } a; - struct V { int v; } v; - struct B : private A, virtual V { int b; } b; // expected-note 6{{private here}} - - A &sab = static_cast<A&>(b); // expected-error {{private base}} - A *spab = static_cast<A*>(&b); // expected-error {{private base}} - int A::*smab = static_cast<int A::*>(&B::b); // expected-error {{private base}} - B &sba = static_cast<B&>(a); // expected-error {{private base}} - B *spba = static_cast<B*>(&a); // expected-error {{private base}} - int B::*smba = static_cast<int B::*>(&A::a); // expected-error {{private base}} - - V &svb = static_cast<V&>(b); - V *spvb = static_cast<V*>(&b); - int V::*smvb = static_cast<int V::*>(&B::b); // expected-error {{virtual base}} - B &sbv = static_cast<B&>(v); // expected-error {{virtual base}} - B *spbv = static_cast<B*>(&v); // expected-error {{virtual base}} - int B::*smbv = static_cast<int B::*>(&V::v); // expected-error {{virtual base}} - - A &cab = (A&)(b); - A *cpab = (A*)(&b); - int A::*cmab = (int A::*)(&B::b); - B &cba = (B&)(a); - B *cpba = (B*)(&a); - int B::*cmba = (int B::*)(&A::a); - - V &cvb = (V&)(b); - V *cpvb = (V*)(&b); - int V::*cmvb = (int V::*)(&B::b); // expected-error {{virtual base}} - B &cbv = (B&)(v); // expected-error {{virtual base}} - B *cpbv = (B*)(&v); // expected-error {{virtual base}} - int B::*cmbv = (int B::*)(&V::v); // expected-error {{virtual base}} -} - -namespace dr55 { // dr55: yes - enum E { e = 5 }; - int test[(e + 1 == 6) ? 1 : -1]; -} - -namespace dr56 { // dr56: yes - struct A { - typedef int T; // expected-note {{previous}} - typedef int T; // expected-error {{redefinition}} - }; - struct B { - struct X; - typedef X X; // expected-note {{previous}} - typedef X X; // expected-error {{redefinition}} - }; -} - -namespace dr58 { // dr58: yes - // FIXME: Ideally, we should have a CodeGen test for this. -#if __cplusplus >= 201103L - enum E1 { E1_0 = 0, E1_1 = 1 }; - enum E2 { E2_0 = 0, E2_m1 = -1 }; - struct X { E1 e1 : 1; E2 e2 : 1; }; - static_assert(X{E1_1, E2_m1}.e1 == 1, ""); - static_assert(X{E1_1, E2_m1}.e2 == -1, ""); -#endif -} - -namespace dr59 { // dr59: yes - template<typename T> struct convert_to { operator T() const; }; - struct A {}; // expected-note 5+{{candidate}} - struct B : A {}; // expected-note 0+{{candidate}} - - A a1 = convert_to<A>(); - A a2 = convert_to<A&>(); - A a3 = convert_to<const A>(); - A a4 = convert_to<const volatile A>(); -#if __cplusplus <= 201402L - // expected-error@-2 {{no viable}} -#endif - A a5 = convert_to<const volatile A&>(); // expected-error {{no viable}} - - B b1 = convert_to<B>(); - B b2 = convert_to<B&>(); - B b3 = convert_to<const B>(); - B b4 = convert_to<const volatile B>(); -#if __cplusplus <= 201402L - // expected-error@-2 {{no viable}} -#endif - B b5 = convert_to<const volatile B&>(); // expected-error {{no viable}} - - A c1 = convert_to<B>(); - A c2 = convert_to<B&>(); - A c3 = convert_to<const B>(); - A c4 = convert_to<const volatile B>(); // expected-error {{no viable}} - A c5 = convert_to<const volatile B&>(); // expected-error {{no viable}} - - int n1 = convert_to<int>(); - int n2 = convert_to<int&>(); - int n3 = convert_to<const int>(); - int n4 = convert_to<const volatile int>(); - int n5 = convert_to<const volatile int&>(); -} - -namespace dr60 { // dr60: yes - void f(int &); - int &f(...); - const int k = 0; - int &n = f(k); -} - -namespace dr61 { // dr61: yes - struct X { - static void f(); - } x; - struct Y { - static void f(); - static void f(int); - } y; - // This is (presumably) valid, because x.f does not refer to an overloaded - // function name. - void (*p)() = &x.f; - void (*q)() = &y.f; // expected-error {{cannot create a non-constant pointer to member function}} - void (*r)() = y.f; // expected-error {{cannot create a non-constant pointer to member function}} -} - -namespace dr62 { // dr62: yes - struct A { - struct { int n; } b; - }; - template<typename T> struct X {}; - template<typename T> T get() { return get<T>(); } - template<typename T> int take(T) { return 0; } - - X<A> x1; - A a = get<A>(); - - typedef struct { } *NoNameForLinkagePtr; -#if __cplusplus < 201103L - // expected-note@-2 5{{here}} -#endif - NoNameForLinkagePtr noNameForLinkagePtr; - - struct Danger { - NoNameForLinkagePtr p; - }; - - X<NoNameForLinkagePtr> x2; - X<const NoNameForLinkagePtr> x3; - NoNameForLinkagePtr p1 = get<NoNameForLinkagePtr>(); - NoNameForLinkagePtr p2 = get<const NoNameForLinkagePtr>(); - int n1 = take(noNameForLinkagePtr); -#if __cplusplus < 201103L - // expected-error@-6 {{uses unnamed type}} - // expected-error@-6 {{uses unnamed type}} - // expected-error@-6 {{uses unnamed type}} - // expected-error@-6 {{uses unnamed type}} - // expected-error@-6 {{uses unnamed type}} -#endif - - X<Danger> x4; - - void f() { - struct NoLinkage {}; - X<NoLinkage> a; - X<const NoLinkage> b; - get<NoLinkage>(); - get<const NoLinkage>(); - X<void (*)(NoLinkage A::*)> c; - X<int NoLinkage::*> d; -#if __cplusplus < 201103L - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} -#endif - } -} - -namespace dr63 { // dr63: yes - template<typename T> struct S { typename T::error e; }; - extern S<int> *p; - void *q = p; -} - -namespace dr64 { // dr64: yes - template<class T> void f(T); - template<class T> void f(T*); - template<> void f(int*); - template<> void f<int>(int*); - template<> void f(int); -} - -// dr65: na - -namespace dr66 { // dr66: no - namespace X { - int f(int n); // expected-note 2{{candidate}} - } - using X::f; - namespace X { - int f(int n = 0); - int f(int, int); - } - // FIXME: The first two calls here should be accepted. - int a = f(); // expected-error {{no matching function}} - int b = f(1); - int c = f(1, 2); // expected-error {{no matching function}} -} - -// dr67: na - -namespace dr68 { // dr68: yes - template<typename T> struct X {}; - struct ::dr68::X<int> x1; - struct ::dr68::template X<int> x2; -#if __cplusplus < 201103L - // expected-error@-2 {{'template' keyword outside of a template}} -#endif - struct Y { - friend struct X<int>; - friend struct ::dr68::X<char>; - friend struct ::dr68::template X<double>; -#if __cplusplus < 201103L - // expected-error@-2 {{'template' keyword outside of a template}} -#endif - }; - template<typename> - struct Z { - friend struct ::dr68::template X<double>; - friend typename ::dr68::X<double>; -#if __cplusplus < 201103L - // expected-error@-2 {{C++11 extension}} -#endif - }; -} - -namespace dr69 { // dr69: yes - template<typename T> static void f() {} - // FIXME: Should we warn here? - inline void g() { f<int>(); } - // FIXME: This should be rejected, per [temp.explicit]p11. - extern template void f<char>(); -#if __cplusplus < 201103L - // expected-error@-2 {{C++11 extension}} -#endif - template<void(*)()> struct Q {}; - Q<&f<int> > q; -#if __cplusplus < 201103L - // expected-error@-2 {{internal linkage}} expected-note@-11 {{here}} -#endif -} - -namespace dr70 { // dr70: yes - template<int> struct A {}; - template<int I, int J> int f(int (&)[I + J], A<I>, A<J>); - int arr[7]; - int k = f(arr, A<3>(), A<4>()); -} - -// dr71: na -// dr72: dup 69 - -#if __cplusplus >= 201103L -namespace dr73 { // dr73: no - // The resolution to dr73 is unworkable. Consider: - int a, b; - static_assert(&a + 1 != &b, ""); // expected-error {{not an integral constant expression}} -} -#endif - -namespace dr74 { // dr74: yes - enum E { k = 5 }; - int (*p)[k] = new int[k][k]; -} - -namespace dr75 { // dr75: yes - struct S { - static int n = 0; // expected-error {{non-const}} - }; -} - -namespace dr76 { // dr76: yes - const volatile int n = 1; - int arr[n]; // expected-error +{{variable length array}} -} - -namespace dr77 { // dr77: yes - struct A { - struct B {}; - friend struct B; - }; -} - -namespace dr78 { // dr78: sup ???? - // Under DR78, this is valid, because 'k' has static storage duration, so is - // zero-initialized. - const int k; // expected-error {{default initialization of an object of const}} -} - -// dr79: na - -namespace dr80 { // dr80: yes - struct A { - int A; - }; - struct B { - static int B; // expected-error {{same name as its class}} - }; - struct C { - int C; // expected-error {{same name as its class}} - C(); - }; - struct D { - D(); - int D; // expected-error {{same name as its class}} - }; -} - -// dr81: na -// dr82: dup 48 - -namespace dr83 { // dr83: yes - int &f(const char*); - char &f(char *); - int &k = f("foo"); -} - -namespace dr84 { // dr84: yes - struct B; - struct A { operator B() const; }; - struct C {}; - struct B { - B(B&); // expected-note 0-1{{candidate}} - B(C); // expected-note 0-1{{no known conversion from 'dr84::B' to 'dr84::C'}} - operator C() const; - }; - A a; - // Cannot use B(C) / operator C() pair to construct the B from the B temporary - // here. In C++17, we initialize the B object directly using 'A::operator B()'. - B b = a; -#if __cplusplus <= 201402L - // expected-error@-2 {{no viable}} -#endif -} - -namespace dr85 { // dr85: yes - struct A { - struct B; - struct B {}; // expected-note{{previous declaration is here}} - struct B; // expected-error{{class member cannot be redeclared}} - - union U; - union U {}; // expected-note{{previous declaration is here}} - union U; // expected-error{{class member cannot be redeclared}} - -#if __cplusplus >= 201103L - enum E1 : int; - enum E1 : int { e1 }; // expected-note{{previous declaration is here}} - enum E1 : int; // expected-error{{class member cannot be redeclared}} - - enum class E2; - enum class E2 { e2 }; // expected-note{{previous declaration is here}} - enum class E2; // expected-error{{class member cannot be redeclared}} -#endif - }; - - template <typename T> - struct C { - struct B {}; // expected-note{{previous declaration is here}} - struct B; // expected-error{{class member cannot be redeclared}} - }; -} - -// dr86: dup 446 - -namespace dr87 { // dr87: no - // FIXME: Superseded by dr1975 - template<typename T> struct X {}; - // FIXME: This is invalid. - X<void() throw()> x; - // This is valid under dr87 but not under dr1975. - X<void(void() throw())> y; -} - -namespace dr88 { // dr88: yes - template<typename T> struct S { - static const int a = 1; // expected-note {{previous}} - static const int b; - }; - template<> const int S<int>::a = 4; // expected-error {{already has an initializer}} - template<> const int S<int>::b = 4; -} - -// dr89: na - -namespace dr90 { // dr90: yes - struct A { - template<typename T> friend void dr90_f(T); - }; - struct B : A { - template<typename T> friend void dr90_g(T); - struct C {}; - union D {}; - }; - struct E : B {}; - struct F : B::C {}; - - void test() { - dr90_f(A()); - dr90_f(B()); - dr90_f(B::C()); // expected-error {{undeclared identifier}} - dr90_f(B::D()); // expected-error {{undeclared identifier}} - dr90_f(E()); - dr90_f(F()); // expected-error {{undeclared identifier}} - - dr90_g(A()); // expected-error {{undeclared identifier}} - dr90_g(B()); - dr90_g(B::C()); - dr90_g(B::D()); - dr90_g(E()); - dr90_g(F()); // expected-error {{undeclared identifier}} - } -} - -namespace dr91 { // dr91: yes - union U { friend int f(U); }; - int k = f(U()); -} - -namespace dr92 { // dr92: 4 c++17 - void f() throw(int, float); // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void (*p)() throw(int) = &f; // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} -#if __cplusplus <= 201402L - // expected-error@-2 {{target exception specification is not superset of source}} -#else - // expected-warning@-4 {{target exception specification is not superset of source}} -#endif - void (*q)() throw(int); // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void (**pp)() throw() = &q; -#if __cplusplus <= 201402L - // expected-error@-2 {{exception specifications are not allowed}} -#else - // expected-error@-4 {{cannot initialize}} -#endif - - void g(void() throw()); // expected-note 0-2 {{no known conversion}} expected-warning 0-1{{mangled name of 'g' will change in C++17}} - void h() throw() { - g(f); // expected-error-re {{{{is not superset|no matching function}}}} - g(q); // expected-error-re {{{{is not superset|no matching function}}}} - } - - // Prior to C++17, this is OK because the exception specification is not - // considered in this context. In C++17, we *do* perform an implicit - // conversion (which performs initialization), and the exception specification - // is part of the type of the parameter, so this is invalid. - template<void() throw()> struct X {}; - X<&f> xp; -#if __cplusplus > 201402L - // expected-error@-2 {{not implicitly convertible}} -#endif - - template<void() throw(int)> struct Y {}; // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - Y<&h> yp; // ok -} - -// dr93: na - -namespace dr94 { // dr94: yes - struct A { static const int n = 5; }; - int arr[A::n]; -} - -namespace dr95 { // dr95: yes - struct A; - struct B; - namespace N { - class C { - friend struct A; - friend struct B; - static void f(); // expected-note {{here}} - }; - struct A *p; // dr95::A, not dr95::N::A. - } - A *q = N::p; // ok, same type - struct B { void f() { N::C::f(); } }; // expected-error {{private}} -} - -namespace dr96 { // dr96: no - struct A { - void f(int); - template<typename T> int f(T); - template<typename T> struct S {}; - } a; - template<template<typename> class X> struct B {}; - - template<typename T> - void test() { - int k1 = a.template f<int>(0); - // FIXME: This is ill-formed, because 'f' is not a template-id and does not - // name a class template. - // FIXME: What about alias templates? - int k2 = a.template f(1); - A::template S<int> s; - B<A::template S> b; - } -} - -namespace dr97 { // dr97: yes - struct A { - static const int a = false; - static const int b = !a; - }; -} - -namespace dr98 { // dr98: yes - void test(int n) { - switch (n) { - try { // expected-note 2{{bypasses}} - case 0: // expected-error {{cannot jump}} - x: - throw n; - } catch (...) { // expected-note 2{{bypasses}} - case 1: // expected-error {{cannot jump}} - y: - throw n; - } - case 2: - goto x; // expected-error {{cannot jump}} - case 3: - goto y; // expected-error {{cannot jump}} - } - } -} - -namespace dr99 { // dr99: sup 214 - template<typename T> void f(T&); - template<typename T> int &f(const T&); - const int n = 0; - int &r = f(n); -} diff --git a/test/CXX/drs/dr10xx.cpp b/test/CXX/drs/dr10xx.cpp deleted file mode 100644 index 7f5fd8c7ec27..000000000000 --- a/test/CXX/drs/dr10xx.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace std { - __extension__ typedef __SIZE_TYPE__ size_t; - - template<typename T> struct initializer_list { - const T *p; size_t n; - initializer_list(const T *p, size_t n); - }; -} - -namespace dr1004 { // dr1004: 5 - template<typename> struct A {}; - template<typename> struct B1 {}; - template<template<typename> class> struct B2 {}; - template<typename X> void f(); // expected-note {{[with X = dr1004::A<int>]}} - template<template<typename> class X> void f(); // expected-note {{[with X = A]}} - template<template<typename> class X> void g(); // expected-note {{[with X = A]}} - template<typename X> void g(); // expected-note {{[with X = dr1004::A<int>]}} - struct C : A<int> { - B1<A> b1a; - B2<A> b2a; - void h() { - f<A>(); // expected-error {{ambiguous}} - g<A>(); // expected-error {{ambiguous}} - } - }; - - // This example (from the standard) is actually ill-formed, because - // name lookup of "T::template A" names the constructor. - template<class T, template<class> class U = T::template A> struct Third { }; // expected-error {{is a constructor name}} - Third<A<int> > t; // expected-note {{in instantiation of default argument}} -} - -namespace dr1048 { // dr1048: 3.6 - struct A {}; - const A f(); - A g(); - typedef const A CA; -#if __cplusplus >= 201103L - // ok: we deduce non-const A in each case. - A &&a = [] (int n) { - while (1) switch (n) { - case 0: return f(); - case 1: return g(); - case 2: return A(); - case 3: return CA(); - } - } (0); -#endif -} - -namespace dr1054 { // dr1054: no - // FIXME: Test is incomplete. - struct A {} volatile a; - void f() { - // FIXME: This is wrong: an lvalue-to-rvalue conversion is applied here, - // which copy-initializes a temporary from 'a'. Therefore this is - // ill-formed because A does not have a volatile copy constructor. - // (We might want to track this aspect under dr1383 instead?) - a; // expected-warning {{assign into a variable to force a volatile load}} - } -} - -namespace dr1070 { // dr1070: 3.5 -#if __cplusplus >= 201103L - struct A { - A(std::initializer_list<int>); - }; - struct B { - int i; - A a; - }; - B b = {1}; - struct C { - std::initializer_list<int> a; - B b; - std::initializer_list<double> c; - }; - C c = {}; -#endif -} diff --git a/test/CXX/drs/dr118.cpp b/test/CXX/drs/dr118.cpp deleted file mode 100644 index 58aa3912c801..000000000000 --- a/test/CXX/drs/dr118.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-linux -std=c++98 %s -pedantic-errors -emit-llvm -o - | FileCheck %s --implicit-check-not " call " -// RUN: %clang_cc1 -triple x86_64-linux -std=c++11 %s -pedantic-errors -emit-llvm -o - | FileCheck %s --implicit-check-not " call " -// RUN: %clang_cc1 -triple x86_64-linux -std=c++14 %s -pedantic-errors -emit-llvm -o - | FileCheck %s --implicit-check-not " call " -// RUN: %clang_cc1 -triple x86_64-linux -std=c++1z %s -pedantic-errors -emit-llvm -o - | FileCheck %s --implicit-check-not " call " - -// dr118: yes - -struct S { - virtual void f(); -}; -void (S::*pmf)(); - -// CHECK-LABEL: define {{.*}} @_Z1g -void g(S *sp) { - // CHECK: call void % - sp->f(); // 1: polymorphic - // CHECK: call void @ - sp->S::f(); // 2: non-polymorphic - // CHECK: call void @ - (sp->S::f)(); // 3: non-polymorphic - // CHECK: call void % - (sp->*pmf)(); // 4: polymorphic - // CHECK: call void % - (sp->*&S::f)(); // 5: polymorphic -} - diff --git a/test/CXX/drs/dr11xx.cpp b/test/CXX/drs/dr11xx.cpp deleted file mode 100644 index 81fbc1e3ef1b..000000000000 --- a/test/CXX/drs/dr11xx.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr1113 { // dr1113: partial - namespace named { - extern int a; // expected-note {{previous}} - static int a; // expected-error {{static declaration of 'a' follows non-static}} - } - namespace { - extern int a; - static int a; // ok, both declarations have internal linkage - int b = a; - } - - // FIXME: Per DR1113 and DR4, this is ill-formed due to ambiguity: the second - // 'f' has internal linkage, and so does not have C language linkage, so is - // not a redeclaration of the first 'f'. - // - // To avoid a breaking change here, Clang ignores the "internal linkage" effect - // of anonymous namespaces on declarations declared within an 'extern "C"' - // linkage-specification. - extern "C" void f(); - namespace { - extern "C" void f(); - } - void g() { f(); } -} diff --git a/test/CXX/drs/dr12xx.cpp b/test/CXX/drs/dr12xx.cpp deleted file mode 100644 index 1bc4c3973443..000000000000 --- a/test/CXX/drs/dr12xx.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr1213 { // dr1213: 7 -#if __cplusplus >= 201103L - using T = int[3]; - int &&r = T{}[1]; - - using T = decltype((T{})); - using U = decltype((T{}[2])); - using U = int &&; - - // Same thing but in a case where we consider overloaded operator[]. - struct ConvertsToInt { - operator int(); - }; - struct X { int array[1]; }; - using U = decltype(X().array[ConvertsToInt()]); - - // We apply the same rule to vector subscripting. - typedef int V4Int __attribute__((__vector_size__(sizeof(int) * 4))); - typedef int EV4Int __attribute__((__ext_vector_type__(4))); - using U = decltype(V4Int()[0]); - using U = decltype(EV4Int()[0]); -#endif -} - -namespace dr1250 { // dr1250: 3.9 -struct Incomplete; - -struct Base { - virtual const Incomplete *meow() = 0; -}; - -struct Derived : Base { - virtual Incomplete *meow(); -}; -} - -namespace dr1265 { // dr1265: 5 -#if __cplusplus >= 201103L - auto a = 0, b() -> int; // expected-error {{declaration with trailing return type must be the only declaration in its group}} - auto b() -> int, d = 0; // expected-error {{declaration with trailing return type must be the only declaration in its group}} - auto e() -> int, f() -> int; // expected-error {{declaration with trailing return type must be the only declaration in its group}} -#endif - -#if __cplusplus >= 201402L - auto g(), h = 0; // expected-error {{function with deduced return type must be the only declaration in its group}} - auto i = 0, j(); // expected-error {{function with deduced return type must be the only declaration in its group}} - auto k(), l(); // expected-error {{function with deduced return type must be the only declaration in its group}} -#endif -} - -namespace dr1295 { // dr1295: 4 - struct X { - unsigned bitfield : 4; - }; - - X x = {1}; - - unsigned const &r1 = static_cast<X &&>(x).bitfield; // expected-error 0-1{{C++11}} - unsigned const &r2 = static_cast<unsigned &&>(x.bitfield); // expected-error 0-1{{C++11}} - - template<unsigned &r> struct Y {}; - Y<x.bitfield> y; -#if __cplusplus <= 201402L - // expected-error@-2 {{does not refer to any declaration}} expected-note@-3 {{here}} -#else - // expected-error@-4 {{refers to subobject}} -#endif - -#if __cplusplus >= 201103L - const unsigned other = 0; - using T = decltype(true ? other : x.bitfield); - using T = unsigned; -#endif -} - diff --git a/test/CXX/drs/dr13xx.cpp b/test/CXX/drs/dr13xx.cpp deleted file mode 100644 index 208ab8a03b0a..000000000000 --- a/test/CXX/drs/dr13xx.cpp +++ /dev/null @@ -1,414 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -__extension__ typedef __SIZE_TYPE__ size_t; - -namespace std { - template<typename T> struct initializer_list { - const T *ptr; - size_t n; - initializer_list(const T*, size_t); - }; -} - -namespace dr1310 { // dr1310: 5 - struct S {} * sp = new S::S; // expected-error {{qualified reference to 'S' is a constructor name}} - void f() { - S::S(a); // expected-error {{qualified reference to 'S' is a constructor name}} - } - struct T { int n; typedef int U; typedef T V; }; - int k = T().T::T::n; - T::V v; - - struct U { int U; }; - int u = U().U::U; - struct U::U w; - - struct V : T::T { - // FIXME: This is technically ill-formed, but we consider that to be a defect. - V() : T::T() {} - }; - template<typename T> struct VT : T::T { - VT() : T::T() {} - }; - template struct VT<T>; - - template<template<typename> class> class TT {}; - template<typename> class TTy {}; - - template<typename T> struct WBase {}; - template<typename T> struct W : WBase<T> { typedef int X; int n; }; - - void w_test() { - W<int>::W w1a; // expected-error {{qualified reference to 'W' is a constructor name}} - W<int>::W::X w1ax; - W<int>::W<int> w1b; // expected-error {{qualified reference to 'W' is a constructor name}} - W<int>::W<int>::X w1bx; - typename W<int>::W w2a; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-1{{outside of a template}} - typename W<int>::W::X w2ax; // expected-error 0-1{{outside of a template}} - typename W<int>::W<int> w2b; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-1{{outside of a template}} - typename W<int>::W<int>::X w2bx; // expected-error 0-1{{outside of a template}} - W<int>::template W<int> w3; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-1{{outside of a template}} - W<int>::template W<int>::X w3x; // expected-error 0-1{{outside of a template}} - typename W<int>::template W<int> w4; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-2{{outside of a template}} - typename W<int>::template W<int>::X w4x; // expected-error 0-2{{outside of a template}} - - TT<W<int>::W> tt1; // expected-error {{qualified reference to 'W' is a constructor name}} - TTy<W<int>::W> tt1a; // expected-error {{qualified reference to 'W' is a constructor name}} - TT<W<int>::template W> tt2; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-1{{outside of a template}} - TT<W<int>::WBase> tt3; - TTy<W<int>::WBase> tt3a; - TT<W<int>::template WBase> tt4; // expected-error 0-1{{outside of a template}} - - W<int> w; - (void)w.W::W::n; - (void)w.W<int>::W::n; - (void)w.W<int>::W<int>::n; - (void)w.W<int>::template W<int>::n; // expected-error 0-1{{outside of a template}} - } - - template<typename W> - void wt_test() { - typename W::W w2a; // expected-error {{qualified reference to 'W' is a constructor name}} - typename W::template W<int> w4; // expected-error {{qualified reference to 'W' is a constructor name}} - TTy<typename W::W> tt2; // expected-error {{qualified reference to 'W' is a constructor name}} - TT<W::template W> tt3; // expected-error {{qualified reference to 'W' is a constructor name}} - } - template<typename W> - void wt_test_good() { - typename W::W::X w2ax; - typename W::template W<int>::X w4x; - TTy<typename W::WBase> tt4; - TT<W::template WBase> tt5; - - W w; - (void)w.W::W::n; - (void)w.W::template W<int>::n; - (void)w.template W<int>::W::n; - (void)w.template W<int>::template W<int>::n; - } - template void wt_test<W<int> >(); // expected-note {{instantiation of}} - template void wt_test_good<W<int> >(); -} - -namespace dr1315 { // dr1315: partial - template <int I, int J> struct A {}; - template <int I> // expected-note {{non-deducible template parameter 'I'}} - struct A<I + 5, I * 2> {}; // expected-error {{contains a template parameter that cannot be deduced}} - template <int I> struct A<I, I> {}; - - template <int I, int J, int K> struct B; - template <int I, int K> struct B<I, I * 2, K> {}; // expected-note {{matches}} - B<1, 2, 3> b1; - - // Multiple declarations with the same dependent expression are equivalent - // for partial ordering purposes. - template <int I> struct B<I, I * 2, 2> { typedef int type; }; - B<1, 2, 2>::type b2; - - // Multiple declarations with differing dependent expressions are unordered. - template <int I, int K> struct B<I, I + 1, K> {}; // expected-note {{matches}} - B<1, 2, 4> b3; // expected-error {{ambiguous}} - - // FIXME: Under dr1315, this is perhaps valid, but that is not clear: this - // fails the "more specialized than the primary template" test because the - // dependent type of T::value is not the same as 'int'. - // A core issue will be opened to decide what is supposed to happen here. - template <typename T, int I> struct C; - template <typename T> struct C<T, T::value>; - // expected-error@-1 {{type of specialized non-type template argument depends on a template parameter of the partial specialization}} -} - -namespace dr1330 { // dr1330: 4 c++11 - // exception-specifications are parsed in a context where the class is complete. - struct A { - void f() throw(T) {} // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} - struct T {}; - -#if __cplusplus >= 201103L - void g() noexcept(&a == b) {} - static int a; - static constexpr int *b = &a; -#endif - }; - - void (A::*af1)() throw(A::T) = &A::f; // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} - void (A::*af2)() throw() = &A::f; // expected-error-re {{{{not superset|different exception spec}}}} - -#if __cplusplus >= 201103L - static_assert(noexcept(A().g()), ""); -#endif - - // Likewise, they're instantiated separately from an enclosing class template. - template<typename U> - struct B { - void f() throw(T, typename U::type) {} // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} - struct T {}; - -#if __cplusplus >= 201103L - void g() noexcept(&a == b && U::value) {} - static int a; - static constexpr int *b = &a; -#endif - }; - - B<int> bi; // ok - - struct P { - typedef int type; - static const int value = true; - }; - - void (B<P>::*bpf1)() throw(B<P>::T, int) = &B<P>::f; // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} -#if __cplusplus < 201103L - // expected-error@-2 {{not superset}} - // FIXME: We only delay instantiation in C++11 onwards. In C++98, something - // weird happens: instantiation of B<P> fails because it references T before - // it's instantiated, but the diagnostic is suppressed in - // Sema::FindInstantiatedDecl because we've already hit an error. This is - // obviously a bad way to react to this situation; we should still producing - // the "T has not yet been instantiated" error here, rather than giving - // confusing errors later on. -#endif - void (B<P>::*bpf2)() throw(int) = &B<P>::f; // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} -#if __cplusplus <= 201402L - // expected-error@-2 {{not superset}} -#else - // expected-warning@-4 {{not superset}} -#endif - void (B<P>::*bpf3)() = &B<P>::f; - void (B<P>::*bpf4)() throw() = &B<P>::f; -#if __cplusplus <= 201402L - // expected-error@-2 {{not superset}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - -#if __cplusplus >= 201103L - static_assert(noexcept(B<P>().g()), ""); - struct Q { static const int value = false; }; - static_assert(!noexcept(B<Q>().g()), ""); -#endif - - template<typename T> int f() throw(typename T::error) { return 0; } // expected-error 1-4{{prior to '::'}} expected-note 0-1{{prior to '::'}} expected-note 0-1{{requested here}} -#if __cplusplus > 201402L - // expected-error@-2 0-1{{C++17}} expected-note@-2 0-1{{noexcept}} -#endif - // An exception-specification is needed even if the function is only used in - // an unevaluated operand. - int f1 = sizeof(f<int>()); // expected-note {{instantiation of}} -#if __cplusplus >= 201103L - decltype(f<char>()) f2; // expected-note {{instantiation of}} - bool f3 = noexcept(f<float>()); // expected-note {{instantiation of}} -#endif - // In C++17 onwards, substituting explicit template arguments into the - // function type substitutes into the exception specification (because it's - // part of the type). In earlier languages, we don't notice there's a problem - // until we've already started to instantiate. - template int f<short>(); -#if __cplusplus >= 201703L - // expected-error@-2 {{does not refer to a function template}} -#else - // expected-note@-4 {{instantiation of}} -#endif - - template<typename T> struct C { - C() throw(typename T::type); // expected-error 1-2{{prior to '::'}} -#if __cplusplus > 201402L - // expected-error@-2 0-1{{C++17}} expected-note@-2 0-1{{noexcept}} -#endif - }; - struct D : C<void> {}; // ok -#if __cplusplus < 201103L - // expected-note@-2 {{instantiation of}} -#endif - void f(D &d) { d = d; } // ok - - struct E : C<int> {}; // expected-note {{in instantiation of}} -#if __cplusplus >= 201103L - E e; // expected-note {{needed here}} -#endif -} - -namespace dr1346 { // dr1346: 3.5 - auto a(1); // expected-error 0-1{{extension}} - auto b(1, 2); // expected-error {{multiple expressions}} expected-error 0-1{{extension}} -#if __cplusplus >= 201103L - auto c({}); // expected-error {{parenthesized initializer list}} - auto d({1}); // expected-error {{parenthesized initializer list}} - auto e({1, 2}); // expected-error {{parenthesized initializer list}} -#endif - template<typename...Ts> void f(Ts ...ts) { // expected-error 0-1{{extension}} - auto x(ts...); // expected-error {{empty}} expected-error 0-1{{extension}} - } - template void f(); // expected-note {{instantiation}} - -#if __cplusplus >= 201103L - void init_capture() { - [a(1)] {} (); // expected-error 0-1{{extension}} - [b(1, 2)] {} (); // expected-error {{multiple expressions}} expected-error 0-1{{extension}} -#if __cplusplus >= 201103L - [c({})] {} (); // expected-error {{parenthesized initializer list}} expected-error 0-1{{extension}} - [d({1})] {} (); // expected-error {{parenthesized initializer list}} expected-error 0-1{{extension}} - [e({1, 2})] {} (); // expected-error {{parenthesized initializer list}} expected-error 0-1{{extension}} -#endif - } -#endif -} - -namespace dr1347 { // dr1347: yes - auto x = 5, *y = &x; // expected-error 0-1{{extension}} - auto z = y, *q = y; // expected-error {{'auto' deduced as 'int *' in declaration of 'z' and deduced as 'int' in declaration of 'q'}} expected-error 0-1{{extension}} -#if __cplusplus >= 201103L - auto a = 5, b = {1, 2}; // expected-error {{'auto' deduced as 'int' in declaration of 'a' and deduced as 'std::initializer_list<int>' in declaration of 'b'}} - auto (*fp)(int) -> int, i = 0; // expected-error {{declaration with trailing return type must be the only declaration in its group}} -#endif -} - -namespace dr1359 { // dr1359: 3.5 -#if __cplusplus >= 201103L - union A { constexpr A() = default; }; - union B { constexpr B() = default; int a; }; // expected-error {{not constexpr}} expected-note 2{{candidate}} - union C { constexpr C() = default; int a, b; }; // expected-error {{not constexpr}} expected-note 2{{candidate}} - struct X { constexpr X() = default; union {}; }; - struct Y { constexpr Y() = default; union { int a; }; }; // expected-error {{not constexpr}} expected-note 2{{candidate}} - - constexpr A a = A(); - constexpr B b = B(); // expected-error {{no matching}} - constexpr C c = C(); // expected-error {{no matching}} - constexpr X x = X(); - constexpr Y y = Y(); // expected-error {{no matching}} -#endif -} - -namespace dr1388 { // dr1388: 4 - template<typename A, typename ...T> void f(T..., A); // expected-note 1+{{candidate}} expected-error 0-1{{C++11}} - template<typename ...T> void g(T..., int); // expected-note 1+{{candidate}} expected-error 0-1{{C++11}} - template<typename ...T, typename A> void h(T..., A); // expected-note 1+{{candidate}} expected-error 0-1{{C++11}} - - void test_f() { - f(0); // ok, trailing parameter pack deduced to empty - f(0, 0); // expected-error {{no matching}} - f<int>(0); - f<int>(0, 0); // expected-error {{no matching}} - f<int, int>(0, 0); - f<int, int, int>(0, 0); // expected-error {{no matching}} - - g(0); - g(0, 0); // expected-error {{no matching}} - g<>(0); - g<int>(0); // expected-error {{no matching}} - g<int>(0, 0); - - h(0); - h(0, 0); // expected-error {{no matching}} - h<int>(0, 0); - h<int, int>(0, 0); // expected-error {{no matching}} - } - - // A non-trailing parameter pack is still a non-deduced context, even though - // we know exactly how many arguments correspond to it. - template<typename T, typename U> struct pair {}; - template<typename ...T> struct tuple { typedef char type; }; // expected-error 0-2{{C++11}} - template<typename ...T, typename ...U> void f_pair_1(pair<T, U>..., int); // expected-error 0-2{{C++11}} expected-note {{different lengths (2 vs. 0)}} - template<typename ...T, typename U> void f_pair_2(pair<T, char>..., U); // expected-error 0-2{{C++11}} - template<typename ...T, typename ...U> void f_pair_3(pair<T, U>..., tuple<U...>); // expected-error 0-2{{C++11}} expected-note {{different lengths (2 vs. 1)}} - template<typename ...T> void f_pair_4(pair<T, char>..., T...); // expected-error 0-2{{C++11}} expected-note {{<int, long> vs. <int, long, const char *>}} - void g(pair<int, char> a, pair<long, char> b, tuple<char, char> c) { - f_pair_1<int, long>(a, b, 0); // expected-error {{no match}} - f_pair_2<int, long>(a, b, 0); - f_pair_3<int, long>(a, b, c); - f_pair_3<int, long>(a, b, tuple<char>()); // expected-error {{no match}} - f_pair_4<int, long>(a, b, 0, 0L); - f_pair_4<int, long>(a, b, 0, 0L, "foo"); // expected-error {{no match}} - } -} - -namespace dr1391 { // dr1391: partial - struct A {}; struct B : A {}; - template<typename T> struct C { C(int); typename T::error error; }; // expected-error 2{{'::'}} - template<typename T> struct D {}; - - // No deduction is performed for parameters with no deducible template-parameters, therefore types do not need to match. - template<typename T> void a(T, int T::*); - void test_a(int A::*p) { a(A(), p); } // ok, type of second parameter does not need to match - - namespace dr_example_1 { - template<typename T, typename U> void f(C<T>); - template<typename T> void f(D<T>); - - void g(D<int> d) { - f(d); // ok, first 'f' eliminated by deduction failure - f<int>(d); // ok, first 'f' eliminated because 'U' cannot be deduced - } - } - - namespace dr_example_2 { - template<typename T> typename C<T>::error f(int, T); - template<typename T> T f(T, T); - - void g(A a) { - f(a, a); // ok, no conversion from A to int for first parameter of first candidate - } - } - - namespace std_example { - template<typename T> struct Z { - typedef typename T::x xx; - }; - template<typename T> typename Z<T>::xx f(void *, T); - template<typename T> void f(int, T); - struct A {} a; - void g() { f(1, a); } - } - - template<typename T> void b(C<int> ci, T *p); - void b(...); - void test_b() { - b(0, 0); // ok, deduction fails prior to forming a conversion sequence and instantiating C<int> - // FIXME: The "while substituting" note should point at the overload candidate. - b<int>(0, 0); // expected-note {{instantiation of}} expected-note {{while substituting}} - } - - template<typename T> struct Id { typedef T type; }; - template<typename T> void c(T, typename Id<C<T> >::type); - void test_c() { - // Implicit conversion sequences for dependent types are checked later. - c(0.0, 0); // expected-note {{instantiation of}} - } - - namespace partial_ordering { - // FIXME: Second template should be considered more specialized because non-dependent parameter is ignored. - template<typename T> int a(T, short) = delete; // expected-error 0-1{{extension}} expected-note {{candidate}} - template<typename T> int a(T*, char); // expected-note {{candidate}} - int test_a = a((int*)0, 0); // FIXME: expected-error {{ambiguous}} - - // FIXME: Second template should be considered more specialized: - // deducing #1 from #2 ignores the second P/A pair, so deduction succeeds, - // deducing #2 from #1 fails to deduce T, so deduction fails. - template<typename T> int b(T, int) = delete; // expected-error 0-1{{extension}} expected-note {{candidate}} - template<typename T, typename U> int b(T*, U); // expected-note {{candidate}} - int test_b = b((int*)0, 0); // FIXME: expected-error {{ambiguous}} - - // Unintended consequences: because partial ordering does not consider - // explicit template arguments, and deduction from a non-dependent type - // vacuously succeeds, a non-dependent template is less specialized than - // anything else! - // According to DR1391, this is ambiguous! - template<typename T> int c(int); - template<typename T> int c(T); - int test_c1 = c(0); // ok - int test_c2 = c<int>(0); // FIXME: apparently ambiguous - } -} - -namespace dr1399 { // dr1399: dup 1388 - template<typename ...T> void f(T..., int, T...) {} // expected-note {{candidate}} expected-error 0-1{{C++11}} - void g() { - f(0); - f<int>(0, 0, 0); - f(0, 0, 0); // expected-error {{no match}} - } -} diff --git a/test/CXX/drs/dr14xx.cpp b/test/CXX/drs/dr14xx.cpp deleted file mode 100644 index eb5ba3db448e..000000000000 --- a/test/CXX/drs/dr14xx.cpp +++ /dev/null @@ -1,375 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-no-diagnostics -#endif - -// dr1425: na abi - -namespace dr1460 { // dr1460: 3.5 -#if __cplusplus >= 201103L - namespace DRExample { - union A { - union {}; - union {}; - constexpr A() {} - }; - constexpr A a = A(); - - union B { - union {}; - union {}; - constexpr B() = default; - }; - constexpr B b = B(); - - union C { - union {}; - union {}; - }; - constexpr C c = C(); -#if __cplusplus > 201103L - constexpr void f() { C c; } - static_assert((f(), true), ""); -#endif - } - - union A {}; - union B { int n; }; // expected-note +{{here}} - union C { int n = 0; }; - struct D { union {}; }; - struct E { union { int n; }; }; // expected-note +{{here}} - struct F { union { int n = 0; }; }; - - struct X { - friend constexpr A::A() noexcept; - friend constexpr B::B() noexcept; // expected-error {{follows non-constexpr declaration}} - friend constexpr C::C() noexcept; - friend constexpr D::D() noexcept; - friend constexpr E::E() noexcept; // expected-error {{follows non-constexpr declaration}} - friend constexpr F::F() noexcept; - }; - - // These are OK, because value-initialization doesn't actually invoke the - // constructor. - constexpr A a = A(); - constexpr B b = B(); - constexpr C c = C(); - constexpr D d = D(); - constexpr E e = E(); - constexpr F f = F(); - - namespace Defaulted { - union A { constexpr A() = default; }; - union B { int n; constexpr B() = default; }; // expected-error {{not constexpr}} - union C { int n = 0; constexpr C() = default; }; - struct D { union {}; constexpr D() = default; }; - struct E { union { int n; }; constexpr E() = default; }; // expected-error {{not constexpr}} - struct F { union { int n = 0; }; constexpr F() = default; }; - - struct G { union { int n = 0; }; union { int m; }; constexpr G() = default; }; // expected-error {{not constexpr}} - struct H { - union { - int n = 0; - }; - union { // expected-note 2{{member not initialized}} - int m; - }; - constexpr H() {} // expected-error {{must initialize all members}} - constexpr H(bool) : m(1) {} - constexpr H(char) : n(1) {} // expected-error {{must initialize all members}} - constexpr H(double) : m(1), n(1) {} - }; - } - -#if __cplusplus > 201103L - template<typename T> constexpr bool check() { - T t; // expected-note-re 2{{non-constexpr constructor '{{[BE]}}'}} - return true; - } - static_assert(check<A>(), ""); - static_assert(check<B>(), ""); // expected-error {{constant}} expected-note {{in call}} - static_assert(check<C>(), ""); - static_assert(check<D>(), ""); - static_assert(check<E>(), ""); // expected-error {{constant}} expected-note {{in call}} - static_assert(check<F>(), ""); -#endif - - union G { - int a = 0; // expected-note {{previous initialization is here}} - int b = 0; // expected-error {{initializing multiple members of union}} - }; - union H { - union { - int a = 0; // expected-note {{previous initialization is here}} - }; - union { - int b = 0; // expected-error {{initializing multiple members of union}} - }; - }; - struct I { - union { - int a = 0; // expected-note {{previous initialization is here}} - int b = 0; // expected-error {{initializing multiple members of union}} - }; - }; - struct J { - union { int a = 0; }; - union { int b = 0; }; - }; - - namespace Overriding { - struct A { - int a = 1, b, c = 3; - constexpr A() : b(2) {} - }; - static_assert(A().a == 1 && A().b == 2 && A().c == 3, ""); - - union B { - int a, b = 2, c; - constexpr B() : a(1) {} - constexpr B(char) : b(4) {} - constexpr B(int) : c(3) {} - constexpr B(const char*) {} - }; - static_assert(B().a == 1, ""); - static_assert(B().b == 2, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(B('x').a == 0, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(B('x').b == 4, ""); - static_assert(B(123).b == 2, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(B(123).c == 3, ""); - static_assert(B("").a == 1, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(B("").b == 2, ""); - static_assert(B("").c == 3, ""); // expected-error {{constant}} expected-note {{read of}} - - struct C { - union { int a, b = 2, c; }; - union { int d, e = 5, f; }; - constexpr C() : a(1) {} - constexpr C(char) : c(3) {} - constexpr C(int) : d(4) {} - constexpr C(float) : f(6) {} - constexpr C(const char*) {} - }; - - static_assert(C().a == 1, ""); - static_assert(C().b == 2, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C().d == 4, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C().e == 5, ""); - - static_assert(C('x').b == 2, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C('x').c == 3, ""); - static_assert(C('x').d == 4, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C('x').e == 5, ""); - - static_assert(C(1).b == 2, ""); - static_assert(C(1).c == 3, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C(1).d == 4, ""); - static_assert(C(1).e == 5, ""); // expected-error {{constant}} expected-note {{read of}} - - static_assert(C(1.f).b == 2, ""); - static_assert(C(1.f).c == 3, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C(1.f).e == 5, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C(1.f).f == 6, ""); - - static_assert(C("").a == 1, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C("").b == 2, ""); - static_assert(C("").c == 3, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C("").d == 4, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C("").e == 5, ""); - static_assert(C("").f == 6, ""); // expected-error {{constant}} expected-note {{read of}} - - struct D; - extern const D d; - struct D { - int a; - union { - int b = const_cast<D&>(d).a = 1; // not evaluated - int c; - }; - constexpr D() : a(0), c(0) {} - }; - constexpr D d {}; - static_assert(d.a == 0, ""); - } -#endif -} - -#if __cplusplus >= 201103L -namespace std { - typedef decltype(sizeof(int)) size_t; - - // libc++'s implementation - template <class _E> - class initializer_list - { - const _E* __begin_; - size_t __size_; - - initializer_list(const _E* __b, size_t __s) - : __begin_(__b), __size_(__s) {} - - public: - typedef _E value_type; - typedef const _E& reference; - typedef const _E& const_reference; - typedef size_t size_type; - - typedef const _E* iterator; - typedef const _E* const_iterator; - - initializer_list() : __begin_(nullptr), __size_(0) {} - - size_t size() const {return __size_;} - const _E* begin() const {return __begin_;} - const _E* end() const {return __begin_ + __size_;} - }; -} // std - -namespace dr1467 { // dr1467: 3.7 c++11 - // List-initialization of aggregate from same-type object - - namespace basic0 { - struct S { - int i = 42; - }; - - S a; - S b(a); - S c{a}; - - struct SS : public S { } x; - S y(x); - S z{x}; - } // basic0 - - namespace basic1 { - struct S { - int i{42}; - }; - - S a; - S b(a); - S c{a}; - - struct SS : public S { } x; - S y(x); - S z{x}; - } // basic1 - - namespace basic2 { - struct S { - int i = {42}; - }; - - S a; - S b(a); - S c{a}; - - struct SS : public S { } x; - S y(x); - S z{x}; - } // basic2 - - namespace dr_example { - struct OK { - OK() = default; - OK(const OK&) = default; - OK(int) { } - }; - - OK ok; - OK ok2{ok}; - - struct X { - X() = default; - X(const X&) = default; - }; - - X x; - X x2{x}; - } // dr_example - - namespace nonaggregate { - struct NonAggregate { - NonAggregate() {} - }; - - struct WantsIt { - WantsIt(NonAggregate); - }; - - void f(NonAggregate); - void f(WantsIt); - - void test1() { - NonAggregate n; - f({n}); - } - - void test2() { - NonAggregate x; - NonAggregate y{x}; - NonAggregate z{{x}}; - } - } // nonaggregate - - namespace SelfInitIsNotListInit { - struct S { - S(); - explicit S(S &); - S(const S &); - }; - S s1; - S s2 = {s1}; // ok, not list-initialization so we pick the non-explicit constructor - } - - struct NestedInit { int a, b, c; }; - NestedInit ni[1] = {{NestedInit{1, 2, 3}}}; - - namespace NestedInit2 { - struct Pair { int a, b; }; - struct TwoPairs { TwoPairs(Pair, Pair); }; - struct Value { Value(Pair); Value(TwoPairs); }; - void f() { Value{{{1,2},{3,4}}}; } - } -} // dr1467 - -namespace dr1490 { // dr1490: 3.7 c++11 - // List-initialization from a string literal - - char s[4]{"abc"}; // Ok - std::initializer_list<char>{"abc"}; // expected-error {{expected unqualified-id}}} -} // dr190 - -namespace dr1495 { // dr1495: 4 - // Deduction succeeds in both directions. - template<typename T, typename U> struct A {}; // expected-note {{template is declared here}} - template<typename T, typename U> struct A<U, T> {}; // expected-error {{class template partial specialization is not more specialized}} - - // Primary template is more specialized. - template<typename, typename...> struct B {}; // expected-note {{template is declared here}} - template<typename ...Ts> struct B<Ts...> {}; // expected-error {{not more specialized}} - - // Deduction fails in both directions. - template<int, typename, typename ...> struct C {}; // expected-note {{template is declared here}} - template<typename ...Ts> struct C<0, Ts...> {}; // expected-error {{not more specialized}} - -#if __cplusplus >= 201402L - // Deduction succeeds in both directions. - template<typename T, typename U> int a; // expected-note {{template is declared here}} - template<typename T, typename U> int a<U, T>; // expected-error {{variable template partial specialization is not more specialized}} - - // Primary template is more specialized. - template<typename, typename...> int b; // expected-note {{template is declared here}} - template<typename ...Ts> int b<Ts...>; // expected-error {{not more specialized}} - - // Deduction fails in both directions. - template<int, typename, typename ...> int c; // expected-note {{template is declared here}} - template<typename ...Ts> int c<0, Ts...>; // expected-error {{not more specialized}} -#endif -} -#endif diff --git a/test/CXX/drs/dr158.cpp b/test/CXX/drs/dr158.cpp deleted file mode 100644 index 33f837ca0627..000000000000 --- a/test/CXX/drs/dr158.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-linux -std=c++98 %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux -std=c++11 %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux -std=c++14 %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux -std=c++1z %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s - -// dr158: yes - -// CHECK-LABEL: define {{.*}} @_Z1f -const int *f(const int * const *p, int **q) { - // CHECK: load i32**, {{.*}}, !tbaa ![[INTPTR_TBAA:[^,]*]] - const int *x = *p; - // CHECK: store i32* null, {{.*}}, !tbaa ![[INTPTR_TBAA]] - *q = 0; - return x; -} - -struct A {}; - -// CHECK-LABEL: define {{.*}} @_Z1g -const int *(A::*const *g(const int *(A::* const **p)[3], int *(A::***q)[3]))[3] { - // CHECK: load i64**, {{.*}}, !tbaa ![[MEMPTR_TBAA:[^,]*]] - const int *(A::*const *x)[3] = *p; - // CHECK: store i64* null, {{.*}}, !tbaa ![[MEMPTR_TBAA]] - *q = 0; - return x; -} - diff --git a/test/CXX/drs/dr15xx.cpp b/test/CXX/drs/dr15xx.cpp deleted file mode 100644 index cca4509fa0c1..000000000000 --- a/test/CXX/drs/dr15xx.cpp +++ /dev/null @@ -1,483 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr1512 { // dr1512: 4 - void f(char *p) { - if (p > 0) {} // expected-error {{ordered comparison between pointer and zero}} -#if __cplusplus >= 201103L - if (p > nullptr) {} // expected-error {{invalid operands}} -#endif - } - bool g(int **x, const int **y) { - return x < y; - } - - template<typename T> T val(); - - template<typename A, typename B, typename C> void composite_pointer_type_is_base() { - typedef __typeof(true ? val<A>() : val<B>()) type; - typedef C type; - - typedef __typeof(val<A>() == val<B>()) cmp; - typedef __typeof(val<A>() != val<B>()) cmp; - typedef bool cmp; - } - - template<typename A, typename B, typename C> void composite_pointer_type_is_ord() { - composite_pointer_type_is_base<A, B, C>(); - - typedef __typeof(val<A>() < val<B>()) cmp; - typedef __typeof(val<A>() <= val<B>()) cmp; - typedef __typeof(val<A>() > val<B>()) cmp; - typedef __typeof(val<A>() >= val<B>()) cmp; - typedef bool cmp; - } - - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(int = 0) { - composite_pointer_type_is_base<A, B, C>(); - } - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(__typeof(val<A>() < val<B>()) * = 0); - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(__typeof(val<A>() <= val<B>()) * = 0); - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(__typeof(val<A>() > val<B>()) * = 0); - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(__typeof(val<A>() >= val<B>()) * = 0); - - // A call to this is ambiguous if a composite pointer type exists. - template<typename A, typename B> - void no_composite_pointer_type(__typeof((true ? val<A>() : val<B>()), void()) * = 0); - template<typename A, typename B> void no_composite_pointer_type(int = 0); - - struct A {}; - struct B : A {}; - struct C {}; - - void test() { -#if __cplusplus >= 201103L - using nullptr_t = decltype(nullptr); - composite_pointer_type_is_unord<nullptr_t, nullptr_t, nullptr_t>(); - no_composite_pointer_type<nullptr_t, int>(); - - composite_pointer_type_is_unord<nullptr_t, const char**, const char**>(); - composite_pointer_type_is_unord<const char**, nullptr_t, const char**>(); -#endif - - composite_pointer_type_is_ord<const int *, volatile void *, const volatile void*>(); - composite_pointer_type_is_ord<const void *, volatile int *, const volatile void*>(); - - composite_pointer_type_is_ord<const A*, volatile B*, const volatile A*>(); - composite_pointer_type_is_ord<const B*, volatile A*, const volatile A*>(); - - composite_pointer_type_is_unord<const int *A::*, volatile int *B::*, const volatile int *const B::*>(); - composite_pointer_type_is_unord<const int *B::*, volatile int *A::*, const volatile int *const B::*>(); - no_composite_pointer_type<int (A::*)(), int (C::*)()>(); - no_composite_pointer_type<const int (A::*)(), volatile int (C::*)()>(); - -#if __cplusplus > 201402 - composite_pointer_type_is_ord<int (*)() noexcept, int (*)(), int (*)()>(); - composite_pointer_type_is_ord<int (*)(), int (*)() noexcept, int (*)()>(); - composite_pointer_type_is_unord<int (A::*)() noexcept, int (A::*)(), int (A::*)()>(); - composite_pointer_type_is_unord<int (A::*)(), int (A::*)() noexcept, int (A::*)()>(); - // FIXME: This looks like a standard defect; these should probably all have type 'int (B::*)()'. - composite_pointer_type_is_unord<int (B::*)(), int (A::*)() noexcept, int (B::*)()>(); - composite_pointer_type_is_unord<int (A::*)() noexcept, int (B::*)(), int (B::*)()>(); - composite_pointer_type_is_unord<int (B::*)() noexcept, int (A::*)(), int (B::*)()>(); - composite_pointer_type_is_unord<int (A::*)(), int (B::*)() noexcept, int (B::*)()>(); - - // FIXME: It would be reasonable to permit these, with a common type of 'int (*const *)()'. - no_composite_pointer_type<int (**)() noexcept, int (**)()>(); - no_composite_pointer_type<int (**)(), int (**)() noexcept>(); - - // FIXME: It would be reasonable to permit these, with a common type of 'int (A::*)()'. - no_composite_pointer_type<int (A::*)() const, int (A::*)()>(); - no_composite_pointer_type<int (A::*)(), int (A::*)() const>(); - - // FIXME: It would be reasonable to permit these, with a common type of - // 'int (A::*)() &' and 'int (A::*)() &&', respectively. - no_composite_pointer_type<int (A::*)() &, int (A::*)()>(); - no_composite_pointer_type<int (A::*)(), int (A::*)() &>(); - no_composite_pointer_type<int (A::*)() &&, int (A::*)()>(); - no_composite_pointer_type<int (A::*)(), int (A::*)() &&>(); - - no_composite_pointer_type<int (A::*)() &&, int (A::*)() &>(); - no_composite_pointer_type<int (A::*)() &, int (A::*)() &&>(); - - no_composite_pointer_type<int (C::*)(), int (A::*)() noexcept>(); - no_composite_pointer_type<int (A::*)() noexcept, int (C::*)()>(); -#endif - } - -#if __cplusplus >= 201103L - template<typename T> struct Wrap { operator T(); }; // expected-note 4{{converted to type 'nullptr_t'}} expected-note 4{{converted to type 'int *'}} - void test_overload() { - using nullptr_t = decltype(nullptr); - void(Wrap<nullptr_t>() == Wrap<nullptr_t>()); - void(Wrap<nullptr_t>() != Wrap<nullptr_t>()); - void(Wrap<nullptr_t>() < Wrap<nullptr_t>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() > Wrap<nullptr_t>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() <= Wrap<nullptr_t>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() >= Wrap<nullptr_t>()); // expected-error {{invalid operands}} - - // Under dr1213, this is ill-formed: we select the builtin operator<(int*, int*) - // but then only convert as far as 'nullptr_t', which we then can't convert to 'int*'. - void(Wrap<nullptr_t>() == Wrap<int*>()); - void(Wrap<nullptr_t>() != Wrap<int*>()); - void(Wrap<nullptr_t>() < Wrap<int*>()); // expected-error {{invalid operands to binary expression ('Wrap<nullptr_t>' and 'Wrap<int *>')}} - void(Wrap<nullptr_t>() > Wrap<int*>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() <= Wrap<int*>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() >= Wrap<int*>()); // expected-error {{invalid operands}} - } -#endif -} - -namespace dr1518 { // dr1518: 4 -#if __cplusplus >= 201103L -struct Z0 { // expected-note 0+ {{candidate}} - explicit Z0() = default; // expected-note 0+ {{here}} -}; -struct Z { // expected-note 0+ {{candidate}} - explicit Z(); // expected-note 0+ {{here}} - explicit Z(int); - explicit Z(int, int); // expected-note 0+ {{here}} -}; -template <class T> int Eat(T); // expected-note 0+ {{candidate}} -Z0 a; -Z0 b{}; -Z0 c = {}; // expected-error {{explicit in copy-initialization}} -int i = Eat<Z0>({}); // expected-error {{no matching function for call to 'Eat'}} - -Z c2 = {}; // expected-error {{explicit in copy-initialization}} -int i2 = Eat<Z>({}); // expected-error {{no matching function for call to 'Eat'}} -Z a1 = 1; // expected-error {{no viable conversion}} -Z a3 = Z(1); -Z a2(1); -Z *p = new Z(1); -Z a4 = (Z)1; -Z a5 = static_cast<Z>(1); -Z a6 = {4, 3}; // expected-error {{explicit in copy-initialization}} - -struct UserProvidedBaseCtor { // expected-note 0+ {{candidate}} - UserProvidedBaseCtor() {} -}; -struct DoesntInheritCtor : UserProvidedBaseCtor { // expected-note 0+ {{candidate}} - int x; -}; -DoesntInheritCtor I{{}, 42}; -#if __cplusplus <= 201402L -// expected-error@-2 {{no matching constructor}} -#endif - -struct BaseCtor { BaseCtor() = default; }; // expected-note 0+ {{candidate}} -struct InheritsCtor : BaseCtor { // expected-note 1+ {{candidate}} - using BaseCtor::BaseCtor; // expected-note 2 {{inherited here}} - int x; -}; -InheritsCtor II = {{}, 42}; // expected-error {{no matching constructor}} - -namespace std_example { - struct A { - explicit A() = default; // expected-note 2{{declared here}} - }; - - struct B : A { - explicit B() = default; // expected-note 2{{declared here}} - }; - - struct C { - explicit C(); // expected-note 2{{declared here}} - }; - - struct D : A { - C c; - explicit D() = default; // expected-note 2{{declared here}} - }; - - template <typename T> void f() { - T t; // ok - T u{}; // ok - T v = {}; // expected-error 4{{explicit}} - } - template <typename T> void g() { - void x(T t); // expected-note 4{{parameter}} - x({}); // expected-error 4{{explicit}} - } - - void test() { - f<A>(); // expected-note {{instantiation of}} - f<B>(); // expected-note {{instantiation of}} - f<C>(); // expected-note {{instantiation of}} - f<D>(); // expected-note {{instantiation of}} - g<A>(); // expected-note {{instantiation of}} - g<B>(); // expected-note {{instantiation of}} - g<C>(); // expected-note {{instantiation of}} - g<D>(); // expected-note {{instantiation of}} - } -} -#endif // __cplusplus >= 201103L -} - -namespace dr1550 { // dr1550: yes - int f(bool b, int n) { - return (b ? (throw 0) : n) + (b ? n : (throw 0)); - } -} - -namespace dr1560 { // dr1560: 3.5 - void f(bool b, int n) { - (b ? throw 0 : n) = (b ? n : throw 0) = 0; - } - class X { X(const X&); }; - const X &get(); - const X &x = true ? get() : throw 0; -} - -namespace dr1573 { // dr1573: 3.9 -#if __cplusplus >= 201103L - // ellipsis is inherited (p0136r1 supersedes this part). - struct A { A(); A(int, char, ...); }; - struct B : A { using A::A; }; - B b(1, 'x', 4.0, "hello"); // ok - - // inherited constructor is effectively constexpr if the user-written constructor would be - struct C { C(); constexpr C(int) {} }; - struct D : C { using C::C; }; - constexpr D d = D(0); // ok - struct E : C { using C::C; A a; }; // expected-note {{non-literal type}} - constexpr E e = E(0); // expected-error {{non-literal type}} - // FIXME: This diagnostic is pretty bad; we should explain that the problem - // is that F::c would be initialized by a non-constexpr constructor. - struct F : C { using C::C; C c; }; // expected-note {{here}} - constexpr F f = F(0); // expected-error {{constant expression}} expected-note {{constructor inherited from base class 'C'}} - - // inherited constructor is effectively deleted if the user-written constructor would be - struct G { G(int); }; - struct H : G { using G::G; G g; }; // expected-note {{constructor inherited by 'H' is implicitly deleted because field 'g' has no default constructor}} - H h(0); // expected-error {{constructor inherited by 'H' from base class 'G' is implicitly deleted}} -#endif -} - -#if __cplusplus >= 201103L -namespace std { - typedef decltype(sizeof(int)) size_t; - - // libc++'s implementation - template <class _E> - class initializer_list - { - const _E* __begin_; - size_t __size_; - - initializer_list(const _E* __b, size_t __s) - : __begin_(__b), __size_(__s) {} - - public: - typedef _E value_type; - typedef const _E& reference; - typedef const _E& const_reference; - typedef size_t size_type; - - typedef const _E* iterator; - typedef const _E* const_iterator; - - initializer_list() : __begin_(nullptr), __size_(0) {} - - size_t size() const {return __size_;} - const _E* begin() const {return __begin_;} - const _E* end() const {return __begin_ + __size_;} - }; - - template < class _T1, class _T2 > struct pair { _T2 second; }; - - template<typename T> struct basic_string { - basic_string(const T* x) {} - ~basic_string() {}; - }; - typedef basic_string<char> string; - -} // std - -namespace dr1579 { // dr1579: 3.9 -template<class T> -struct GenericMoveOnly { - GenericMoveOnly(); - template<class U> GenericMoveOnly(const GenericMoveOnly<U> &) = delete; // expected-note 5 {{marked deleted here}} - GenericMoveOnly(const int &) = delete; // expected-note 2 {{marked deleted here}} - template<class U> GenericMoveOnly(GenericMoveOnly<U> &&); - GenericMoveOnly(int &&); -}; - -GenericMoveOnly<float> DR1579_Eligible(GenericMoveOnly<char> CharMO) { - int i; - GenericMoveOnly<char> GMO; - - if (0) - return i; - else if (0) - return GMO; - else if (0) - return ((GMO)); - else - return CharMO; -} - -GenericMoveOnly<char> GlobalMO; - -GenericMoveOnly<float> DR1579_Ineligible(int &AnInt, - GenericMoveOnly<char> &CharMO) { - static GenericMoveOnly<char> StaticMove; - extern GenericMoveOnly<char> ExternMove; - - if (0) - return AnInt; // expected-error{{invokes a deleted function}} - else if (0) - return GlobalMO; // expected-error{{invokes a deleted function}} - else if (0) - return StaticMove; // expected-error{{invokes a deleted function}} - else if (0) - return ExternMove; // expected-error{{invokes a deleted function}} - else if (0) - return AnInt; // expected-error{{invokes a deleted function}} - else - return CharMO; // expected-error{{invokes a deleted function}} -} - -auto DR1579_lambda_valid = [](GenericMoveOnly<float> mo) -> - GenericMoveOnly<char> { - return mo; -}; - -auto DR1579_lambda_invalid = []() -> GenericMoveOnly<char> { - static GenericMoveOnly<float> mo; - return mo; // expected-error{{invokes a deleted function}} -}; -} // end namespace dr1579 - -namespace dr1584 { - // Deducing function types from cv-qualified types - template<typename T> void f(const T *); // expected-note {{candidate template ignored}} - template<typename T> void g(T *, const T * = 0); - template<typename T> void h(T *) { T::error; } // expected-error {{no members}} - template<typename T> void h(const T *); - void i() { - f(&i); // expected-error {{no matching function}} - g(&i); - h(&i); // expected-note {{here}} - } -} - -namespace dr1589 { // dr1589: 3.7 c++11 - // Ambiguous ranking of list-initialization sequences - - void f0(long, int=0); // Would makes selection of #0 ambiguous - void f0(long); // #0 - void f0(std::initializer_list<int>); // #00 - void g0() { f0({1L}); } // chooses #00 - - void f1(int, int=0); // Would make selection of #1 ambiguous - void f1(int); // #1 - void f1(std::initializer_list<long>); // #2 - void g1() { f1({42}); } // chooses #2 - - void f2(std::pair<const char*, const char*>, int = 0); // Would makes selection of #3 ambiguous - void f2(std::pair<const char*, const char*>); // #3 - void f2(std::initializer_list<std::string>); // #4 - void g2() { f2({"foo","bar"}); } // chooses #4 - - namespace with_error { - void f0(long); // #0 expected-note {{candidate function}} - void f0(std::initializer_list<int>); // #00 expected-note {{candidate function}} - void f0(std::initializer_list<int>, int = 0); // Makes selection of #00 ambiguous \ - // expected-note {{candidate function}} - void g0() { f0({1L}); } // chooses #00 expected-error{{call to 'f0' is ambiguous}} - - void f1(int); // #1 expected-note {{candidate function}} - void f1(std::initializer_list<long>); // #2 expected-note {{candidate function}} - void f1(std::initializer_list<long>, int = 0); // Makes selection of #00 ambiguous \ - // expected-note {{candidate function}} - void g1() { f1({42}); } // chooses #2 expected-error{{call to 'f1' is ambiguous}} - - void f2(std::pair<const char*, const char*>); // #3 TODO: expected- note {{candidate function}} - void f2(std::initializer_list<std::string>); // #4 expected-note {{candidate function}} - void f2(std::initializer_list<std::string>, int = 0); // Makes selection of #00 ambiguous \ - // expected-note {{candidate function}} - void g2() { f2({"foo","bar"}); } // chooses #4 expected-error{{call to 'f2' is ambiguous}} - } - -} // dr1589 - -namespace dr1591 { //dr1591. Deducing array bound and element type from initializer list - template<class T, int N> int h(T const(&)[N]); - int X = h({1,2,3}); // T deduced to int, N deduced to 3 - - template<class T> int j(T const(&)[3]); - int Y = j({42}); // T deduced to int, array bound not considered - - struct Aggr { int i; int j; }; - template<int N> int k(Aggr const(&)[N]); //expected-note{{not viable}} - int Y0 = k({1,2,3}); //expected-error{{no matching function}} - int Z = k({{1},{2},{3}}); // OK, N deduced to 3 - - template<int M, int N> int m(int const(&)[M][N]); - int X0 = m({{1,2},{3,4}}); // M and N both deduced to 2 - - template<class T, int N> int n(T const(&)[N], T); - int X1 = n({{1},{2},{3}},Aggr()); // OK, T is Aggr, N is 3 - - - namespace check_multi_dim_arrays { - template<class T, int N, int M, int O> int ***f(const T (&a)[N][M][O]); //expected-note{{deduced conflicting values}} - template<class T, int N, int M> int **f(const T (&a)[N][M]); //expected-note{{couldn't infer}} - - template<class T, int N> int *f(const T (&a)[N]); //expected-note{{couldn't infer}} - int ***p3 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12} } }); - int ***p33 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12, 13} } }); //expected-error{{no matching}} - int **p2 = f({ {1,2,3}, {3, 4, 5} }); - int **p22 = f({ {1,2}, {3, 4} }); - int *p1 = f({1, 2, 3}); - } - namespace check_multi_dim_arrays_rref { - template<class T, int N, int M, int O> int ***f(T (&&a)[N][M][O]); //expected-note{{deduced conflicting values}} - template<class T, int N, int M> int **f(T (&&a)[N][M]); //expected-note{{couldn't infer}} - - template<class T, int N> int *f(T (&&a)[N]); //expected-note{{couldn't infer}} - int ***p3 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12} } }); - int ***p33 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12, 13} } }); //expected-error{{no matching}} - int **p2 = f({ {1,2,3}, {3, 4, 5} }); - int **p22 = f({ {1,2}, {3, 4} }); - int *p1 = f({1, 2, 3}); - } - - namespace check_arrays_of_init_list { - template<class T, int N> float *f(const std::initializer_list<T> (&)[N]); - template<class T, int N> double *f(const T(&)[N]); - double *p = f({1, 2, 3}); - float *fp = f({{1}, {1, 2}, {1, 2, 3}}); - } - namespace core_reflector_28543 { - - template<class T, int N> int *f(T (&&)[N]); // #1 - template<class T> char *f(std::initializer_list<T> &&); //#2 - template<class T, int N, int M> int **f(T (&&)[N][M]); //#3 expected-note{{candidate}} - template<class T, int N> char **f(std::initializer_list<T> (&&)[N]); //#4 expected-note{{candidate}} - - template<class T> short *f(T (&&)[2]); //#5 - - template<class T> using Arr = T[]; - - char *pc = f({1, 2, 3}); // OK prefer #2 via 13.3.3.2 [over.ics.rank] - char *pc2 = f({1, 2}); // #2 also - int *pi = f(Arr<int>{1, 2, 3}); // OK prefer #1 - - void *pv1 = f({ {1, 2, 3}, {4, 5, 6} }); // expected-error{{ambiguous}} btw 3 & 4 - char **pcc = f({ {1}, {2, 3} }); // OK #4 - - short *ps = f(Arr<int>{1, 2}); // OK #5 - } -} // dr1591 - -#endif diff --git a/test/CXX/drs/dr16xx.cpp b/test/CXX/drs/dr16xx.cpp deleted file mode 100644 index 4f2f06e0d020..000000000000 --- a/test/CXX/drs/dr16xx.cpp +++ /dev/null @@ -1,367 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-error@+1 {{variadic macro}} -#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__) -#endif - -#if __cplusplus >= 201103L -namespace std { - typedef decltype(sizeof(int)) size_t; - - template<typename E> class initializer_list { - const E *begin; - size_t size; - - public: - initializer_list(); - }; -} // std -#endif - -namespace dr1611 { // dr1611: dup 1658 - struct A { A(int); }; - struct B : virtual A { virtual void f() = 0; }; - struct C : B { C() : A(0) {} void f(); }; - C c; -} - -namespace dr1684 { // dr1684: 3.6 -#if __cplusplus >= 201103L - struct NonLiteral { // expected-note {{because}} - NonLiteral(); - constexpr int f() { return 0; } // expected-warning 0-1{{will not be implicitly 'const'}} - }; - constexpr int f(NonLiteral &) { return 0; } - constexpr int f(NonLiteral) { return 0; } // expected-error {{not a literal type}} -#endif -} - -namespace dr1631 { // dr1631: 3.7 -#if __cplusplus >= 201103L - // Incorrect overload resolution for single-element initializer-list - - struct A { int a[1]; }; - struct B { B(int); }; - void f(B, int); - void f(B, int, int = 0); - void f(int, A); - - void test() { - f({0}, {{1}}); // expected-warning {{braces around scalar init}} - } - - namespace with_error { - void f(B, int); // TODO: expected- note {{candidate function}} - void f(int, A); // expected-note {{candidate function}} - void f(int, A, int = 0); // expected-note {{candidate function}} - - void test() { - f({0}, {{1}}); // expected-error{{call to 'f' is ambiguous}} - } - } -#endif -} - -namespace dr1638 { // dr1638: yes -#if __cplusplus >= 201103L - template<typename T> struct A { - enum class E; // expected-note {{previous}} - enum class F : T; // expected-note 2{{previous}} - }; - - template<> enum class A<int>::E; - template<> enum class A<int>::E {}; - template<> enum class A<int>::F : int; - template<> enum class A<int>::F : int {}; - - template<> enum class A<short>::E : int; - template<> enum class A<short>::E : int {}; - - template<> enum class A<short>::F; // expected-error {{different underlying type}} - template<> enum class A<char>::E : char; // expected-error {{different underlying type}} - template<> enum class A<char>::F : int; // expected-error {{different underlying type}} - - enum class A<unsigned>::E; // expected-error {{template specialization requires 'template<>'}} expected-error {{nested name specifier}} - template enum class A<unsigned>::E; // expected-error {{enumerations cannot be explicitly instantiated}} - enum class A<unsigned>::E *e; // expected-error {{must use 'enum' not 'enum class'}} - - struct B { - friend enum class A<unsigned>::E; // expected-error {{must use 'enum' not 'enum class'}} - }; -#endif -} - -namespace dr1645 { // dr1645: 3.9 -#if __cplusplus >= 201103L - struct A { - constexpr A(int, float = 0); // expected-note 2{{candidate}} - explicit A(int, int = 0); // expected-note 2{{candidate}} - A(int, int, int = 0) = delete; // expected-note {{candidate}} - }; - - struct B : A { // expected-note 2{{candidate}} - using A::A; // expected-note 5{{inherited here}} - }; - - constexpr B a(0); // expected-error {{ambiguous}} - constexpr B b(0, 0); // expected-error {{ambiguous}} -#endif -} - -namespace dr1653 { // dr1653: 4 c++17 - void f(bool b) { - ++b; - b++; -#if __cplusplus <= 201402L - // expected-warning@-3 {{deprecated}} expected-warning@-2 {{deprecated}} -#else - // expected-error@-5 {{incrementing expression of type bool}} expected-error@-4 {{incrementing expression of type bool}} -#endif - --b; // expected-error {{cannot decrement expression of type bool}} - b--; // expected-error {{cannot decrement expression of type bool}} - b += 1; // ok - b -= 1; // ok - } -} - -namespace dr1658 { // dr1658: 5 - namespace DefCtor { - class A { A(); }; // expected-note 0-2{{here}} - class B { ~B(); }; // expected-note 0-2{{here}} - - // The stars align! An abstract class does not construct its virtual bases. - struct C : virtual A { C(); virtual void foo() = 0; }; - C::C() = default; // ok, not deleted, expected-error 0-1{{extension}} - struct D : virtual B { D(); virtual void foo() = 0; }; - D::D() = default; // ok, not deleted, expected-error 0-1{{extension}} - - // In all other cases, we are not so lucky. - struct E : A { E(); virtual void foo() = 0; }; -#if __cplusplus < 201103L - E::E() = default; // expected-error {{private default constructor}} expected-error {{extension}} expected-note {{here}} -#else - E::E() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible default constructor}} -#endif - struct F : virtual A { F(); }; -#if __cplusplus < 201103L - F::F() = default; // expected-error {{private default constructor}} expected-error {{extension}} expected-note {{here}} -#else - F::F() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible default constructor}} -#endif - - struct G : B { G(); virtual void foo() = 0; }; -#if __cplusplus < 201103L - G::G() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}} -#else - G::G() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}} -#endif - struct H : virtual B { H(); }; -#if __cplusplus < 201103L - H::H() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}} -#else - H::H() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}} -#endif - } - - namespace Dtor { - class B { ~B(); }; // expected-note 0-2{{here}} - - struct D : virtual B { ~D(); virtual void foo() = 0; }; - D::~D() = default; // ok, not deleted, expected-error 0-1{{extension}} - - struct G : B { ~G(); virtual void foo() = 0; }; -#if __cplusplus < 201103L - G::~G() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}} -#else - G::~G() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}} -#endif - struct H : virtual B { ~H(); }; -#if __cplusplus < 201103L - H::~H() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}} -#else - H::~H() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}} -#endif - } - - namespace MemInit { - struct A { A(int); }; // expected-note {{here}} - struct B : virtual A { - B() {} - virtual void f() = 0; - }; - struct C : virtual A { - C() {} // expected-error {{must explicitly initialize}} - }; - } - - namespace CopyCtorParamType { - struct A { A(A&); }; - struct B : virtual A { virtual void f() = 0; }; - struct C : virtual A { virtual void f(); }; - struct D : A { virtual void f() = 0; }; - - struct X { - friend B::B(const B&) throw(); - friend C::C(C&); - friend D::D(D&); - }; - } - - namespace CopyCtor { - class A { A(const A&); A(A&&); }; // expected-note 0-4{{here}} expected-error 0-1{{extension}} - - struct C : virtual A { C(const C&); C(C&&); virtual void foo() = 0; }; // expected-error 0-1{{extension}} - C::C(const C&) = default; // expected-error 0-1{{extension}} - C::C(C&&) = default; // expected-error 0-2{{extension}} - - struct E : A { E(const E&); E(E&&); virtual void foo() = 0; }; // expected-error 0-1{{extension}} -#if __cplusplus < 201103L - E::E(const E&) = default; // expected-error {{private copy constructor}} expected-error {{extension}} expected-note {{here}} - E::E(E&&) = default; // expected-error {{private move constructor}} expected-error 2{{extension}} expected-note {{here}} -#else - E::E(const E&) = default; // expected-error {{would delete}} expected-note@-5{{inaccessible copy constructor}} - E::E(E&&) = default; // expected-error {{would delete}} expected-note@-6{{inaccessible move constructor}} -#endif - struct F : virtual A { F(const F&); F(F&&); }; // expected-error 0-1{{extension}} -#if __cplusplus < 201103L - F::F(const F&) = default; // expected-error {{private copy constructor}} expected-error {{extension}} expected-note {{here}} - F::F(F&&) = default; // expected-error {{private move constructor}} expected-error 2{{extension}} expected-note {{here}} -#else - F::F(const F&) = default; // expected-error {{would delete}} expected-note@-5{{inaccessible copy constructor}} - F::F(F&&) = default; // expected-error {{would delete}} expected-note@-6{{inaccessible move constructor}} -#endif - } - - // assignment case is superseded by dr2180 -} - -namespace dr1672 { // dr1672: 7 - struct Empty {}; - struct A : Empty {}; - struct B { Empty e; }; - struct C : A { B b; int n; }; - struct D : A { int n; B b; }; - - static_assert(!__is_standard_layout(C), ""); - static_assert(__is_standard_layout(D), ""); - - struct E { B b; int n; }; - struct F { int n; B b; }; - union G { B b; int n; }; - union H { int n; B b; }; - - struct X {}; - template<typename T> struct Y : X, A { T t; }; - - static_assert(!__is_standard_layout(Y<E>), ""); - static_assert(__is_standard_layout(Y<F>), ""); - static_assert(!__is_standard_layout(Y<G>), ""); - static_assert(!__is_standard_layout(Y<H>), ""); - static_assert(!__is_standard_layout(Y<X>), ""); -} - -namespace dr1687 { // dr1687: 7 - template<typename T> struct To { - operator T(); // expected-note 2{{first operand was implicitly converted to type 'int *'}} - // expected-note@-1 {{second operand was implicitly converted to type 'double'}} -#if __cplusplus > 201703L - // expected-note@-3 2{{operand was implicitly converted to type 'dr1687::E}} -#endif - }; - - int *a = To<int*>() + 100.0; // expected-error {{invalid operands to binary expression ('To<int *>' and 'double')}} - int *b = To<int*>() + To<double>(); // expected-error {{invalid operands to binary expression ('To<int *>' and 'To<double>')}} - -#if __cplusplus > 201703L - enum E1 {}; - enum E2 {}; - auto c = To<E1>() <=> To<E2>(); // expected-error {{invalid operands to binary expression ('To<dr1687::E1>' and 'To<dr1687::E2>')}} -#endif -} - -namespace dr1696 { // dr1696: 7 - namespace std_examples { -#if __cplusplus >= 201402L - extern struct A a; - struct A { - const A &x = { A{a, a} }; - const A &y = { A{} }; // expected-error {{default member initializer for 'y' needed within definition of enclosing class 'A' outside of member functions}} expected-note {{here}} - }; - A a{a, a}; -#endif - } - - struct A { A(); ~A(); }; -#if __cplusplus >= 201103L - struct B { - A &&a; // expected-note {{declared here}} - B() : a{} {} // expected-error {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}} - } b; -#endif - - struct C { - C(); - const A &a; // expected-note {{declared here}} - }; - C::C() : a(A()) {} // expected-error {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}} - -#if __cplusplus >= 201103L - // This is OK in C++14 onwards, per DR1815, though we don't support that yet: - // D1 d1 = {}; - // is equivalent to - // D1 d1 = {A()}; - // ... which lifetime-extends the A temporary. - struct D1 { -#if __cplusplus < 201402L - // expected-error@-2 {{binds to a temporary}} -#endif - const A &a = A(); // expected-note {{default member init}} - }; - D1 d1 = {}; -#if __cplusplus < 201402L - // expected-note@-2 {{first required here}} -#else - // expected-warning-re@-4 {{sorry, lifetime extension {{.*}} not supported}} -#endif - - struct D2 { - const A &a = A(); // expected-note {{default member init}} - D2() {} // expected-error {{binds to a temporary}} - }; - - struct D3 { // expected-error {{binds to a temporary}} - const A &a = A(); // expected-note {{default member init}} - }; - D3 d3; // expected-note {{first required here}} - - struct haslist1 { - std::initializer_list<int> il; // expected-note {{'std::initializer_list' member}} - haslist1(int i) : il{i, 2, 3} {} // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}} - }; - - struct haslist2 { - std::initializer_list<int> il; // expected-note {{'std::initializer_list' member}} - haslist2(); - }; - haslist2::haslist2() : il{1, 2} {} // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}} - - struct haslist3 { - std::initializer_list<int> il = {1, 2, 3}; - }; - - struct haslist4 { // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}} - std::initializer_list<int> il = {1, 2, 3}; // expected-note {{default member initializer}} - }; - haslist4 hl4; // expected-note {{in implicit default constructor}} - - struct haslist5 { - std::initializer_list<int> il = {1, 2, 3}; // expected-note {{default member initializer}} - haslist5() {} // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}} - }; -#endif -} diff --git a/test/CXX/drs/dr1748.cpp b/test/CXX/drs/dr1748.cpp deleted file mode 100644 index 7e04f402d266..000000000000 --- a/test/CXX/drs/dr1748.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s -// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s -// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s -// RUN: %clang_cc1 -std=c++1z %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s - -// dr1748: 3.7 - -// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets. -__extension__ typedef __SIZE_TYPE__ size_t; - -void *operator new(size_t, void *); -void *operator new[](size_t, void *); - -struct X { X(); }; - -// The reserved placement allocation functions get inlined -// even if we can't see their definitions. They do not -// perform a null check. - -// CHECK-LABEL: define {{.*}} @_Z1fPv( -// CHECK-NOT: call -// CHECK-NOT: icmp{{.*}} null -// CHECK-NOT: br i1 -// CHECK: call void @_ZN1XC1Ev( -// CHECK: } -X *f(void *p) { return new (p) X; } - -// CHECK-LABEL: define {{.*}} @_Z1gPv( -// CHECK-NOT: call -// CHECK-NOT: icmp{{.*}} null -// CHECK-NOT: br i1 -// CHECK: call void @_ZN1XC1Ev( -// CHECK: br i1 -// CHECK: } -X *g(void *p) { return new (p) X[5]; } diff --git a/test/CXX/drs/dr17xx.cpp b/test/CXX/drs/dr17xx.cpp deleted file mode 100644 index a917412adcbd..000000000000 --- a/test/CXX/drs/dr17xx.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-no-diagnostics -#endif - -namespace dr1715 { // dr1715: 3.9 -#if __cplusplus >= 201103L - struct B { - template<class T> B(T, typename T::Q); - }; - - class S { - using Q = int; - template<class T> friend B::B(T, typename T::Q); - }; - - struct D : B { - using B::B; - }; - struct E : B { // expected-note 2{{candidate}} - template<class T> E(T t, typename T::Q q) : B(t, q) {} // expected-note {{'Q' is a private member}} - }; - - B b(S(), 1); - D d(S(), 2); - E e(S(), 3); // expected-error {{no match}} -#endif -} - -namespace dr1736 { // dr1736: 3.9 -#if __cplusplus >= 201103L -struct S { - template <class T> S(T t) { - struct L : S { - using S::S; - }; - typename T::type value; // expected-error {{no member}} - L l(value); // expected-note {{instantiation of}} - } -}; -struct Q { typedef int type; } q; -S s(q); // expected-note {{instantiation of}} -#endif -} - -namespace dr1756 { // dr1756: 3.7 -#if __cplusplus >= 201103L - // Direct-list-initialization of a non-class object - - int a{0}; - - struct X { operator int(); } x; - int b{x}; -#endif -} - -namespace dr1758 { // dr1758: 3.7 -#if __cplusplus >= 201103L - // Explicit conversion in copy/move list initialization - - struct X { X(); }; - struct Y { explicit operator X(); } y; - X x{y}; - - struct A { - A() {} - A(const A &) {} - }; - struct B { - operator A() { return A(); } - } b; - A a{b}; -#endif -} diff --git a/test/CXX/drs/dr18xx.cpp b/test/CXX/drs/dr18xx.cpp deleted file mode 100644 index 16f967b65654..000000000000 --- a/test/CXX/drs/dr18xx.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-error@+1 {{variadic macro}} -#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__) -#endif - -namespace dr1813 { // dr1813: 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 dr1815 { // dr1815: no -#if __cplusplus >= 201402L - // FIXME: needs codegen test - struct A { int &&r = 0; }; // expected-note {{default member init}} - A a = {}; // FIXME expected-warning {{not supported}} - - struct B { int &&r = 0; }; // expected-error {{binds to a temporary}} expected-note {{default member init}} - B b; // expected-note {{here}} -#endif -} - -namespace dr1881 { // dr1881: 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), ""); -} - -void dr1891() { // dr1891: 4 -#if __cplusplus >= 201103L - int n; - auto a = []{}; // expected-note 2{{candidate}} expected-note 2{{here}} - auto b = [=]{ return n; }; // expected-note 2{{candidate}} expected-note 2{{here}} - typedef decltype(a) A; - typedef decltype(b) B; - - static_assert(!__has_trivial_constructor(A), ""); - static_assert(!__has_trivial_constructor(B), ""); - - A x; // expected-error {{no matching constructor}} - B y; // expected-error {{no matching constructor}} - - a = a; // expected-error {{copy assignment operator is implicitly deleted}} - a = static_cast<A&&>(a); // expected-error {{copy assignment operator is implicitly deleted}} - b = b; // expected-error {{copy assignment operator is implicitly deleted}} - b = static_cast<B&&>(b); // expected-error {{copy assignment operator is implicitly deleted}} -#endif -} diff --git a/test/CXX/drs/dr19xx.cpp b/test/CXX/drs/dr19xx.cpp deleted file mode 100644 index e6cf337da0ba..000000000000 --- a/test/CXX/drs/dr19xx.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace std { struct type_info; } - -namespace dr1902 { // dr1902: 3.7 - struct A {}; - struct B { - B(A); -#if __cplusplus >= 201103L - // expected-note@-2 {{candidate}} -#endif - - B() = delete; -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} -#endif - - B(const B&) // expected-note {{deleted here}} -#if __cplusplus >= 201103L - // expected-note@-2 {{candidate}} -#else - // expected-error@+2 {{extension}} -#endif - = delete; - - operator A(); - }; - - extern B b1; - B b2(b1); // expected-error {{call to deleted}} - -#if __cplusplus >= 201103L - // This is ambiguous, even though calling the B(const B&) constructor would - // both directly and indirectly call a deleted function. - B b({}); // expected-error {{ambiguous}} -#endif -} - -namespace dr1903 { - namespace A { - struct a {}; - int a; - namespace B { - int b; - } - using namespace B; - namespace { - int c; - } - namespace D { - int d; - } - using D::d; - } - namespace X { - using A::a; - using A::b; - using A::c; - using A::d; - struct a *p; - } -} - -namespace dr1909 { // dr1909: yes - struct A { - template<typename T> struct A {}; // expected-error {{member 'A' has the same name as its class}} - }; - struct B { - template<typename T> void B() {} // expected-error {{constructor cannot have a return type}} - }; - struct C { - template<typename T> static int C; // expected-error {{member 'C' has the same name as its class}} expected-error 0-1{{extension}} - }; - struct D { - template<typename T> using D = int; // expected-error {{member 'D' has the same name as its class}} expected-error 0-1{{extension}} - }; -} - -namespace dr1940 { // dr1940: yes -#if __cplusplus >= 201103L -static union { - static_assert(true, ""); // ok - static_assert(false, ""); // expected-error {{static_assert failed}} -}; -#endif -} - -namespace dr1941 { // dr1941: 3.9 -#if __cplusplus >= 201402L -template<typename X> -struct base { - template<typename T> - base(T a, T b, decltype(void(*T()), 0) = 0) { - while (a != b) (void)*a++; - } - - template<typename T> - base(T a, X x, decltype(void(T(0) * 1), 0) = 0) { - for (T n = 0; n != a; ++n) (void)X(x); - } -}; - -struct derived : base<int> { - using base::base; -}; - -struct iter { - iter operator++(int); - int operator*(); - friend bool operator!=(iter, iter); -} it, end; - -derived d1(it, end); -derived d2(42, 9); -#endif -} - -namespace dr1947 { // dr1947: yes -#if __cplusplus >= 201402L -unsigned o = 0'01; // ok -unsigned b = 0b'01; // expected-error {{invalid digit 'b' in octal constant}} -unsigned x = 0x'01; // expected-error {{invalid suffix 'x'01' on integer constant}} -#endif -} - -#if __cplusplus >= 201103L -// dr1948: yes -// FIXME: This diagnostic could be improved. -void *operator new(__SIZE_TYPE__) noexcept { return nullptr; } // expected-error{{exception specification in declaration does not match previous declaration}} -#endif - -namespace dr1959 { // dr1959: 3.9 -#if __cplusplus >= 201103L - struct b; - struct c; - struct a { - a() = default; - a(const a &) = delete; // expected-note {{deleted}} - a(const b &) = delete; // not inherited - a(c &&) = delete; // expected-note {{not viable}} - template<typename T> a(T) = delete; // expected-note {{would take its own class type by value}} - }; - - struct b : a { // expected-note {{cannot bind}} expected-note {{deleted because}} - using a::a; // expected-note 2{{inherited here}} - }; - - a x; - // FIXME: As a resolution to an open DR against P0136R0, we disallow - // use of inherited constructors to construct from a single argument - // where the base class is reference-related to the argument type. - b y = x; // expected-error {{no viable conversion}} - b z = z; // expected-error {{deleted}} - - struct c : a { - using a::a; - c(const c &); - }; - // FIXME: As a resolution to an open DR against P0136R0, we disallow - // use of inherited constructors to construct from a single argument - // where the base class is reference-related to the argument type. - c q(static_cast<c&&>(q)); -#endif -} - -namespace dr1968 { // dr1968: yes -#if __cplusplus >= 201103L - static_assert(&typeid(int) == &typeid(int), ""); // expected-error{{not an integral constant expression}} -#endif -} - -namespace dr1991 { // dr1991: 3.9 -#if __cplusplus >= 201103L - struct A { - A(int, int) = delete; - }; - - struct B : A { - using A::A; - B(int, int, int = 0); - }; - - // FIXME: As a resolution to an open DR against P0136R1, we treat derived - // class constructors as better than base class constructors in the presence - // of ambiguity. - B b(0, 0); // ok, calls B constructor -#endif -} - -// dr1994: dup 529 diff --git a/test/CXX/drs/dr1xx.cpp b/test/CXX/drs/dr1xx.cpp deleted file mode 100644 index 26ab67d54d31..000000000000 --- a/test/CXX/drs/dr1xx.cpp +++ /dev/null @@ -1,1060 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr100 { // dr100: yes - template<const char *> struct A {}; // expected-note 0-1{{declared here}} - template<const char (&)[4]> struct B {}; // expected-note 0-1{{declared here}} - A<"foo"> a; // expected-error {{does not refer to any declaration}} - B<"bar"> b; // expected-error {{does not refer to any declaration}} -} - -namespace dr101 { // dr101: 3.5 - extern "C" void dr101_f(); - typedef unsigned size_t; - namespace X { - extern "C" void dr101_f(); - typedef unsigned size_t; - } - using X::dr101_f; - using X::size_t; - extern "C" void dr101_f(); - typedef unsigned size_t; -} - -namespace dr102 { // dr102: yes - namespace A { - template<typename T> T f(T a, T b) { return a + b; } // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} - } - namespace B { - struct S {}; - } - B::S operator+(B::S, B::S); // expected-note {{should be declared prior to the call site or in namespace 'dr102::B'}} - template B::S A::f(B::S, B::S); // expected-note {{in instantiation of}} -} - -// dr103: na -// dr104: na lib -// dr105: na - -namespace dr106 { // dr106: sup 540 - typedef int &r1; - typedef r1 &r1; - typedef const r1 r1; // expected-warning {{has no effect}} - typedef const r1 &r1; // expected-warning {{has no effect}} - - typedef const int &r2; - typedef r2 &r2; - typedef const r2 r2; // expected-warning {{has no effect}} - typedef const r2 &r2; // expected-warning {{has no effect}} -} - -namespace dr107 { // dr107: yes - struct S {}; - extern "C" S operator+(S, S) { return S(); } -} - -namespace dr108 { // dr108: yes - template<typename T> struct A { - struct B { typedef int X; }; - B::X x; // expected-error {{missing 'typename'}} - struct C : B { X x; }; // expected-error {{unknown type name}} - }; - template<> struct A<int>::B { int X; }; -} - -namespace dr109 { // dr109: yes - struct A { template<typename T> void f(T); }; - template<typename T> struct B : T { - using T::template f; // expected-error {{'template' keyword not permitted here}} - using T::template f<int>; // expected-error {{'template' keyword not permitted here}} expected-error {{using declaration cannot refer to a template specialization}} - // FIXME: We shouldn't suggest using the 'template' keyword in a location where it's not valid. - using T::f<int>; // expected-error {{use 'template' keyword}} expected-error {{using declaration cannot refer to a template specialization}} - void g() { this->f<int>(123); } // expected-error {{use 'template' keyword}} - }; -} - -namespace dr111 { // dr111: dup 535 - struct A { A(); A(volatile A&, int = 0); A(A&, const char * = "foo"); }; - struct B : A { B(); }; // expected-note +{{would lose const qualifier}} expected-note {{requires 0 arguments}} - const B b1; - B b2(b1); // expected-error {{no matching constructor}} -} - -namespace dr112 { // dr112: yes - struct T { int n; }; - typedef T Arr[1]; - - const T a1[1] = {}; - volatile T a2[1] = {}; - const Arr a3 = {}; - volatile Arr a4 = {}; - template<const volatile T*> struct X {}; - X<a1> x1; - X<a2> x2; - X<a3> x3; - X<a4> x4; -#if __cplusplus < 201103L - // expected-error@-5 {{internal linkage}} expected-note@-10 {{here}} - // expected-error@-4 {{internal linkage}} expected-note@-9 {{here}} -#else - // FIXME: Test this somehow. -#endif -} - -namespace dr113 { // dr113: yes - extern void (*p)(); - void f() { - no_such_function(); // expected-error {{undeclared}} - p(); - } - void g(); - void (*p)() = &g; -} - -namespace dr114 { // dr114: yes - struct A { - virtual void f(int) = 0; // expected-note {{unimplemented}} - }; - struct B : A { - template<typename T> void f(T); - void g() { f(0); } - } b; // expected-error {{abstract}} -} - -namespace dr115 { // dr115: yes - template<typename T> int f(T); // expected-note +{{}} - template<typename T> int g(T); // expected-note +{{}} - template<typename T> int g(T, int); // expected-note +{{}} - - int k1 = f(&f); // expected-error {{no match}} - int k2 = f(&f<int>); - int k3 = f(&g<int>); // expected-error {{no match}} - - void h() { - (void)&f; // expected-error {{address of overloaded function 'f' cannot be cast to type 'void'}} - (void)&f<int>; - (void)&g<int>; // expected-error {{address of overloaded function 'g' cannot be cast to type 'void'}} - - &f; // expected-error {{reference to overloaded function could not be resolved}} - &f<int>; // expected-warning {{unused}} - &g<int>; // expected-error {{reference to overloaded function could not be resolved}} - } - - struct S { - template<typename T> static int f(T); - template<typename T> static int g(T); - template<typename T> static int g(T, int); - } s; - - int k4 = f(&s.f); // expected-error {{non-constant pointer to member}} - int k5 = f(&s.f<int>); - int k6 = f(&s.g<int>); // expected-error {{non-constant pointer to member}} - - void i() { - (void)&s.f; // expected-error {{non-constant pointer to member}} - (void)&s.f<int>; - (void)&s.g<int>; // expected-error {{non-constant pointer to member}} - - &s.f; // expected-error {{non-constant pointer to member}} - &s.f<int>; // expected-warning {{unused}} - &s.g<int>; // expected-error {{non-constant pointer to member}} - } - - struct T { - template<typename T> int f(T); - template<typename T> int g(T); - template<typename T> int g(T, int); - } t; - - int k7 = f(&s.f); // expected-error {{non-constant pointer to member}} - int k8 = f(&s.f<int>); - int k9 = f(&s.g<int>); // expected-error {{non-constant pointer to member}} - - void j() { - (void)&s.f; // expected-error {{non-constant pointer to member}} - (void)&s.f<int>; - (void)&s.g<int>; // expected-error {{non-constant pointer to member}} - - &s.f; // expected-error {{non-constant pointer to member}} - &s.f<int>; // expected-warning {{unused}} - &s.g<int>; // expected-error {{non-constant pointer to member}} - } - -#if __cplusplus >= 201103L - // Special case kicks in only if a template argument list is specified. - template<typename T=int> void with_default(); // expected-note +{{}} - int k10 = f(&with_default); // expected-error {{no matching function}} - int k11 = f(&with_default<>); - void k() { - (void)&with_default; // expected-error {{overloaded function}} - (void)&with_default<>; - &with_default; // expected-error {{overloaded function}} - &with_default<>; // expected-warning {{unused}} - } -#endif -} - -namespace dr116 { // dr116: yes - template<int> struct A {}; - template<int N> void f(A<N>) {} // expected-note {{previous}} - template<int M> void f(A<M>) {} // expected-error {{redefinition}} - template<typename T> void f(A<sizeof(T)>) {} // expected-note {{previous}} - template<typename U> void f(A<sizeof(U)>) {} // expected-error {{redefinition}} -} - -// dr117: na -// dr118 is in its own file. -// dr119: na -// dr120: na - -namespace dr121 { // dr121: yes - struct X { - template<typename T> struct Y {}; - }; - template<typename T> struct Z { - X::Y<T> x; - T::Y<T> y; // expected-error +{{}} - }; - Z<X> z; -} - -namespace dr122 { // dr122: yes - template<typename T> void f(); - void g() { f<int>(); } -} - -// dr123: na -// dr124: dup 201 - -// dr125: yes -struct dr125_A { struct dr125_B {}; }; // expected-note {{here}} -dr125_A::dr125_B dr125_C(); -namespace dr125_B { dr125_A dr125_C(); } -namespace dr125 { - struct X { - friend dr125_A::dr125_B (::dr125_C)(); // ok - friend dr125_A (::dr125_B::dr125_C)(); // ok - friend dr125_A::dr125_B::dr125_C(); // expected-error {{did you mean the constructor name 'dr125_B'?}} - // expected-error@-1 {{missing exception specification}} - }; -} - -namespace dr126 { // dr126: partial - // FIXME: We do not yet generate correct code for this change: - // eg: - // catch (void*&) should catch void* but not int* - // catch (void*) and catch (void*const&) should catch both - // Likewise: - // catch (Base *&) should catch Base* but not Derived* - // catch (Base *) should catch both - // In each case, we emit the same code for both catches. - // - // The ABI does not let us represent the language rule in the unwind tables. - // So, when catching by non-const (or volatile) reference to pointer, we - // should compare the exception type to the caught type and only accept an - // exact match. -#if __cplusplus <= 201402L - struct C {}; - struct D : C {}; - struct E : private C { friend class A; friend class B; }; - struct F : protected C {}; - struct G : C {}; - struct H : D, G {}; - - struct A { - virtual void cp() throw(C*); - virtual void dp() throw(C*); - virtual void ep() throw(C*); // expected-note {{overridden}} - virtual void fp() throw(C*); // expected-note {{overridden}} - virtual void gp() throw(C*); - virtual void hp() throw(C*); // expected-note {{overridden}} - - virtual void cr() throw(C&); - virtual void dr() throw(C&); - virtual void er() throw(C&); // expected-note {{overridden}} - virtual void fr() throw(C&); // expected-note {{overridden}} - virtual void gr() throw(C&); - virtual void hr() throw(C&); // expected-note {{overridden}} - - virtual void pv() throw(void*); - -#if __cplusplus >= 201103L - virtual void np() throw(C*); - virtual void npm() throw(int C::*); - virtual void nr() throw(C*&); // expected-note {{overridden}} - virtual void ncr() throw(C*const&); -#endif - - virtual void ref1() throw(C *const&); - virtual void ref2() throw(C *); - - virtual void v() throw(int); - virtual void w() throw(const int); - virtual void x() throw(int*); // expected-note {{overridden}} - virtual void y() throw(const int*); - virtual void z() throw(int); // expected-note {{overridden}} - }; - struct B : A { - virtual void cp() throw(C*); - virtual void dp() throw(D*); - virtual void ep() throw(E*); // expected-error {{more lax}} - virtual void fp() throw(F*); // expected-error {{more lax}} - virtual void gp() throw(G*); - virtual void hp() throw(H*); // expected-error {{more lax}} - - virtual void cr() throw(C&); - virtual void dr() throw(D&); - virtual void er() throw(E&); // expected-error {{more lax}} - virtual void fr() throw(F&); // expected-error {{more lax}} - virtual void gr() throw(G&); - virtual void hr() throw(H&); // expected-error {{more lax}} - - virtual void pv() throw(C*); - -#if __cplusplus >= 201103L - using nullptr_t = decltype(nullptr); - virtual void np() throw(nullptr_t); - virtual void npm() throw(nullptr_t&); - virtual void nr() throw(nullptr_t); // expected-error {{more lax}} - virtual void ncr() throw(nullptr_t); -#endif - - virtual void ref1() throw(D *const &); - virtual void ref2() throw(D *); - - virtual void v() throw(const int); - virtual void w() throw(int); - virtual void x() throw(const int*); // expected-error {{more lax}} - virtual void y() throw(int*); // ok - virtual void z() throw(long); // expected-error {{more lax}} - }; -#else - void f() throw(int); // expected-error {{ISO C++17 does not allow}} expected-note {{use 'noexcept}} -#endif -} - -namespace dr127 { // dr127: yes - __extension__ typedef __decltype(sizeof(0)) size_t; - template<typename T> struct A { - A() { throw 0; } - void *operator new(size_t, const char * = 0); - void operator delete(void *, const char *) { T::error; } // expected-error 2{{no members}} - void operator delete(void *) { T::error; } - }; - A<void> *p = new A<void>; // expected-note {{instantiat}} - A<int> *q = new ("") A<int>; // expected-note {{instantiat}} -} - -namespace dr128 { // dr128: yes - enum E1 { e1 } x = e1; - enum E2 { e2 } y = static_cast<E2>(x), z = static_cast<E2>(e1); -} - -// dr129: dup 616 -// dr130: na - -namespace dr131 { // dr131: yes - const char *a_with_\u0e8c = "\u0e8c"; - const char *b_with_\u0e8d = "\u0e8d"; - const char *c_with_\u0e8e = "\u0e8e"; -#if __cplusplus < 201103L - // expected-error@-4 {{expected ';'}} expected-error@-2 {{expected ';'}} -#endif -} - -namespace dr132 { // dr132: no - void f() { - extern struct {} x; // ok - extern struct S {} y; // FIXME: This is invalid. - } - static enum { E } e; -} - -// dr133: dup 87 -// dr134: na - -namespace dr135 { // dr135: yes - struct A { - A f(A a) { return a; } - friend A g(A a) { return a; } - static A h(A a) { return a; } - }; -} - -namespace dr136 { // dr136: 3.4 - void f(int, int, int = 0); // expected-note {{previous declaration is here}} - void g(int, int, int); // expected-note {{previous declaration is here}} - struct A { - friend void f(int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - friend void g(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - friend void h(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}} - friend void i(int, int, int = 0) {} // expected-note {{previous declaration is here}} - friend void j(int, int, int = 0) {} - operator int(); - }; - void i(int, int, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - void q() { - j(A(), A()); // ok, has default argument - } - extern "C" void k(int, int, int, int); // expected-note {{previous declaration is here}} - namespace NSA { - struct A { - friend void dr136::k(int, int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - }; - } - namespace NSB { - struct A { - friend void dr136::k(int, int, int = 0, int); // expected-error {{missing default argument on parameter}} - }; - } - struct B { - void f(int); // expected-note {{previous declaration is here}} - }; - struct C { - friend void B::f(int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - }; -} - -namespace dr137 { // dr137: yes - extern void *p; - extern const void *cp; - extern volatile void *vp; - extern const volatile void *cvp; - int *q = static_cast<int*>(p); - int *qc = static_cast<int*>(cp); // expected-error {{casts away qualifiers}} - int *qv = static_cast<int*>(vp); // expected-error {{casts away qualifiers}} - int *qcv = static_cast<int*>(cvp); // expected-error {{casts away qualifiers}} - const int *cq = static_cast<const int*>(p); - const int *cqc = static_cast<const int*>(cp); - const int *cqv = static_cast<const int*>(vp); // expected-error {{casts away qualifiers}} - const int *cqcv = static_cast<const int*>(cvp); // expected-error {{casts away qualifiers}} - const volatile int *cvq = static_cast<const volatile int*>(p); - const volatile int *cvqc = static_cast<const volatile int*>(cp); - const volatile int *cvqv = static_cast<const volatile int*>(vp); - const volatile int *cvqcv = static_cast<const volatile int*>(cvp); -} - -namespace dr139 { // dr139: yes - namespace example1 { - typedef int f; // expected-note {{previous}} - struct A { - friend void f(A &); // expected-error {{different kind of symbol}} - }; - } - - namespace example2 { - typedef int f; - namespace N { - struct A { - friend void f(A &); - operator int(); - void g(A a) { int i = f(a); } // ok, f is typedef not friend function - }; - } - } -} - -namespace dr140 { // dr140: yes - void f(int *const) {} // expected-note {{previous}} - void f(int[3]) {} // expected-error {{redefinition}} - void g(const int); - void g(int n) { n = 2; } -} - -namespace dr141 { // dr141: yes - template<typename T> void f(); - template<typename T> struct S { int n; }; - struct A : S<int> { - template<typename T> void f(); - template<typename T> struct S {}; - } a; - struct B : S<int> {} b; - void g() { - a.f<int>(); - (void)a.S<int>::n; // expected-error {{no member named 'n'}} -#if __cplusplus < 201103L - // expected-error@-2 {{ambiguous}} - // expected-note@-11 {{lookup from the current scope}} - // expected-note@-9 {{lookup in the object type}} -#endif - b.f<int>(); // expected-error {{no member}} expected-error +{{}} - (void)b.S<int>::n; - } - template<typename T> struct C { - T t; - void g() { - t.f<int>(); // expected-error {{use 'template'}} - } - void h() { - (void)t.S<int>::n; // ok - } - void i() { - (void)t.S<int>(); // ok! - } - }; - void h() { C<B>().h(); } // ok - struct X { - template<typename T> void S(); - }; - void i() { C<X>().i(); } // ok!! -} - -namespace dr142 { // dr142: yes - class B { // expected-note +{{here}} - public: - int mi; // expected-note +{{here}} - static int si; // expected-note +{{here}} - }; - class D : private B { // expected-note +{{here}} - }; - class DD : public D { - void f(); - }; - void DD::f() { - mi = 3; // expected-error {{private base class}} expected-error {{private member}} - si = 3; // expected-error {{private member}} - B b_old; // expected-error {{private member}} - dr142::B b; - b.mi = 3; - b.si = 3; - B::si = 3; // expected-error {{private member}} - dr142::B::si = 3; - B *bp1_old = this; // expected-error {{private member}} expected-error {{private base class}} - dr142::B *bp1 = this; // expected-error {{private base class}} - B *bp2_old = (B*)this; // expected-error 2{{private member}} - dr142::B *bp2 = (dr142::B*)this; - bp2->mi = 3; - } -} - -namespace dr143 { // dr143: yes - namespace A { struct X; } - namespace B { void f(A::X); } - namespace A { - struct X { friend void B::f(X); }; - } - void g(A::X x) { - f(x); // expected-error {{undeclared identifier 'f'}} - } -} - -namespace dr145 { // dr145: yes - void f(bool b) { -#if __cplusplus <= 201402L - ++b; // expected-warning {{deprecated}} - b++; // expected-warning {{deprecated}} -#else - ++b; // expected-error {{increment}} - b++; // expected-error {{increment}} -#endif - } -} - -namespace dr147 { // dr147: yes - namespace example1 { - template<typename> struct A { - template<typename T> A(T); - }; - // Per core issue 1435, this is ill-formed because A<int>::A<int> does not - // name the injected-class-name. (A<int>::A does, though.) - template<> template<> A<int>::A<int>(int) {} // expected-error {{out-of-line constructor for 'A' cannot have template arguments}} - template<> template<> A<float>::A(float) {} - } - namespace example2 { - struct A { A(); }; - struct B : A { B(); }; - A::A a1; // expected-error {{is a constructor}} - B::A a2; - } - namespace example3 { - template<typename> struct A { - template<typename T> A(T); - static A a; - }; - template<> A<int>::A<int>(A<int>::a); // expected-error {{is a constructor}} - } -} - -namespace dr148 { // dr148: yes - struct A { int A::*p; }; - int check1[__is_pod(int(A::*)) ? 1 : -1]; - int check2[__is_pod(A) ? 1 : -1]; -} - -// dr149: na - -namespace dr151 { // dr151: yes - struct X {}; - typedef int X::*p; -#if __cplusplus < 201103L -#define fold(x) (__builtin_constant_p(0) ? (x) : (x)) -#else -#define fold -#endif - int check[fold(p() == 0) ? 1 : -1]; -#undef fold -} - -namespace dr152 { // dr152: yes - struct A { - A(); // expected-note 0-2{{not viable}} - explicit A(const A&); - }; - A a1 = A(); -#if __cplusplus <= 201402L - // expected-error@-2 {{no matching constructor}} -#endif - A a2((A())); - - A &f(); - A a3 = f(); // expected-error {{no matching constructor}} - A a4(f()); -} - -// dr153: na - -namespace dr154 { // dr154: yes - union { int a; }; // expected-error {{must be declared 'static'}} - namespace { - union { int b; }; - } - static union { int c; }; -} - -namespace dr155 { // dr155: dup 632 - struct S { int n; } s = { { 1 } }; // expected-warning {{braces around scalar initializer}} -} - -// dr158 is in its own file. - -namespace dr159 { // dr159: 3.5 - namespace X { void f(); } - void f(); - void dr159::f() {} // expected-warning {{extra qualification}} - void dr159::X::f() {} -} - -// dr160: na - -namespace dr161 { // dr161: yes - class A { - protected: - struct B { int n; } b; // expected-note 2{{here}} - static B bs; - void f(); // expected-note {{here}} - static void sf(); - }; - struct C : A {}; - struct D : A { - void g(C c) { - (void)b.n; - B b1; - C::B b2; // ok, accessible as a member of A - (void)&C::b; // expected-error {{protected}} - (void)&C::bs; - (void)c.b; // expected-error {{protected}} - (void)c.bs; - f(); - sf(); - c.f(); // expected-error {{protected}} - c.sf(); - A::f(); - D::f(); - A::sf(); - C::sf(); - D::sf(); - } - }; -} - -namespace dr162 { // dr162: no - struct A { - char &f(char); - static int &f(int); - - void g() { - int &a = (&A::f)(0); // FIXME: expected-error {{could not be resolved}} - char &b = (&A::f)('0'); // expected-error {{could not be resolved}} - } - }; - - int &c = (&A::f)(0); // FIXME: expected-error {{could not be resolved}} - char &d = (&A::f)('0'); // expected-error {{could not be resolved}} -} - -// dr163: na - -namespace dr164 { // dr164: yes - void f(int); - template <class T> int g(T t) { return f(t); } - - enum E { e }; - int f(E); - - int k = g(e); -} - -namespace dr165 { // dr165: no - namespace N { - struct A { friend struct B; }; - void f() { void g(); } - } - // FIXME: dr1477 says this is ok, dr165 says it's ill-formed - struct N::B {}; - // FIXME: dr165 says this is ill-formed, but the argument in dr1477 says it's ok - void N::g() {} -} - -namespace dr166 { // dr166: yes - namespace A { class X; } - - template<typename T> int f(T t) { return t.n; } - int g(A::X); - template<typename T> int h(T t) { return t.n; } // expected-error {{private}} - int i(A::X); - - namespace A { - class X { - friend int f<X>(X); - friend int dr166::g(X); - friend int h(X); - friend int i(X); - int n; // expected-note 2{{here}} - }; - - int h(X x) { return x.n; } - int i(X x) { return x.n; } - } - - template int f(A::X); - int g(A::X x) { return x.n; } - template int h(A::X); // expected-note {{instantiation}} - int i(A::X x) { return x.n; } // expected-error {{private}} -} - -// dr167: sup 1012 - -namespace dr168 { // dr168: no - extern "C" typedef int (*p)(); - extern "C++" typedef int (*q)(); - struct S { - static int f(); - }; - p a = &S::f; // FIXME: this should fail. - q b = &S::f; -} - -namespace dr169 { // dr169: yes - template<typename> struct A { int n; }; - struct B { - template<typename> struct C; - template<typename> void f(); - template<typename> static int n; // expected-error 0-1{{extension}} - }; - struct D : A<int>, B { - using A<int>::n; - using B::C<int>; // expected-error {{using declaration cannot refer to a template specialization}} - using B::f<int>; // expected-error {{using declaration cannot refer to a template specialization}} - using B::n<int>; // expected-error {{using declaration cannot refer to a template specialization}} - }; -} - -namespace { // dr171: yes - int dr171a; -} -int dr171b; // expected-note {{here}} -namespace dr171 { - extern "C" void dr171a(); - extern "C" void dr171b(); // expected-error {{conflicts}} -} - -namespace dr172 { // dr172: yes - enum { zero }; - int check1[-1 < zero ? 1 : -1]; - - enum { x = -1, y = (unsigned int)-1 }; - int check2[sizeof(x) > sizeof(int) ? 1 : -1]; - - enum { a = (unsigned int)-1 / 2 }; - int check3a[sizeof(a) == sizeof(int) ? 1 : -1]; - int check3b[-a < 0 ? 1 : -1]; - - enum { b = (unsigned int)-1 / 2 + 1 }; - int check4a[sizeof(b) == sizeof(unsigned int) ? 1 : -1]; - int check4b[-b > 0 ? 1 : -1]; - - enum { c = (unsigned long)-1 / 2 }; - int check5a[sizeof(c) == sizeof(long) ? 1 : -1]; - int check5b[-c < 0 ? 1 : -1]; - - enum { d = (unsigned long)-1 / 2 + 1 }; - int check6a[sizeof(d) == sizeof(unsigned long) ? 1 : -1]; - int check6b[-d > 0 ? 1 : -1]; - - enum { e = (unsigned long long)-1 / 2 }; // expected-error 0-1{{extension}} - int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; // expected-error 0-1{{extension}} - int check7b[-e < 0 ? 1 : -1]; - - enum { f = (unsigned long long)-1 / 2 + 1 }; // expected-error 0-1{{extension}} - int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; // expected-error 0-1{{extension}} - int check8b[-f > 0 ? 1 : -1]; -} - -namespace dr173 { // dr173: yes - int check[('0' + 1 == '1' && '0' + 2 == '2' && '0' + 3 == '3' && - '0' + 4 == '4' && '0' + 5 == '5' && '0' + 6 == '6' && - '0' + 7 == '7' && '0' + 8 == '8' && '0' + 9 == '9') ? 1 : -1]; -} - -// dr174: sup 1012 - -namespace dr175 { // dr175: yes - struct A {}; // expected-note {{here}} - struct B : private A {}; // expected-note {{constrained by private inheritance}} - struct C : B { - A a; // expected-error {{private}} - dr175::A b; - }; -} - -namespace dr176 { // dr176: yes - template<typename T> class Y; - template<> class Y<int> { - void f() { - typedef Y A; // expected-note {{here}} - typedef Y<char> A; // expected-error {{different types ('Y<char>' vs 'Y<int>')}} - } - }; - - template<typename T> struct Base {}; // expected-note 2{{found}} - template<typename T> struct Derived : public Base<T> { - void f() { - typedef typename Derived::template Base<T> A; - typedef typename Derived::Base A; - } - }; - template struct Derived<int>; - - template<typename T> struct Derived2 : Base<int>, Base<char> { - typename Derived2::Base b; // expected-error {{found in multiple base classes}} - typename Derived2::Base<double> d; - }; - - template<typename T> class X { // expected-note {{here}} - X *p1; - X<T> *p2; - X<int> *p3; - dr176::X *p4; // expected-error {{requires template arguments}} - }; -} - -namespace dr177 { // dr177: yes - struct B {}; - struct A { - A(A &); // expected-note 0-1{{not viable: expects an l-value}} - A(const B &); // expected-note 0-1{{not viable: no known conversion from 'dr177::A' to}} - }; - B b; - A a = b; -#if __cplusplus <= 201402L - // expected-error@-2 {{no viable constructor copying variable}} -#endif - - struct C { C(C&); }; // expected-note {{not viable: no known conversion from 'dr177::D' to 'dr177::C &'}} - struct D : C {}; - struct E { operator D(); }; - E e; - C c = e; // expected-error {{no viable constructor copying variable of type 'dr177::D'}} -} - -namespace dr178 { // dr178: yes - int check[int() == 0 ? 1 : -1]; -#if __cplusplus >= 201103L - static_assert(int{} == 0, ""); - struct S { int a, b; }; - static_assert(S{1}.b == 0, ""); - struct T { constexpr T() : n() {} int n; }; - static_assert(T().n == 0, ""); - struct U : S { constexpr U() : S() {} }; - static_assert(U().b == 0, ""); -#endif -} - -namespace dr179 { // dr179: yes - void f(); - int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} -} - -namespace dr180 { // dr180: yes - template<typename T> struct X : T, T::some_base { - X() : T::some_type_that_might_be_T(), T::some_base() {} - friend class T::some_class; - void f() { - enum T::some_enum e; - } - }; -} - -namespace dr181 { // dr181: yes - namespace X { - template <template X<class T> > struct A { }; // expected-error +{{}} - template <template X<class T> > void f(A<X>) { } // expected-error +{{}} - } - - namespace Y { - template <template <class T> class X> struct A { }; - template <template <class T> class X> void f(A<X>) { } - } -} - -namespace dr182 { // dr182: yes - template <class T> struct C { - void f(); - void g(); - }; - - template <class T> void C<T>::f() {} - template <class T> void C<T>::g() {} - - class A { - class B {}; // expected-note {{here}} - void f(); - }; - - template void C<A::B>::f(); - template <> void C<A::B>::g(); // expected-error {{private}} - - void A::f() { - C<B> cb; - cb.f(); - } -} - -namespace dr183 { // dr183: sup 382 - template<typename T> struct A {}; - template<typename T> struct B { - typedef int X; - }; - template<> struct A<int> { -#if __cplusplus <= 199711 - typename B<int>::X x; // expected-error {{'typename' occurs outside of a template}} -#else - typename B<int>::X x; -#endif - }; -} - -namespace dr184 { // dr184: yes - template<typename T = float> struct B {}; - - template<template<typename TT = float> class T> struct A { - void f(); - void g(); - }; - - template<template<typename TT> class T> void A<T>::f() { // expected-note {{here}} - T<> t; // expected-error {{too few template arguments}} - } - - template<template<typename TT = char> class T> void A<T>::g() { - T<> t; - typedef T<> X; - typedef T<char> X; - } - - void h() { A<B>().g(); } -} - -// dr185 FIXME: add codegen test - -namespace dr187 { // dr187: sup 481 - const int Z = 1; - template<int X = Z, int Z = X> struct A; - typedef A<> T; - typedef A<1, 1> T; -} - -namespace dr188 { // dr188: yes - char c[10]; - int check[sizeof(0, c) == 10 ? 1 : -1]; -} - -// dr190 FIXME: add codegen test for tbaa - -// dr193 FIXME: add codegen test - -namespace dr194 { // dr194: yes - struct A { - A(); - void A(); // expected-error {{constructor cannot have a return type}} - }; - struct B { - void B(); // expected-error {{constructor cannot have a return type}} - B(); - }; - struct C { - inline explicit C(int) {} - }; -} - -namespace dr195 { // dr195: yes - void f(); - int *p = (int*)&f; // expected-error 0-1{{extension}} - void (*q)() = (void(*)())&p; // expected-error 0-1{{extension}} -} - -namespace dr197 { // dr197: yes - char &f(char); - - template <class T> void g(T t) { - char &a = f(1); - char &b = f(T(1)); // expected-error {{unrelated type 'int'}} - char &c = f(t); // expected-error {{unrelated type 'int'}} - } - - void f(int); - - enum E { e }; - int &f(E); - - void h() { - g('a'); - g(2); - g(e); // expected-note {{in instantiation of}} - } -} - -namespace dr198 { // dr198: yes - struct A { - int n; - struct B { - int m[sizeof(n)]; -#if __cplusplus < 201103L - // expected-error@-2 {{invalid use of non-static data member}} -#endif - int f() { return n; } - // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'B'}} - }; - struct C; - struct D; - }; - struct A::C { - int m[sizeof(n)]; -#if __cplusplus < 201103L - // expected-error@-2 {{invalid use of non-static data member}} -#endif - int f() { return n; } - // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'C'}} - }; - struct A::D : A { - int m[sizeof(n)]; -#if __cplusplus < 201103L - // expected-error@-2 {{invalid use of non-static data member}} -#endif - int f() { return n; } - }; -} - -// dr199 FIXME: add codegen test diff --git a/test/CXX/drs/dr20xx.cpp b/test/CXX/drs/dr20xx.cpp deleted file mode 100644 index 5819c319fd54..000000000000 --- a/test/CXX/drs/dr20xx.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors \ -// RUN: -Wno-variadic-macros -Wno-c11-extensions -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -// expected-no-diagnostics - -#if __cplusplus < 201103L -#define static_assert(...) _Static_assert(__VA_ARGS__) -#endif - -namespace dr2094 { // dr2094: 5 - struct A { int n; }; - struct B { volatile int n; }; - static_assert(__is_trivially_copyable(volatile int), ""); - static_assert(__is_trivially_copyable(const volatile int), ""); - static_assert(__is_trivially_copyable(const volatile int[]), ""); - static_assert(__is_trivially_copyable(A), ""); - static_assert(__is_trivially_copyable(volatile A), ""); - static_assert(__is_trivially_copyable(const volatile A), ""); - static_assert(__is_trivially_copyable(const volatile A[]), ""); - static_assert(__is_trivially_copyable(B), ""); - - static_assert(__is_trivially_constructible(A, A const&), ""); - static_assert(__is_trivially_constructible(B, B const&), ""); - - static_assert(__is_trivially_assignable(A, const A&), ""); - static_assert(__is_trivially_assignable(B, const B&), ""); -} diff --git a/test/CXX/drs/dr21xx.cpp b/test/CXX/drs/dr21xx.cpp deleted file mode 100644 index 2522ff7dbdef..000000000000 --- a/test/CXX/drs/dr21xx.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-error@+1 {{variadic macro}} -#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__) -#endif - -namespace dr2120 { // dr2120: 7 - struct A {}; - struct B : A {}; - struct C { A a; }; - struct D { C c[5]; }; - struct E : B { D d; }; - static_assert(__is_standard_layout(B), ""); - static_assert(__is_standard_layout(D), ""); - static_assert(!__is_standard_layout(E), ""); -} - -namespace dr2180 { // dr2180: yes - class A { - A &operator=(const A &); // expected-note 0-2{{here}} - A &operator=(A &&); // expected-note 0-2{{here}} expected-error 0-1{{extension}} - }; - - struct B : virtual A { - B &operator=(const B &); - B &operator=(B &&); // expected-error 0-1{{extension}} - virtual void foo() = 0; - }; -#if __cplusplus < 201103L - B &B::operator=(const B&) = default; // expected-error {{private member}} expected-error {{extension}} expected-note {{here}} - B &B::operator=(B&&) = default; // expected-error {{private member}} expected-error 2{{extension}} expected-note {{here}} -#else - B &B::operator=(const B&) = default; // expected-error {{would delete}} expected-note@-9{{inaccessible copy assignment}} - B &B::operator=(B&&) = default; // expected-error {{would delete}} expected-note@-10{{inaccessible move assignment}} -#endif -} diff --git a/test/CXX/drs/dr22xx.cpp b/test/CXX/drs/dr22xx.cpp deleted file mode 100644 index 70a26db757c3..000000000000 --- a/test/CXX/drs/dr22xx.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr2229 { // dr2229: 7 -struct AnonBitfieldQualifiers { - const unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} - volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} - const volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} - - unsigned : 1; - const unsigned i1 : 1; - volatile unsigned i2 : 1; - const volatile unsigned i3 : 1; -}; -} - -#if __cplusplus >= 201103L -namespace dr2211 { // dr2211: 8 -void f() { - int a; - auto f = [a](int a) { (void)a; }; // expected-error {{a lambda parameter cannot shadow an explicitly captured entity}} - // expected-note@-1{{variable 'a' is explicitly captured here}} - auto g = [=](int a) { (void)a; }; -} -} -#endif diff --git a/test/CXX/drs/dr2xx.cpp b/test/CXX/drs/dr2xx.cpp deleted file mode 100644 index b69c014b587f..000000000000 --- a/test/CXX/drs/dr2xx.cpp +++ /dev/null @@ -1,1079 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -// PR13819 -- __SIZE_TYPE__ is incompatible. -typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}} - -#if __cplusplus < 201103L -#define fold(x) (__builtin_constant_p(x) ? (x) : (x)) -#else -#define fold -#endif - -namespace dr200 { // dr200: dup 214 - template <class T> T f(int); - template <class T, class U> T f(U) = delete; // expected-error 0-1{{extension}} - - void g() { - f<int>(1); - } -} - -// dr201 FIXME: write codegen test - -namespace dr202 { // dr202: yes - template<typename T> T f(); - template<int (*g)()> struct X { - int arr[fold(g == &f<int>) ? 1 : -1]; - }; - template struct X<f>; -} - -// FIXME (export) dr204: no - -namespace dr206 { // dr206: yes - struct S; // expected-note 2{{declaration}} - template<typename T> struct Q { S s; }; // expected-error {{incomplete}} - template<typename T> void f() { S s; } // expected-error {{incomplete}} -} - -namespace dr207 { // dr207: yes - class A { - protected: - static void f() {} - }; - class B : A { - public: - using A::f; - void g() { - A::f(); - f(); - } - }; -} - -// dr208 FIXME: write codegen test - -namespace dr209 { // dr209: yes - class A { - void f(); // expected-note {{here}} - }; - class B { - friend void A::f(); // expected-error {{private}} - }; -} - -// dr210 FIXME: write codegen test - -namespace dr211 { // dr211: yes - struct A { - A() try { - throw 0; - } catch (...) { - return; // expected-error {{return in the catch of a function try block of a constructor}} - } - }; -} - -namespace dr213 { // dr213: yes - template <class T> struct A : T { - void h(T t) { - char &r1 = f(t); - int &r2 = g(t); // expected-error {{undeclared}} - } - }; - struct B { - int &f(B); - int &g(B); // expected-note {{in dependent base class}} - }; - char &f(B); - - template void A<B>::h(B); // expected-note {{instantiation}} -} - -namespace dr214 { // dr214: yes - template<typename T, typename U> T checked_cast(U from) { U::error; } - template<typename T, typename U> T checked_cast(U *from); - class C {}; - void foo(int *arg) { checked_cast<const C *>(arg); } - - template<typename T> T f(int); - template<typename T, typename U> T f(U) { T::error; } - void g() { - f<int>(1); - } -} - -namespace dr215 { // dr215: yes - template<typename T> class X { - friend void T::foo(); - int n; - }; - struct Y { - void foo() { (void)+X<Y>().n; } - }; -} - -namespace dr216 { // dr216: no - // FIXME: Should reject this: 'f' has linkage but its type does not, - // and 'f' is odr-used but not defined in this TU. - typedef enum { e } *E; - void f(E); - void g(E e) { f(e); } - - struct S { - // FIXME: Should reject this: 'f' has linkage but its type does not, - // and 'f' is odr-used but not defined in this TU. - typedef enum { e } *E; - void f(E); - }; - void g(S s, S::E e) { s.f(e); } -} - -namespace dr217 { // dr217: yes - template<typename T> struct S { - void f(int); - }; - template<typename T> void S<T>::f(int = 0) {} // expected-error {{default arguments cannot be added}} -} - -namespace dr218 { // dr218: yes - namespace A { - struct S {}; - void f(S); - } - namespace B { - struct S {}; - void f(S); - } - - struct C { - int f; - void test1(A::S as) { f(as); } // expected-error {{called object type 'int'}} - void test2(A::S as) { void f(); f(as); } // expected-error {{too many arguments}} expected-note {{}} - void test3(A::S as) { using A::f; f(as); } // ok - void test4(A::S as) { using B::f; f(as); } // ok - void test5(A::S as) { int f; f(as); } // expected-error {{called object type 'int'}} - void test6(A::S as) { struct f {}; (void) f(as); } // expected-error {{no matching conversion}} expected-note +{{}} - }; - - namespace D { - struct S {}; - struct X { void operator()(S); } f; - } - void testD(D::S ds) { f(ds); } // expected-error {{undeclared identifier}} - - namespace E { - struct S {}; - struct f { f(S); }; - } - void testE(E::S es) { f(es); } // expected-error {{undeclared identifier}} - - namespace F { - struct S { - template<typename T> friend void f(S, T) {} - }; - } - void testF(F::S fs) { f(fs, 0); } - - namespace G { - namespace X { - int f; - struct A {}; - } - namespace Y { - template<typename T> void f(T); - struct B {}; - } - template<typename A, typename B> struct C {}; - } - void testG(G::C<G::X::A, G::Y::B> gc) { f(gc); } -} - -// dr219: na -// dr220: na - -namespace dr221 { // dr221: yes - struct A { // expected-note 2-4{{candidate}} - A &operator=(int&); // expected-note 2{{candidate}} - A &operator+=(int&); - static A &operator=(A&, double&); // expected-error {{cannot be a static member}} - static A &operator+=(A&, double&); // expected-error {{cannot be a static member}} - friend A &operator=(A&, char&); // expected-error {{must be a non-static member function}} - friend A &operator+=(A&, char&); - }; - A &operator=(A&, float&); // expected-error {{must be a non-static member function}} - A &operator+=(A&, float&); - - void test(A a, int n, char c, float f) { - a = n; - a += n; - a = c; // expected-error {{no viable}} - a += c; - a = f; // expected-error {{no viable}} - a += f; - } -} - -namespace dr222 { // dr222: dup 637 - void f(int a, int b, int c, int *x) { -#pragma clang diagnostic push -#pragma clang diagnostic warning "-Wunsequenced" - void((a += b) += c); - void((a += b) + (a += c)); // expected-warning {{multiple unsequenced modifications to 'a'}} - - x[a++] = a; // expected-warning {{unsequenced modification and access to 'a'}} - - a = b = 0; // ok, read and write of 'b' are sequenced - - a = (b = a++); // expected-warning {{multiple unsequenced modifications to 'a'}} - a = (b = ++a); -#pragma clang diagnostic pop - } -} - -// dr223: na - -namespace dr224 { // dr224: no - namespace example1 { - template <class T> class A { - typedef int type; - A::type a; - A<T>::type b; - A<T*>::type c; // expected-error {{missing 'typename'}} - ::dr224::example1::A<T>::type d; - - class B { - typedef int type; - - A::type a; - A<T>::type b; - A<T*>::type c; // expected-error {{missing 'typename'}} - ::dr224::example1::A<T>::type d; - - B::type e; - A<T>::B::type f; - A<T*>::B::type g; // expected-error {{missing 'typename'}} - typename A<T*>::B::type h; - }; - }; - - template <class T> class A<T*> { - typedef int type; - A<T*>::type a; - A<T>::type b; // expected-error {{missing 'typename'}} - }; - - template <class T1, class T2, int I> struct B { - typedef int type; - B<T1, T2, I>::type b1; - B<T2, T1, I>::type b2; // expected-error {{missing 'typename'}} - - typedef T1 my_T1; - static const int my_I = I; - static const int my_I2 = I+0; - static const int my_I3 = my_I; - B<my_T1, T2, my_I>::type b3; // FIXME: expected-error {{missing 'typename'}} - B<my_T1, T2, my_I2>::type b4; // expected-error {{missing 'typename'}} - B<my_T1, T2, my_I3>::type b5; // FIXME: expected-error {{missing 'typename'}} - }; - } - - namespace example2 { - template <int, typename T> struct X { typedef T type; }; - template <class T> class A { - static const int i = 5; - X<i, int>::type w; // FIXME: expected-error {{missing 'typename'}} - X<A::i, char>::type x; // FIXME: expected-error {{missing 'typename'}} - X<A<T>::i, double>::type y; // FIXME: expected-error {{missing 'typename'}} - X<A<T*>::i, long>::type z; // expected-error {{missing 'typename'}} - int f(); - }; - template <class T> int A<T>::f() { - return i; - } - } -} - -// dr225: yes -template<typename T> void dr225_f(T t) { dr225_g(t); } // expected-error {{call to function 'dr225_g' that is neither visible in the template definition nor found by argument-dependent lookup}} -void dr225_g(int); // expected-note {{should be declared prior to the call site}} -template void dr225_f(int); // expected-note {{in instantiation of}} - -namespace dr226 { // dr226: no - template<typename T = void> void f() {} -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} - // FIXME: This appears to be wrong: default arguments for function templates - // are listed as a defect (in c++98) not an extension. EDG accepts them in - // strict c++98 mode. -#endif - template<typename T> struct S { - template<typename U = void> void g(); -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} -#endif - template<typename U> struct X; - template<typename U> void h(); - }; - template<typename T> template<typename U> void S<T>::g() {} - template<typename T> template<typename U = void> struct S<T>::X {}; // expected-error {{cannot add a default template arg}} - template<typename T> template<typename U = void> void S<T>::h() {} // expected-error {{cannot add a default template arg}} - - template<typename> void friend_h(); - struct A { - // FIXME: This is ill-formed. - template<typename=void> struct friend_B; - // FIXME: f, h, and i are ill-formed. - // f is ill-formed because it is not a definition. - // h and i are ill-formed because they are not the only declarations of the - // function in the translation unit. - template<typename=void> void friend_f(); - template<typename=void> void friend_g() {} - template<typename=void> void friend_h() {} - template<typename=void> void friend_i() {} -#if __cplusplus < 201103L - // expected-error@-5 {{extension}} expected-error@-4 {{extension}} - // expected-error@-4 {{extension}} expected-error@-3 {{extension}} -#endif - }; - template<typename> void friend_i(); - - template<typename=void, typename X> void foo(X) {} - template<typename=void, typename X> struct Foo {}; // expected-error {{missing a default argument}} expected-note {{here}} -#if __cplusplus < 201103L - // expected-error@-3 {{extension}} -#endif - - template<typename=void, typename X, typename, typename Y> int foo(X, Y); - template<typename, typename X, typename=void, typename Y> int foo(X, Y); - int x = foo(0, 0); -#if __cplusplus < 201103L - // expected-error@-4 {{extension}} - // expected-error@-4 {{extension}} -#endif -} - -void dr227(bool b) { // dr227: yes - if (b) - int n; - else - int n; -} - -namespace dr228 { // dr228: yes - template <class T> struct X { - void f(); - }; - template <class T> struct Y { - void g(X<T> x) { x.template X<T>::f(); } - }; -} - -namespace dr229 { // dr229: yes - template<typename T> void f(); - template<typename T> void f<T*>() {} // expected-error {{function template partial specialization}} - template<> void f<int>() {} -} - -namespace dr230 { // dr230: yes - struct S { - S() { f(); } // expected-warning {{call to pure virtual member function}} - virtual void f() = 0; // expected-note {{declared here}} - }; -} - -namespace dr231 { // dr231: yes - namespace outer { - namespace inner { - int i; // expected-note {{here}} - } - void f() { using namespace inner; } - int j = i; // expected-error {{undeclared identifier 'i'; did you mean 'inner::i'?}} - } -} - -// dr234: na -// dr235: na - -namespace dr236 { // dr236: yes - void *p = int(); -#if __cplusplus < 201103L - // expected-warning@-2 {{null pointer}} -#else - // expected-error@-4 {{cannot initialize}} -#endif -} - -namespace dr237 { // dr237: dup 470 - template<typename T> struct A { void f() { T::error; } }; - template<typename T> struct B : A<T> {}; - template struct B<int>; // ok -} - -namespace dr239 { // dr239: yes - namespace NS { - class T {}; - void f(T); - float &g(T, int); - } - NS::T parm; - int &g(NS::T, float); - int main() { - f(parm); - float &r = g(parm, 1); - extern int &g(NS::T, float); - int &s = g(parm, 1); - } -} - -// dr240: dup 616 - -namespace dr241 { // dr241: yes - namespace A { - struct B {}; - template <int X> void f(); // expected-note 2{{candidate}} - template <int X> void g(B); - } - namespace C { - template <class T> void f(T t); // expected-note 2{{candidate}} - template <class T> void g(T t); // expected-note {{candidate}} - } - void h(A::B b) { - f<3>(b); // expected-error {{undeclared identifier}} - g<3>(b); // expected-error {{undeclared identifier}} - A::f<3>(b); // expected-error {{no matching}} - A::g<3>(b); - C::f<3>(b); // expected-error {{no matching}} - C::g<3>(b); // expected-error {{no matching}} - using C::f; - using C::g; - f<3>(b); // expected-error {{no matching}} - g<3>(b); - } -} - -namespace dr243 { // dr243: yes - struct B; - struct A { - A(B); // expected-note {{candidate}} - }; - struct B { - operator A() = delete; // expected-error 0-1{{extension}} expected-note {{candidate}} - } b; - A a1(b); - A a2 = b; // expected-error {{ambiguous}} -} - -namespace dr244 { // dr244: partial - struct B {}; struct D : B {}; // expected-note {{here}} - - D D_object; - typedef B B_alias; - B* B_ptr = &D_object; - - void f() { - D_object.~B(); // expected-error {{expression does not match the type}} - D_object.B::~B(); - B_ptr->~B(); - B_ptr->~B_alias(); - B_ptr->B_alias::~B(); - // This is valid under DR244. - B_ptr->B_alias::~B_alias(); - B_ptr->dr244::~B(); // expected-error {{refers to a member in namespace}} - B_ptr->dr244::~B_alias(); // expected-error {{refers to a member in namespace}} - } - - namespace N { - template<typename T> struct E {}; - typedef E<int> F; - } - void g(N::F f) { - typedef N::F G; - f.~G(); - f.G::~E(); - f.G::~F(); // expected-error {{expected the class name after '~' to name a destructor}} - f.G::~G(); - // This is technically ill-formed; E is looked up in 'N::' and names the - // class template, not the injected-class-name of the class. But that's - // probably a bug in the standard. - f.N::F::~E(); - // This is valid; we look up the second F in the same scope in which we - // found the first one, that is, 'N::'. - f.N::F::~F(); // FIXME: expected-error {{expected the class name after '~' to name a destructor}} - // This is technically ill-formed; G is looked up in 'N::' and is not found; - // as above, this is probably a bug in the standard. - f.N::F::~G(); - } -} - -namespace dr245 { // dr245: yes - struct S { - enum E {}; // expected-note {{here}} - class E *p; // expected-error {{does not match previous declaration}} - }; -} - -namespace dr246 { // dr246: yes - struct S { - S() try { // expected-note {{try block}} - throw 0; -X: ; - } catch (int) { - goto X; // expected-error {{cannot jump}} - } - }; -} - -namespace dr247 { // dr247: yes - struct A {}; - struct B : A { - void f(); - void f(int); - }; - void (A::*f)() = (void (A::*)())&B::f; - - struct C { - void f(); - void f(int); - }; - struct D : C {}; - void (C::*g)() = &D::f; - void (D::*h)() = &D::f; - - struct E { - void f(); - }; - struct F : E { - using E::f; - void f(int); - }; - void (F::*i)() = &F::f; -} - -namespace dr248 { // dr248: yes c++11 - // FIXME: Should this also apply to c++98 mode? This was a DR against C++98. - int \u040d\u040e = 0; -#if __cplusplus < 201103L - // FIXME: expected-error@-2 {{expected ';'}} -#endif -} - -namespace dr249 { // dr249: yes - template<typename T> struct X { void f(); }; - template<typename T> void X<T>::f() {} -} - -namespace dr250 { // dr250: yes - typedef void (*FPtr)(double x[]); - - template<int I> void f(double x[]); - FPtr fp = &f<3>; - - template<int I = 3> void g(double x[]); // expected-error 0-1{{extension}} - FPtr gp = &g<>; -} - -namespace dr252 { // dr252: yes - struct A { - void operator delete(void*); // expected-note {{found}} - }; - struct B { - void operator delete(void*); // expected-note {{found}} - }; - struct C : A, B { - virtual ~C(); - }; - C::~C() {} // expected-error {{'operator delete' found in multiple base classes}} - - struct D { - void operator delete(void*, int); // expected-note {{here}} - virtual ~D(); - }; - D::~D() {} // expected-error {{no suitable member 'operator delete'}} - - struct E { - void operator delete(void*, int); - void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note 1-2 {{here}} - virtual ~E(); // expected-error 0-1 {{attempt to use a deleted function}} - }; - E::~E() {} // expected-error {{attempt to use a deleted function}} - - struct F { - // If both functions are available, the first one is a placement delete. - void operator delete(void*, size_t); - void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note {{here}} - virtual ~F(); - }; - F::~F() {} // expected-error {{attempt to use a deleted function}} - - struct G { - void operator delete(void*, size_t); - virtual ~G(); - }; - G::~G() {} -} - -namespace dr254 { // dr254: yes - template<typename T> struct A { - typedef typename T::type type; // ok even if this is a typedef-name, because - // it's not an elaborated-type-specifier - typedef struct T::type foo; // expected-error {{typedef 'type' cannot be referenced with a struct specifier}} - }; - struct B { struct type {}; }; - struct C { typedef struct {} type; }; // expected-note {{here}} - A<B>::type n; - A<C>::type n; // expected-note {{instantiation of}} -} - -// dr256: dup 624 - -namespace dr257 { // dr257: yes - struct A { A(int); }; // expected-note {{here}} - struct B : virtual A { - B() {} - virtual void f() = 0; - }; - struct C : B { - C() {} - }; - struct D : B { - D() {} // expected-error {{must explicitly initialize the base class 'dr257::A'}} - void f(); - }; -} - -namespace dr258 { // dr258: yes - struct A { - void f(const int); - template<typename> void g(int); - float &h() const; - }; - struct B : A { - using A::f; - using A::g; - using A::h; - int &f(int); - template<int> int &g(int); // expected-note {{candidate}} - int &h(); - } b; - int &w = b.f(0); - int &x = b.g<int>(0); // expected-error {{no match}} - int &y = b.h(); - float &z = const_cast<const B&>(b).h(); - - struct C { - virtual void f(const int) = 0; - }; - struct D : C { - void f(int); - } d; - - struct E { - virtual void f() = 0; // expected-note {{unimplemented}} - }; - struct F : E { - void f() const {} - } f; // expected-error {{abstract}} -} - -namespace dr259 { // dr259: 4 - template<typename T> struct A {}; - template struct A<int>; // expected-note {{previous}} - template struct A<int>; // expected-error {{duplicate explicit instantiation}} - - template<> struct A<float>; // expected-note {{previous}} - template struct A<float>; // expected-warning {{has no effect}} - - template struct A<char>; // expected-note {{here}} - template<> struct A<char>; // expected-error {{explicit specialization of 'dr259::A<char>' after instantiation}} - - template<> struct A<double>; - template<> struct A<double>; - template<> struct A<double> {}; // expected-note {{here}} - template<> struct A<double> {}; // expected-error {{redefinition}} - - template<typename T> struct B; // expected-note {{here}} - template struct B<int>; // expected-error {{undefined}} - - template<> struct B<float>; // expected-note {{previous}} - template struct B<float>; // expected-warning {{has no effect}} -} - -// FIXME: When dr260 is resolved, also add tests for DR507. - -namespace dr261 { // dr261: no -#pragma clang diagnostic push -#pragma clang diagnostic warning "-Wused-but-marked-unused" - - // FIXME: This is ill-formed, with a diagnostic required, because operator new - // and operator delete are inline and odr-used, but not defined in this - // translation unit. - // We're also missing the -Wused-but-marked-unused diagnostic here. - struct A { - inline void *operator new(size_t) __attribute__((unused)); - inline void operator delete(void*) __attribute__((unused)); - A() {} - }; - - // FIXME: This is ill-formed, with a required diagnostic, for the same - // reason. - struct B { - inline void operator delete(void*) __attribute__((unused)); - ~B() {} - }; - struct C { - inline void operator delete(void*) __attribute__((unused)); - virtual ~C() {} // expected-warning {{'operator delete' was marked unused but was used}} - }; - - struct D { - inline void operator delete(void*) __attribute__((unused)); - }; - void h() { C::operator delete(0); } // expected-warning {{marked unused but was used}} - -#pragma clang diagnostic pop -} - -namespace dr262 { // dr262: yes - int f(int = 0, ...); - int k = f(); - int l = f(0); - int m = f(0, 0); -} - -namespace dr263 { // dr263: yes - struct X {}; - struct Y { -#if __cplusplus < 201103L - friend X::X() throw(); - friend X::~X() throw(); -#else - friend constexpr X::X() noexcept; - friend X::~X(); -#endif - Y::Y(); // expected-error {{extra qualification}} - Y::~Y(); // expected-error {{extra qualification}} - }; -} - -// dr265: dup 353 -// dr266: na -// dr269: na -// dr270: na - -namespace dr272 { // dr272: yes - struct X { - void f() { - this->~X(); - X::~X(); - ~X(); // expected-error {{unary expression}} - } - }; -} - -#include <stdarg.h> -#include <stddef.h> -namespace dr273 { // dr273: yes - struct A { - int n; - }; - void operator&(A); - void f(A a, ...) { - offsetof(A, n); - va_list val; - va_start(val, a); - va_end(val); - } -} - -// dr274: na - -namespace dr275 { // dr275: no - namespace N { - template <class T> void f(T) {} // expected-note 1-4{{here}} - template <class T> void g(T) {} // expected-note {{candidate}} - template <> void f(int); - template <> void f(char); - template <> void f(double); - template <> void g(char); - } - - using namespace N; - - namespace M { - template <> void N::f(char) {} // expected-error {{'M' does not enclose namespace 'N'}} - template <class T> void g(T) {} - template <> void g(char) {} - template void f(long); -#if __cplusplus >= 201103L - // FIXME: this should be rejected in c++98 too - // expected-error@-3 {{must occur in namespace 'N'}} -#endif - template void N::f(unsigned long); -#if __cplusplus >= 201103L - // FIXME: this should be rejected in c++98 too - // expected-error@-3 {{not in a namespace enclosing 'N'}} -#endif - template void h(long); // expected-error {{does not refer to a function template}} - template <> void f(double) {} // expected-error {{no function template matches}} - } - - template <class T> void g(T) {} // expected-note {{candidate}} - - template <> void N::f(char) {} - template <> void f(int) {} // expected-error {{no function template matches}} - - template void f(short); -#if __cplusplus >= 201103L - // FIXME: this should be rejected in c++98 too - // expected-error@-3 {{must occur in namespace 'N'}} -#endif - template void N::f(unsigned short); - - // FIXME: this should probably be valid. the wording from the issue - // doesn't clarify this, but it follows from the usual rules. - template void g(int); // expected-error {{ambiguous}} - - // FIXME: likewise, this should also be valid. - template<typename T> void f(T) {} // expected-note {{candidate}} - template void f(short); // expected-error {{ambiguous}} -} - -// dr276: na - -namespace dr277 { // dr277: yes - typedef int *intp; - int *p = intp(); - int a[fold(intp() ? -1 : 1)]; -} - -namespace dr280 { // dr280: yes - typedef void f0(); - typedef void f1(int); - typedef void f2(int, int); - typedef void f3(int, int, int); - struct A { - operator f1*(); // expected-note {{here}} expected-note {{candidate}} - operator f2*(); - }; - struct B { - operator f0*(); // expected-note {{candidate}} - private: - operator f3*(); // expected-note {{here}} expected-note {{candidate}} - }; - struct C { - operator f0*(); // expected-note {{candidate}} - operator f1*(); // expected-note {{candidate}} - operator f2*(); // expected-note {{candidate}} - operator f3*(); // expected-note {{candidate}} - }; - struct D : private A, B { // expected-note 2{{here}} - operator f2*(); // expected-note {{candidate}} - } d; - struct E : C, D {} e; - void g() { - d(); // ok, public - d(0); // expected-error {{private member of 'dr280::A'}} expected-error {{private base class 'dr280::A'}} - d(0, 0); // ok, suppressed by member in D - d(0, 0, 0); // expected-error {{private member of 'dr280::B'}} - e(); // expected-error {{ambiguous}} - e(0); // expected-error {{ambiguous}} - e(0, 0); // expected-error {{ambiguous}} - e(0, 0, 0); // expected-error {{ambiguous}} - } -} - -namespace dr281 { // dr281: no - void a(); - inline void b(); - - void d(); - inline void e(); - - struct S { - friend inline void a(); // FIXME: ill-formed - friend inline void b(); - friend inline void c(); // FIXME: ill-formed - friend inline void d() {} - friend inline void e() {} - friend inline void f() {} - }; -} - -namespace dr283 { // dr283: yes - template<typename T> // expected-note 2{{here}} - struct S { - friend class T; // expected-error {{shadows}} - class T; // expected-error {{shadows}} - }; -} - -namespace dr284 { // dr284: no - namespace A { - struct X; - enum Y {}; - class Z {}; - } - namespace B { - struct W; - using A::X; - using A::Y; - using A::Z; - } - struct B::V {}; // expected-error {{no struct named 'V'}} - struct B::W {}; - struct B::X {}; // FIXME: ill-formed - enum B::Y e; // ok per dr417 - class B::Z z; // ok per dr417 - - struct C { - struct X; - enum Y {}; - class Z {}; - }; - struct D : C { - struct W; - using C::X; - using C::Y; - using C::Z; - }; - struct D::V {}; // expected-error {{no struct named 'V'}} - struct D::W {}; - struct D::X {}; // FIXME: ill-formed - enum D::Y e2; // ok per dr417 - class D::Z z2; // ok per dr417 -} - -namespace dr285 { // dr285: yes - template<typename T> void f(T, int); // expected-note {{match}} - template<typename T> void f(int, T); // expected-note {{match}} - template<> void f<int>(int, int) {} // expected-error {{ambiguous}} -} - -namespace dr286 { // dr286: yes - template<class T> struct A { - class C { - template<class T2> struct B {}; // expected-note {{here}} - }; - }; - - template<class T> - template<class T2> - struct A<T>::C::B<T2*> { }; - - A<short>::C::B<int*> absip; // expected-error {{private}} -} - -// dr288: na - -namespace dr289 { // dr289: yes - struct A; // expected-note {{forward}} - struct B : A {}; // expected-error {{incomplete}} - - template<typename T> struct C { typename T::error error; }; // expected-error {{cannot be used prior to '::'}} - struct D : C<int> {}; // expected-note {{instantiation}} -} - -// dr290: na -// dr291: dup 391 -// dr292 FIXME: write a codegen test - -namespace dr294 { // dr294: no - void f() throw(int); -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - int main() { - (void)static_cast<void (*)() throw()>(f); // FIXME: ill-formed in C++14 and before -#if __cplusplus > 201402L - // FIXME: expected-error@-2 {{not allowed}} - // - // Irony: the above is valid in C++17 and beyond, but that's exactly when - // we reject it. In C++14 and before, this is ill-formed because an - // exception-specification is not permitted in a type-id. In C++17, this is - // valid because it's the inverse of a standard conversion sequence - // containing a function pointer conversion. (Well, it's actually not valid - // yet, as a static_cast is not permitted to reverse a function pointer - // conversion, but that is being changed by core issue). -#endif - (void)static_cast<void (*)() throw(int)>(f); // FIXME: ill-formed in C++14 and before -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - - void (*p)() throw() = f; // expected-error-re {{{{not superset|different exception specification}}}} - void (*q)() throw(int) = f; -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - } -} - -namespace dr295 { // dr295: 3.7 - typedef int f(); - const f g; // expected-warning {{'const' qualifier on function type 'dr295::f' (aka 'int ()') has no effect}} - f &r = g; - template<typename T> struct X { - const T &f; - }; - X<f> x = {g}; - - typedef int U(); - typedef const U U; // expected-warning {{'const' qualifier on function type 'dr295::U' (aka 'int ()') has no effect}} - - typedef int (*V)(); - typedef volatile U *V; // expected-warning {{'volatile' qualifier on function type 'dr295::U' (aka 'int ()') has no effect}} -} - -namespace dr296 { // dr296: yes - struct A { - static operator int() { return 0; } // expected-error {{static}} - }; -} - -namespace dr298 { // dr298: yes - struct A { - typedef int type; - A(); - ~A(); - }; - typedef A B; // expected-note {{here}} - typedef const A C; // expected-note {{here}} - - A::type i1; - B::type i2; - C::type i3; - - struct A a; - struct B b; // expected-error {{typedef 'B' cannot be referenced with a struct specifier}} - struct C c; // expected-error {{typedef 'C' cannot be referenced with a struct specifier}} - - B::B() {} // expected-error {{requires a type specifier}} - B::A() {} // ok - C::~C() {} // expected-error {{destructor cannot be declared using a typedef 'dr298::C' (aka 'const dr298::A') of the class name}} - - typedef struct D E; // expected-note {{here}} - struct E {}; // expected-error {{conflicts with typedef}} - - struct F { - ~F(); - }; - typedef const F G; - G::~F() {} // ok -} - -namespace dr299 { // dr299: yes c++11 - struct S { - operator int(); - }; - struct T { - operator int(); // expected-note {{}} - operator unsigned short(); // expected-note {{}} - }; - // FIXME: should this apply to c++98 mode? - int *p = new int[S()]; // expected-error 0-1{{extension}} - int *q = new int[T()]; // expected-error {{ambiguous}} -} diff --git a/test/CXX/drs/dr3xx.cpp b/test/CXX/drs/dr3xx.cpp deleted file mode 100644 index d723c5b78cdf..000000000000 --- a/test/CXX/drs/dr3xx.cpp +++ /dev/null @@ -1,1380 +0,0 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr300 { // dr300: yes - template<typename R, typename A> void f(R (&)(A)) {} - int g(int); - void h() { f(g); } -} - -namespace dr301 { // dr301: yes - // see also dr38 - struct S; - template<typename T> void operator+(T, T); - void operator-(S, S); - - void f() { - bool a = (void(*)(S, S))operator+<S> < - (void(*)(S, S))operator+<S>; - bool b = (void(*)(S, S))operator- < - (void(*)(S, S))operator-; - bool c = (void(*)(S, S))operator+ < - (void(*)(S, S))operator-; // expected-error {{expected '>'}} - } - - template<typename T> void f() { - typename T::template operator+<int> a; // expected-error {{typename specifier refers to a non-type template}} expected-error +{{}} - // FIXME: This shouldn't say (null). - class T::template operator+<int> b; // expected-error {{identifier followed by '<' indicates a class template specialization but (null) refers to a function template}} - enum T::template operator+<int> c; // expected-error {{expected identifier}} expected-error {{does not declare anything}} - enum T::template operator+<int>::E d; // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} expected-error {{forward reference}} - enum T::template X<int>::E e; - T::template operator+<int>::foobar(); // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} - T::template operator+<int>(0); // ok - } - - template<typename T> class operator&<T*> {}; // expected-error +{{}} - template<typename T> class T::operator& {}; // expected-error +{{}} - template<typename T> class S::operator&<T*> {}; // expected-error +{{}} -} - -namespace dr302 { // dr302: yes - struct A { A(); ~A(); }; -#if __cplusplus < 201103L - struct B { // expected-error {{implicit default constructor for 'dr302::B' must explicitly initialize the const member 'n'}} - const int n; // expected-note {{declared here}} - A a; - } b = B(); // expected-note {{first required here}} - // Trivial default constructor C::C() is not called here. - struct C { - const int n; - } c = C(); -#else - struct B { - const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}} - A a; - } b = B(); // expected-error {{call to implicitly-deleted default constructor}} - // C::C() is called here, because even though it's trivial, it's deleted. - struct C { - const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}} - } c = C(); // expected-error {{call to implicitly-deleted default constructor}} - struct D { - const int n = 0; - } d = D(); -#endif -} - -// dr303: na - -namespace dr304 { // dr304: yes - typedef int &a; - int n = a(); // expected-error {{requires an initializer}} - - struct S { int &b; }; - int m = S().b; -#if __cplusplus < 201103L - // expected-error@-3 {{requires an initializer}} - // expected-note@-3 {{in value-initialization}} -#else - // expected-error@-5 {{deleted}} - // expected-note@-7 {{reference}} -#endif -} - -namespace dr305 { // dr305: no - struct A { - typedef A C; - }; - void f(A *a) { - struct A {}; - a->~A(); - a->~C(); - } - typedef A B; - void g(B *b) { - b->~B(); - b->~C(); - } - void h(B *b) { - struct B {}; // expected-note {{declared here}} - b->~B(); // expected-error {{does not match}} - } - - template<typename T> struct X {}; - void i(X<int>* x) { - struct X {}; - x->~X<int>(); - x->~X(); - x->~X<char>(); // expected-error {{no member named}} - } - -#if __cplusplus >= 201103L - struct Y { - template<typename T> using T1 = Y; - }; - template<typename T> using T2 = Y; - void j(Y *y) { - y->~T1<int>(); - y->~T2<int>(); - } - struct Z { - template<typename T> using T2 = T; - }; - void k(Z *z) { - z->~T1<int>(); // expected-error {{no member named 'T1' in 'dr305::Z'}} expected-error +{{}} - z->~T2<int>(); // expected-error {{no member named '~int'}} - z->~T2<Z>(); - } - - // FIXME: This is valid. - namespace Q { - template<typename A> struct R {}; - } - template<typename A> using R = Q::R<int>; - void qr(Q::R<int> x) { x.~R<char>(); } // expected-error {{no member named}} -#endif -} - -namespace dr306 { // dr306: no - // FIXME: dup 39 - // FIXME: This should be accepted. - struct A { struct B {}; }; // expected-note 2{{member}} - struct C { typedef A::B B; }; // expected-note {{member}} - struct D : A, A::B, C {}; - D::B b; // expected-error {{found in multiple base classes of different types}} -} - -// dr307: na - -namespace dr308 { // dr308: yes - // This is mostly an ABI library issue. - struct A {}; - struct B : A {}; - struct C : A {}; - struct D : B, C {}; - void f() { - try { - throw D(); - } catch (const A&) { // expected-note {{for type 'const dr308::A &'}} - // unreachable - } catch (const B&) { // expected-warning {{exception of type 'const dr308::B &' will be caught by earlier handler}} - // get here instead - } - } -} - -// dr309: dup 485 - -namespace dr311 { // dr311: yes - namespace X { namespace Y {} } - namespace X::Y {} -#if __cplusplus <= 201402L - // expected-error@-2 {{define each namespace separately}} -#endif - namespace X { - namespace X::Y {} -#if __cplusplus <= 201402L - // expected-error@-2 {{define each namespace separately}} -#endif - } - // FIXME: The diagnostics here are not very good. - namespace ::dr311::X {} // expected-error 2+{{}} // expected-warning {{extra qual}} -} - -// dr312: dup 616 - -namespace dr313 { // dr313: dup 299 c++11 - struct A { operator int() const; }; - int *p = new int[A()]; -#if __cplusplus < 201103L - // FIXME: should this be available in c++98 mode? expected-error@-2 {{extension}} -#endif -} - -namespace dr314 { // FIXME 314: dup 1710 - template<typename T> struct A { - template<typename U> struct B {}; - }; - template<typename T> struct C : public A<T>::template B<T> { - C() : A<T>::template B<T>() {} - }; -} - -// dr315: na -// dr316: sup 1004 - -namespace dr317 { // dr317: 3.5 - void f() {} // expected-note {{previous}} - inline void f(); // expected-error {{inline declaration of 'f' follows non-inline definition}} - - int g(); - int n = g(); - inline int g() { return 0; } - - int h(); - int m = h(); - int h() { return 0; } // expected-note {{previous}} - inline int h(); // expected-error {{inline declaration of 'h' follows non-inline definition}} -} - -namespace dr318 { // dr318: sup 1310 - struct A {}; - struct A::A a; -} - -namespace dr319 { // dr319: no - // FIXME: dup dr389 - // FIXME: We don't have a diagnostic for a name with linkage - // having a type without linkage. - typedef struct { - int i; - } *ps; - extern "C" void f(ps); - void g(ps); // FIXME: ill-formed, type 'ps' has no linkage - - static enum { e } a1; - enum { e2 } a2; // FIXME: ill-formed, enum type has no linkage - - enum { n1 = 1u }; - typedef int (*pa)[n1]; - pa parr; // ok, type has linkage despite using 'n1' - - template<typename> struct X {}; - - void f() { - struct A { int n; }; - extern A a; // FIXME: ill-formed - X<A> xa; - - typedef A B; - extern B b; // FIXME: ill-formed - X<B> xb; - - const int n = 1; - typedef int (*C)[n]; - extern C c; // ok - X<C> xc; - } -#if __cplusplus < 201103L - // expected-error@-12 {{uses local type 'A'}} - // expected-error@-9 {{uses local type 'A'}} -#endif -} - -namespace dr320 { // dr320: yes -#if __cplusplus >= 201103L - struct X { - constexpr X() {} - constexpr X(const X &x) : copies(x.copies + 1) {} - unsigned copies = 0; - }; - constexpr X f(X x) { return x; } - constexpr unsigned g(X x) { return x.copies; } - static_assert(f(X()).copies == g(X()) + 1, "expected one extra copy for return value"); -#endif -} - -namespace dr321 { // dr321: dup 557 - namespace N { - template<int> struct A { - template<int> struct B; - }; - template<> template<> struct A<0>::B<0>; - void f(A<0>::B<0>); - } - template<> template<> struct N::A<0>::B<0> {}; - - template<typename T> void g(T t) { f(t); } - template void g(N::A<0>::B<0>); - - namespace N { - template<typename> struct I { friend bool operator==(const I&, const I&); }; - } - N::I<int> i, j; - bool x = i == j; -} - -namespace dr322 { // dr322: yes - struct A { - template<typename T> operator T&(); - } a; - int &r = static_cast<int&>(a); - int &s = a; -} - -// dr323: no - -namespace dr324 { // dr324: yes - struct S { int n : 1; } s; // expected-note 3{{bit-field is declared here}} - int &a = s.n; // expected-error {{non-const reference cannot bind to bit-field}} - int *b = &s.n; // expected-error {{address of bit-field}} - int &c = (s.n = 0); // expected-error {{non-const reference cannot bind to bit-field}} - int *d = &(s.n = 0); // expected-error {{address of bit-field}} - int &e = true ? s.n : s.n; // expected-error {{non-const reference cannot bind to bit-field}} - int *f = &(true ? s.n : s.n); // expected-error {{address of bit-field}} - int &g = (void(), s.n); // expected-error {{non-const reference cannot bind to bit-field}} - int *h = &(void(), s.n); // expected-error {{address of bit-field}} - int *i = &++s.n; // expected-error {{address of bit-field}} -} - -namespace dr326 { // dr326: yes - struct S {}; - int test[__is_trivially_constructible(S, const S&) ? 1 : -1]; -} - -namespace dr327 { // dr327: dup 538 - struct A; - class A {}; - - class B; - struct B {}; -} - -namespace dr328 { // dr328: yes - struct A; // expected-note 3{{forward declaration}} - struct B { A a; }; // expected-error {{incomplete}} - template<typename> struct C { A a; }; // expected-error {{incomplete}} - A *p = new A[0]; // expected-error {{incomplete}} -} - -namespace dr329 { // dr329: 3.5 - struct B {}; - template<typename T> struct A : B { - friend void f(A a) { g(a); } - friend void h(A a) { g(a); } // expected-error {{undeclared}} - friend void i(B b) {} // expected-error {{redefinition}} expected-note {{previous}} - }; - A<int> a; - A<char> b; // expected-note {{instantiation}} - - void test() { - h(a); // expected-note {{instantiation}} - } -} - -namespace dr330 { // dr330: 7 - // Conversions between P and Q will be allowed by P0388. - typedef int *(*P)[3]; - typedef const int *const (*Q)[3]; - typedef const int *Qinner[3]; - typedef Qinner const *Q2; // same as Q, but 'const' written outside the array type - typedef const int *const (*R)[4]; - typedef const int *const (*S)[]; - typedef const int *(*T)[]; - void f(P p, Q q, Q2 q2, R r, S s, T t) { - q = p; // ok - q2 = p; // ok - r = p; // expected-error {{incompatible}} - s = p; // expected-error {{incompatible}} (for now) - t = p; // expected-error {{incompatible}} - s = q; // expected-error {{incompatible}} - s = q2; // expected-error {{incompatible}} - s = t; // ok, adding const - t = s; // expected-error {{incompatible}} - (void) const_cast<P>(q); - (void) const_cast<P>(q2); - (void) const_cast<Q>(p); - (void) const_cast<Q2>(p); - (void) const_cast<S>(p); // expected-error {{not allowed}} (for now) - (void) const_cast<P>(s); // expected-error {{not allowed}} (for now) - (void) const_cast<S>(q); // expected-error {{not allowed}} - (void) const_cast<S>(q2); // expected-error {{not allowed}} - (void) const_cast<Q>(s); // expected-error {{not allowed}} - (void) const_cast<Q2>(s); // expected-error {{not allowed}} - (void) const_cast<T>(s); - (void) const_cast<S>(t); - (void) const_cast<T>(q); // expected-error {{not allowed}} - (void) const_cast<Q>(t); // expected-error {{not allowed}} - - (void) reinterpret_cast<P>(q); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<P>(q2); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<Q>(p); - (void) reinterpret_cast<Q2>(p); - (void) reinterpret_cast<S>(p); - (void) reinterpret_cast<P>(s); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<S>(q); - (void) reinterpret_cast<S>(q2); - (void) reinterpret_cast<Q>(s); - (void) reinterpret_cast<Q2>(s); - (void) reinterpret_cast<T>(s); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<S>(t); - (void) reinterpret_cast<T>(q); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<Q>(t); - } - - namespace swift_17882 { - typedef const char P[72]; - typedef int *Q; - void f(P &pr, P *pp) { - (void) reinterpret_cast<const Q&>(pr); - (void) reinterpret_cast<const Q*>(pp); - } - - struct X {}; - typedef const volatile int A[1][2][3]; - typedef int *const X::*volatile *B1; - typedef int *const X::* *B2; - typedef int *X::* volatile *B3; - typedef volatile int *(*const B4)[4]; - void f(A *a) { - (void) reinterpret_cast<B1*>(a); - (void) reinterpret_cast<B2*>(a); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<B3*>(a); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<B4*>(a); - } - } -} - -namespace dr331 { // dr331: yes - struct A { - A(volatile A&); // expected-note {{candidate}} - } const a, b(a); // expected-error {{no matching constructor}} -} - -namespace dr332 { // dr332: dup 577 - void f(volatile void); // expected-error {{'void' as parameter must not have type qualifiers}} - void g(const void); // expected-error {{'void' as parameter must not have type qualifiers}} - void h(int n, volatile void); // expected-error {{'void' must be the first and only parameter}} -} - -namespace dr333 { // dr333: yes - int n = 0; - int f(int(n)); - int g((int(n))); - int h = f(g); -} - -namespace dr334 { // dr334: yes - template<typename T> void f() { - T x; - f((x, 123)); - } - struct S { - friend S operator,(S, int); - friend void f(S); - }; - template void f<S>(); -} - -// dr335: no - -namespace dr336 { // dr336: yes - namespace Pre { - template<class T1> class A { - template<class T2> class B { - template<class T3> void mf1(T3); - void mf2(); - }; - }; - template<> template<class X> class A<int>::B {}; - template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {} // expected-error {{does not match}} - template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}} - } - namespace Post { - template<class T1> class A { - template<class T2> class B { - template<class T3> void mf1(T3); - void mf2(); - }; - }; - template<> template<class X> class A<int>::B { - template<class T> void mf1(T); - }; - template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {} - // FIXME: This diagnostic isn't very good. - template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}} - } -} - -namespace dr337 { // dr337: yes - template<typename T> void f(T (*)[1]); - template<typename T> int &f(...); - - struct A { virtual ~A() = 0; }; - int &r = f<A>(0); - - // FIXME: The language rules here are completely broken. We cannot determine - // whether an incomplete type is abstract. See DR1640, which will probably - // supersede this one and remove this rule. - struct B; - int &s = f<B>(0); // expected-error {{of type 'void'}} - struct B { virtual ~B() = 0; }; -} - -namespace dr339 { // dr339: yes - template <int I> struct A { static const int value = I; }; - - char xxx(int); - char (&xxx(float))[2]; - - template<class T> A<sizeof(xxx((T)0))> f(T) {} // expected-note {{candidate}} - - void test() { - A<1> a = f(0); - A<2> b = f(0.0f); - A<3> c = f("foo"); // expected-error {{no matching function}} - } - - - char f(int); - int f(...); - - template <class T> struct conv_int { - static const bool value = sizeof(f(T())) == 1; - }; - - template <class T> bool conv_int2(A<sizeof(f(T()))> p); - - template<typename T> A<sizeof(f(T()))> make_A(); - - int a[conv_int<char>::value ? 1 : -1]; - bool b = conv_int2<char>(A<1>()); - A<1> c = make_A<char>(); -} - -namespace dr340 { // dr340: yes - struct A { A(int); }; - struct B { B(A, A, int); }; - int x, y; - B b(A(x), A(y), 3); -} - -namespace dr341 { // dr341: sup 1708 - namespace A { - int n; - extern "C" int &dr341_a = n; // expected-note {{previous}} expected-note {{declared with C language linkage here}} - } - namespace B { - extern "C" int &dr341_a = dr341_a; // expected-error {{redefinition}} - } - extern "C" void dr341_b(); // expected-note {{declared with C language linkage here}} -} -int dr341_a; // expected-error {{declaration of 'dr341_a' in global scope conflicts with declaration with C language linkage}} -int dr341_b; // expected-error {{declaration of 'dr341_b' in global scope conflicts with declaration with C language linkage}} -int dr341_c; // expected-note {{declared in global scope here}} -int dr341_d; // expected-note {{declared in global scope here}} -namespace dr341 { - extern "C" int dr341_c; // expected-error {{declaration of 'dr341_c' with C language linkage conflicts with declaration in global scope}} - extern "C" void dr341_d(); // expected-error {{declaration of 'dr341_d' with C language linkage conflicts with declaration in global scope}} - - namespace A { extern "C" int dr341_e; } // expected-note {{previous}} - namespace B { extern "C" void dr341_e(); } // expected-error {{redefinition of 'dr341_e' as different kind of symbol}} -} - -// dr342: na - -namespace dr343 { // FIXME 343: no - // FIXME: dup 1710 - template<typename T> struct A { - template<typename U> struct B {}; - }; - // FIXME: In these contexts, the 'template' keyword is optional. - template<typename T> struct C : public A<T>::B<T> { // expected-error {{use 'template'}} - C() : A<T>::B<T>() {} // expected-error {{use 'template'}} - }; -} - -namespace dr344 { // dr344: dup 1435 - struct A { inline virtual ~A(); }; - struct B { friend A::~A(); }; -} - -namespace dr345 { // dr345: yes - struct A { - struct X {}; - int X; // expected-note {{here}} - }; - struct B { - struct X {}; - }; - template <class T> void f(T t) { typename T::X x; } // expected-error {{refers to non-type member 'X'}} - void f(A a, B b) { - f(b); - f(a); // expected-note {{instantiation}} - } -} - -// dr346: na - -namespace dr347 { // dr347: yes - struct base { - struct nested; - static int n; - static void f(); - void g(); - }; - - struct derived : base {}; - - struct derived::nested {}; // expected-error {{no struct named 'nested'}} - int derived::n; // expected-error {{no member named 'n'}} - void derived::f() {} // expected-error {{does not match any}} - void derived::g() {} // expected-error {{does not match any}} -} - -// dr348: na - -namespace dr349 { // dr349: no - struct A { - template <class T> operator T ***() { - int ***p = 0; - return p; // expected-error {{cannot initialize return object of type 'const int ***' with an lvalue of type 'int ***'}} - } - }; - - // FIXME: This is valid. - A a; - const int *const *const *p1 = a; // expected-note {{in instantiation of}} - - struct B { - template <class T> operator T ***() { - const int ***p = 0; - return p; - } - }; - - // FIXME: This is invalid. - B b; - const int *const *const *p2 = b; -} - -// dr351: na - -namespace dr352 { // dr352: yes - namespace example1 { - namespace A { - enum E {}; - template<typename R, typename A> void foo(E, R (*)(A)); // expected-note 2{{couldn't infer template argument 'R'}} - } - - template<typename T> void arg(T); - template<typename T> int arg(T) = delete; // expected-note {{here}} expected-error 0-1{{extension}} - - void f(A::E e) { - foo(e, &arg); // expected-error {{no matching function}} - - using A::foo; - foo<int, int>(e, &arg); // expected-error {{deleted}} - } - - int arg(int); - - void g(A::E e) { - foo(e, &arg); // expected-error {{no matching function}} - - using A::foo; - foo<int, int>(e, &arg); // ok, uses non-template - } - } - - namespace contexts { - template<int I> void f1(int (&)[I]); - template<int I> void f2(int (&)[I+1]); // expected-note {{couldn't infer}} - template<int I> void f3(int (&)[I+1], int (&)[I]); - void f() { - int a[4]; - int b[3]; - f1(a); - f2(a); // expected-error {{no matching function}} - f3(a, b); - } - - template<int I> struct S {}; - template<int I> void g1(S<I>); - template<int I> void g2(S<I+1>); // expected-note {{couldn't infer}} - template<int I> void g3(S<I+1>, S<I>); - void g() { - S<4> a; - S<3> b; - g1(a); - g2(a); // expected-error {{no matching function}} - g3(a, b); - } - - template<typename T> void h1(T = 0); // expected-note {{couldn't infer}} - template<typename T> void h2(T, T = 0); - void h() { - h1(); // expected-error {{no matching function}} - h1(0); - h1<int>(); - h2(0); - } - - template<typename T> int tmpl(T); - template<typename R, typename A> void i1(R (*)(A)); // expected-note 3{{couldn't infer}} - template<typename R, typename A> void i2(R, A, R (*)(A)); // expected-note {{not viable}} - void i() { - extern int single(int); - i1(single); - i2(0, 0, single); - - extern int ambig(float), ambig(int); - i1(ambig); // expected-error {{no matching function}} - i2(0, 0, ambig); - - extern void no_match(float), no_match(int); - i1(no_match); // expected-error {{no matching function}} - i2(0, 0, no_match); // expected-error {{no matching function}} - - i1(tmpl); // expected-error {{no matching function}} - i2(0, 0, tmpl); - } - } - - template<typename T> struct is_int; - template<> struct is_int<int> {}; - - namespace example2 { - template<typename T> int f(T (*p)(T)) { is_int<T>(); } - int g(int); - int g(char); - int i = f(g); - } - - namespace example3 { - template<typename T> int f(T, T (*p)(T)) { is_int<T>(); } - int g(int); - char g(char); - int i = f(1, g); - } - - namespace example4 { - template <class T> int f(T, T (*p)(T)) { is_int<T>(); } - char g(char); - template <class T> T g(T); - int i = f(1, g); - } - - namespace example5 { - template<int I> class A {}; - template<int I> void g(A<I+1>); // expected-note {{couldn't infer}} - template<int I> void f(A<I>, A<I+1>); - void h(A<1> a1, A<2> a2) { - g(a1); // expected-error {{no matching function}} - g<0>(a1); - f(a1, a2); - } - } -} - -// dr353 needs an IRGen test. - -namespace dr354 { // dr354: yes c++11 - // FIXME: Should we allow this in C++98 too? - struct S {}; - - template<int*> struct ptr {}; // expected-note 0-4{{here}} - ptr<0> p0; - ptr<(int*)0> p1; - ptr<(float*)0> p2; - ptr<(int S::*)0> p3; -#if __cplusplus < 201103L - // expected-error@-5 {{does not refer to any decl}} - // expected-error@-5 {{does not refer to any decl}} - // expected-error@-5 {{does not refer to any decl}} - // expected-error@-5 {{does not refer to any decl}} -#elif __cplusplus <= 201402L - // expected-error@-10 {{must be cast}} - // ok - // expected-error@-10 {{does not match}} - // expected-error@-10 {{does not match}} -#else - // expected-error@-15 {{conversion from 'int' to 'int *' is not allowed}} - // ok - // expected-error@-15 {{'float *' is not implicitly convertible to 'int *'}} - // expected-error@-15 {{'int dr354::S::*' is not implicitly convertible to 'int *'}} -#endif - - template<int*> int both(); - template<int> int both(); - int b0 = both<0>(); - int b1 = both<(int*)0>(); -#if __cplusplus < 201103L - // expected-error@-2 {{no matching function}} - // expected-note@-6 {{candidate}} - // expected-note@-6 {{candidate}} -#endif - - template<int S::*> struct ptr_mem {}; // expected-note 0-4{{here}} - ptr_mem<0> m0; - ptr_mem<(int S::*)0> m1; - ptr_mem<(float S::*)0> m2; - ptr_mem<(int *)0> m3; -#if __cplusplus < 201103L - // expected-error@-5 {{cannot be converted}} - // expected-error@-5 {{is not a pointer to member constant}} - // expected-error@-5 {{cannot be converted}} - // expected-error@-5 {{cannot be converted}} -#elif __cplusplus <= 201402L - // expected-error@-10 {{must be cast}} - // ok - // expected-error@-10 {{does not match}} - // expected-error@-10 {{does not match}} -#else - // expected-error@-15 {{conversion from 'int' to 'int dr354::S::*' is not allowed}} - // ok - // expected-error@-15 {{'float dr354::S::*' is not implicitly convertible to 'int dr354::S::*'}} - // expected-error@-15 {{'int *' is not implicitly convertible to 'int dr354::S::*'}} -#endif -} - -struct dr355_S; // dr355: yes -struct ::dr355_S {}; // expected-warning {{extra qualification}} -namespace dr355 { struct ::dr355_S s; } - -// dr356: na - -namespace dr357 { // dr357: yes - template<typename T> struct A { - void f() const; // expected-note {{const qualified}} - }; - template<typename T> void A<T>::f() {} // expected-error {{does not match}} - - struct B { - template<typename T> void f(); - }; - template<typename T> void B::f() const {} // expected-error {{does not match}} -} - -namespace dr358 { // dr358: yes - extern "C" void dr358_f(); - namespace N { - int var; - extern "C" void dr358_f() { var = 10; } - } -} - -namespace dr359 { // dr359: yes - // Note, the example in the DR is wrong; it doesn't contain an anonymous - // union. - struct E { - union { - struct { - int x; - } s; - } v; - - union { - struct { // expected-error {{extension}} - int x; - } s; - - struct S { // expected-error {{types cannot be declared in an anonymous union}} - int x; - } t; - - union { // expected-error {{extension}} - int u; - }; - }; - }; -} - -// dr362: na -// dr363: na - -namespace dr364 { // dr364: yes - struct S { - static void f(int); - void f(char); - }; - - void g() { - S::f('a'); // expected-error {{call to non-static}} - S::f(0); - } -} - -#if "foo" // expected-error {{invalid token}} dr366: yes -#endif - -namespace dr367 { // dr367: yes - // FIXME: These diagnostics are terrible. Don't diagnose an ill-formed global - // array as being a VLA! - int a[true ? throw 0 : 4]; // expected-error 2{{variable length array}} - int b[true ? 4 : throw 0]; - int c[true ? *new int : 4]; // expected-error 2{{variable length array}} - int d[true ? 4 : *new int]; -#if __cplusplus < 201103L - // expected-error@-4 {{variable length array}} expected-error@-4 {{constant expression}} - // expected-error@-3 {{variable length array}} expected-error@-3 {{constant expression}} -#endif -} - -namespace dr368 { // dr368: yes - template<typename T, T> struct S {}; // expected-note {{here}} - template<typename T> int f(S<T, T()> *); // expected-error {{function type}} - //template<typename T> int g(S<T, (T())> *); // FIXME: crashes clang - template<typename T> int g(S<T, true ? T() : T()> *); // expected-note {{cannot have type 'dr368::X'}} - struct X {}; - int n = g<X>(0); // expected-error {{no matching}} -} - -// dr370: na - -namespace dr372 { // dr372: no - namespace example1 { - template<typename T> struct X { - protected: - typedef T Type; // expected-note 2{{protected}} - }; - template<typename T> struct Y {}; - - // FIXME: These two are valid; deriving from T1<T> gives Z1 access to - // the protected member T1<T>::Type. - template<typename T, - template<typename> class T1, - template<typename> class T2> struct Z1 : - T1<T>, - T2<typename T1<T>::Type> {}; // expected-error {{protected}} - - template<typename T, - template<typename> class T1, - template<typename> class T2> struct Z2 : - T2<typename T1<T>::Type>, // expected-error {{protected}} - T1<T> {}; - - Z1<int, X, Y> z1; // expected-note {{instantiation of}} - Z2<int, X, Y> z2; // expected-note {{instantiation of}} - } - - namespace example2 { - struct X { - private: - typedef int Type; // expected-note {{private}} - }; - template<typename T> struct A { - typename T::Type t; // expected-error {{private}} - }; - A<X> ax; // expected-note {{instantiation of}} - } - - namespace example3 { - struct A { - protected: - typedef int N; // expected-note 2{{protected}} - }; - - template<typename T> struct B {}; - template<typename U> struct C : U, B<typename U::N> {}; // expected-error {{protected}} - template<typename U> struct D : B<typename U::N>, U {}; // expected-error {{protected}} - - C<A> x; // expected-note {{instantiation of}} - D<A> y; // expected-note {{instantiation of}} - } - - namespace example4 { - class A { - class B {}; - friend class X; - }; - - struct X : A::B { - A::B mx; - class Y { - A::B my; - }; - }; - } - - // FIXME: This is valid: deriving from A gives D access to A::B - namespace std_example { - class A { - protected: - struct B {}; // expected-note {{here}} - }; - struct D : A::B, A {}; // expected-error {{protected}} - } - - // FIXME: This is valid: deriving from A::B gives access to A::B! - namespace badwolf { - class A { - protected: - struct B; // expected-note {{here}} - }; - struct A::B : A {}; - struct C : A::B {}; // expected-error {{protected}} - } -} - -namespace dr373 { // dr373: 5 - namespace X { int dr373; } - struct dr373 { // expected-note {{here}} - void f() { - using namespace dr373::X; - int k = dr373; // expected-error {{does not refer to a value}} - - namespace Y = dr373::X; - k = Y::dr373; - } - }; - - struct A { struct B {}; }; // expected-note 2{{here}} - namespace X = A::B; // expected-error {{expected namespace name}} - using namespace A::B; // expected-error {{expected namespace name}} -} - -namespace dr374 { // dr374: yes - namespace N { - template<typename T> void f(); - template<typename T> struct A { void f(); }; - } - template<> void N::f<char>() {} - template<> void N::A<char>::f() {} - template<> struct N::A<int> {}; -} - -// dr375: dup 345 -// dr376: na - -namespace dr377 { // dr377: yes - enum E { // expected-error {{enumeration values exceed range of largest integer}} - a = -__LONG_LONG_MAX__ - 1, // expected-error 0-1{{extension}} - b = 2 * (unsigned long long)__LONG_LONG_MAX__ // expected-error 0-2{{extension}} - }; -} - -// dr378: dup 276 -// dr379: na - -namespace dr381 { // dr381: yes - struct A { - int a; - }; - struct B : virtual A {}; - struct C : B {}; - struct D : B {}; - struct E : public C, public D {}; - struct F : public A {}; - void f() { - E e; - e.B::a = 0; // expected-error {{ambiguous conversion}} - F f; - f.A::a = 1; - } -} - -namespace dr382 { // dr382: yes c++11 - // FIXME: Should we allow this in C++98 mode? - struct A { typedef int T; }; - typename A::T t; - typename dr382::A a; -#if __cplusplus < 201103L - // expected-error@-3 {{occurs outside of a template}} - // expected-error@-3 {{occurs outside of a template}} -#endif - typename A b; // expected-error {{expected a qualified name}} -} - -namespace dr383 { // dr383: yes - struct A { A &operator=(const A&); }; - struct B { ~B(); }; - union C { C &operator=(const C&); }; - union D { ~D(); }; - int check[(__is_pod(A) || __is_pod(B) || __is_pod(C) || __is_pod(D)) ? -1 : 1]; -} - -namespace dr384 { // dr384: yes - namespace N1 { - template<typename T> struct Base {}; - template<typename T> struct X { - struct Y : public Base<T> { - Y operator+(int) const; - }; - Y f(unsigned i) { return Y() + i; } - }; - } - - namespace N2 { - struct Z {}; - template<typename T> int *operator+(T, unsigned); - } - - int main() { - N1::X<N2::Z> v; - v.f(0); - } -} - -namespace dr385 { // dr385: yes - struct A { protected: void f(); }; - struct B : A { using A::f; }; - struct C : A { void g(B b) { b.f(); } }; - void h(B b) { b.f(); } - - struct D { int n; }; // expected-note {{member}} - struct E : protected D {}; // expected-note 2{{protected}} - struct F : E { friend int i(E); }; - int i(E e) { return e.n; } // expected-error {{protected base}} expected-error {{protected member}} -} - -namespace dr387 { // dr387: yes - namespace old { - template<typename T> class number { - number(int); // expected-note 2{{here}} - friend number gcd(number &x, number &y) {} - }; - - void g() { - number<double> a(3), b(4); // expected-error 2{{private}} - a = gcd(a, b); - b = gcd(3, 4); // expected-error {{undeclared}} - } - } - - namespace newer { - template <typename T> class number { - public: - number(int); - friend number gcd(number x, number y) { return 0; } - }; - - void g() { - number<double> a(3), b(4); - a = gcd(a, b); - b = gcd(3, 4); // expected-error {{undeclared}} - } - } -} - -// FIXME: dr388 needs codegen test - -namespace dr389 { // dr389: no - struct S { - typedef struct {} A; - typedef enum {} B; - typedef struct {} const C; // expected-note 0-2{{here}} - typedef enum {} const D; // expected-note 0-1{{here}} - }; - template<typename> struct T {}; - - struct WithLinkage1 {}; - enum WithLinkage2 {}; - typedef struct {} *WithLinkage3a, WithLinkage3b; - typedef enum {} WithLinkage4a, *WithLinkage4b; - typedef S::A WithLinkage5; - typedef const S::B WithLinkage6; - typedef int WithLinkage7; - typedef void (*WithLinkage8)(WithLinkage2 WithLinkage1::*, WithLinkage5 *); - typedef T<WithLinkage5> WithLinkage9; - - typedef struct {} *WithoutLinkage1; // expected-note 0-1{{here}} - typedef enum {} const WithoutLinkage2; // expected-note 0-1{{here}} - // These two types don't have linkage even though they are externally visible - // and the ODR requires them to be merged across TUs. - typedef S::C WithoutLinkage3; - typedef S::D WithoutLinkage4; - typedef void (*WithoutLinkage5)(int (WithoutLinkage3::*)(char)); - -#if __cplusplus >= 201103L - // This has linkage even though its template argument does not. - // FIXME: This is probably a defect. - typedef T<WithoutLinkage1> WithLinkage10; -#else - typedef int WithLinkage10; // dummy - - typedef T<WithLinkage1> GoodArg1; - typedef T<WithLinkage2> GoodArg2; - typedef T<WithLinkage3a> GoodArg3a; - typedef T<WithLinkage3b> GoodArg3b; - typedef T<WithLinkage4a> GoodArg4a; - typedef T<WithLinkage4b> GoodArg4b; - typedef T<WithLinkage5> GoodArg5; - typedef T<WithLinkage6> GoodArg6; - typedef T<WithLinkage7> GoodArg7; - typedef T<WithLinkage8> GoodArg8; - typedef T<WithLinkage9> GoodArg9; - - typedef T<WithoutLinkage1> BadArg1; // expected-error{{template argument uses}} - typedef T<WithoutLinkage2> BadArg2; // expected-error{{template argument uses}} - typedef T<WithoutLinkage3> BadArg3; // expected-error{{template argument uses}} - typedef T<WithoutLinkage4> BadArg4; // expected-error{{template argument uses}} - typedef T<WithoutLinkage5> BadArg5; // expected-error{{template argument uses}} -#endif - - extern WithLinkage1 withLinkage1; - extern WithLinkage2 withLinkage2; - extern WithLinkage3a withLinkage3a; - extern WithLinkage3b withLinkage3b; - extern WithLinkage4a withLinkage4a; - extern WithLinkage4b withLinkage4b; - extern WithLinkage5 withLinkage5; - extern WithLinkage6 withLinkage6; - extern WithLinkage7 withLinkage7; - extern WithLinkage8 withLinkage8; - extern WithLinkage9 withLinkage9; - extern WithLinkage10 withLinkage10; - - // FIXME: These are all ill-formed. - extern WithoutLinkage1 withoutLinkage1; - extern WithoutLinkage2 withoutLinkage2; - extern WithoutLinkage3 withoutLinkage3; - extern WithoutLinkage4 withoutLinkage4; - extern WithoutLinkage5 withoutLinkage5; - - // OK, extern "C". - extern "C" { - extern WithoutLinkage1 dr389_withoutLinkage1; - extern WithoutLinkage2 dr389_withoutLinkage2; - extern WithoutLinkage3 dr389_withoutLinkage3; - extern WithoutLinkage4 dr389_withoutLinkage4; - extern WithoutLinkage5 dr389_withoutLinkage5; - } - - // OK, defined. - WithoutLinkage1 withoutLinkageDef1; - WithoutLinkage2 withoutLinkageDef2 = WithoutLinkage2(); - WithoutLinkage3 withoutLinkageDef3 = {}; - WithoutLinkage4 withoutLinkageDef4 = WithoutLinkage4(); - WithoutLinkage5 withoutLinkageDef5; - - void use(const void *); - void use_all() { - use(&withLinkage1); use(&withLinkage2); use(&withLinkage3a); use(&withLinkage3b); - use(&withLinkage4a); use(&withLinkage4b); use(&withLinkage5); use(&withLinkage6); - use(&withLinkage7); use(&withLinkage8); use(&withLinkage9); use(&withLinkage10); - - use(&withoutLinkage1); use(&withoutLinkage2); use(&withoutLinkage3); - use(&withoutLinkage4); use(&withoutLinkage5); - - use(&dr389_withoutLinkage1); use(&dr389_withoutLinkage2); - use(&dr389_withoutLinkage3); use(&dr389_withoutLinkage4); - use(&dr389_withoutLinkage5); - - use(&withoutLinkageDef1); use(&withoutLinkageDef2); use(&withoutLinkageDef3); - use(&withoutLinkageDef4); use(&withoutLinkageDef5); - } - - void local() { - // FIXME: This is ill-formed. - extern WithoutLinkage1 withoutLinkageLocal; - } -} - -namespace dr390 { // dr390: yes - template<typename T> - struct A { - A() { f(); } // expected-warning {{call to pure virt}} - virtual void f() = 0; // expected-note {{here}} - virtual ~A() = 0; - }; - template<typename T> A<T>::~A() { T::error; } // expected-error {{cannot be used prior to}} - template<typename T> void A<T>::f() { T::error; } // ok, not odr-used - struct B : A<int> { // expected-note 2{{in instantiation of}} - void f() {} - } b; -} - -namespace dr391 { // dr391: yes c++11 - // FIXME: Should this apply to C++98 too? - class A { A(const A&); }; // expected-note 0-1{{here}} - A fa(); - const A &a = fa(); -#if __cplusplus < 201103L - // expected-error@-2 {{C++98 requires an accessible copy constructor}} -#endif - - struct B { B(const B&) = delete; }; // expected-error 0-1{{extension}} expected-note 0-1{{here}} - B fb(); - const B &b = fb(); -#if __cplusplus < 201103L - // expected-error@-2 {{deleted}} -#endif - - template<typename T> - struct C { - C(const C&) { T::error; } - }; - C<int> fc(); - const C<int> &c = fc(); -} - -// dr392 FIXME write codegen test -// dr394: na - -namespace dr395 { // dr395: yes - struct S { - template <typename T, int N>(&operator T())[N]; // expected-error {{cannot specify any part of a return type}} - template <typename T, int N> operator(T (&)[N])(); // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error +{{}} - template <typename T> operator T *() const { return 0; } - template <typename T, typename U> operator T U::*() const { return 0; } - template <typename T, typename U> operator T (U::*)()() const { return 0; } // expected-error +{{}} - }; - - struct null1_t { - template <class T, class U> struct ptr_mem_fun_t { - typedef T (U::*type)(); - }; - - template <class T, class U> - operator typename ptr_mem_fun_t<T, U>::type() const { // expected-note {{couldn't infer}} - return 0; - } - } null1; - int (S::*p)() = null1; // expected-error {{no viable conversion}} - - template <typename T> using id = T; // expected-error 0-1{{extension}} - - struct T { - template <typename T, int N> operator id<T[N]> &(); - template <typename T, typename U> operator id<T (U::*)()>() const; - }; - - struct null2_t { - template<class T, class U> using ptr_mem_fun_t = T (U::*)(); // expected-error 0-1{{extension}} - template<class T, class U> operator ptr_mem_fun_t<T, U>() const { return 0; }; - } null2; - int (S::*q)() = null2; -} - -namespace dr396 { // dr396: yes - void f() { - auto int a(); // expected-error {{storage class on function}} - int (i); // expected-note {{previous}} - auto int (i); // expected-error {{redefinition}} -#if __cplusplus >= 201103L - // expected-error@-4 {{'auto' storage class}} expected-error@-2 {{'auto' storage class}} -#endif - } -} - -// dr397: sup 1823 - -namespace dr398 { // dr398: yes - namespace example1 { - struct S { - static int const I = 42; - }; - template <int N> struct X {}; - template <typename T> void f(X<T::I> *) {} - template <typename T> void f(X<T::J> *) {} - void foo() { f<S>(0); } - } - - namespace example2 { - template <int I> struct X {}; - template <template <class T> class> struct Z {}; - template <class T> void f(typename T::Y *) {} // expected-note 2{{substitution failure}} - template <class T> void g(X<T::N> *) {} // expected-note {{substitution failure}} - template <class T> void h(Z<T::template TT> *) {} // expected-note {{substitution failure}} - struct A {}; - struct B { - int Y; - }; - struct C { - typedef int N; - }; - struct D { - typedef int TT; - }; - - void test() { - f<A>(0); // expected-error {{no matching function}} - f<B>(0); // expected-error {{no matching function}} - g<C>(0); // expected-error {{no matching function}} - h<D>(0); // expected-error {{no matching function}} - } - } -} diff --git a/test/CXX/drs/dr412.cpp b/test/CXX/drs/dr412.cpp deleted file mode 100644 index 27bc7e5cf94e..000000000000 --- a/test/CXX/drs/dr412.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT="throw()" -DBAD_ALLOC="throw(std::bad_alloc)" -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC= -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC= -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC= - -// dr412: yes -// lwg404: yes -// lwg2340: yes - -// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets. -__extension__ typedef __SIZE_TYPE__ size_t; -namespace std { struct bad_alloc {}; } - -inline void* operator new(size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}} -inline void* operator new[](size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}} -inline void operator delete(void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}} -inline void operator delete[](void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}} -#ifdef __cpp_sized_deallocation -inline void operator delete(void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}} -inline void operator delete[](void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}} -#endif diff --git a/test/CXX/drs/dr4xx.cpp b/test/CXX/drs/dr4xx.cpp deleted file mode 100644 index 00393cc2e4c0..000000000000 --- a/test/CXX/drs/dr4xx.cpp +++ /dev/null @@ -1,1229 +0,0 @@ -// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets. -__extension__ typedef __SIZE_TYPE__ size_t; - -namespace std { struct type_info; } - -namespace dr400 { // dr400: yes - struct A { int a; struct a {}; }; // expected-note 2{{conflicting}} expected-note {{ambiguous}} - struct B { int a; struct a {}; }; // expected-note 2{{target}} expected-note {{ambiguous}} - struct C : A, B { using A::a; struct a b; }; - struct D : A, B { using A::a; using B::a; struct a b; }; // expected-error 2{{conflicts}} - struct E : A, B { struct a b; }; // expected-error {{found in multiple base classes}} -} - -namespace dr401 { // dr401: yes - template<class T, class U = typename T::type> class A : public T {}; // expected-error {{protected}} expected-error 2{{private}} - - class B { - protected: - typedef int type; // expected-note {{protected}} -#if __cplusplus == 199711L - // expected-note@-2 {{protected}} -#endif - }; - - class C { - typedef int type; // expected-note {{private}} - friend class A<C>; // expected-note {{default argument}} - }; - - class D { - typedef int type; // expected-note {{private}} - friend class A<D, int>; - }; - - A<B> *b; // expected-note {{default argument}} - A<D> *d; // expected-note {{in instantiation of default argument}} - - struct E { - template<class T, class U = typename T::type> class A : public T {}; - }; - class F { - typedef int type; - friend class E; - }; - E::A<F> eaf; // ok, default argument is in befriended context - - // FIXME: Why do we get different diagnostics in C++11 onwards here? We seem - // to not treat the default template argument as a SFINAE context in C++98. - template<class T, class U = typename T::type> void f(T) {} - void g(B b) { f(b); } -#if __cplusplus < 201103L - // expected-error@-3 0-1{{extension}} expected-error@-3 {{protected}} expected-note@-3 {{instantiation}} - // expected-note@-3 {{substituting}} -#else - // expected-error@-5 {{no matching}} expected-note@-6 {{protected}} -#endif -} - -namespace dr403 { // dr403: yes - namespace A { - struct S {}; - int f(void*); - } - template<typename T> struct X {}; - typedef struct X<A::S>::X XS; - XS *p; - int k = f(p); // ok, finds A::f, even though type XS is a typedef-name - // referring to an elaborated-type-specifier naming a - // injected-class-name, which is about as far from a - // template-id as we can make it. -} - -// dr404: na -// (NB: also sup 594) - -namespace dr406 { // dr406: yes - typedef struct { - static int n; // expected-error {{static data member 'n' not allowed in anonymous struct}} - } A; -} - -namespace dr407 { // dr407: 3.8 - struct S; - typedef struct S S; - void f() { - struct S *p; - { - typedef struct S S; // expected-note {{here}} - struct S *p; // expected-error {{typedef 'S' cannot be referenced with a struct specifier}} - } - } - struct S {}; - - namespace UsingDir { - namespace A { - struct S {}; // expected-note {{found}} - } - namespace B { - typedef int S; // expected-note {{found}} - } - namespace C { - using namespace A; - using namespace B; - struct S s; // expected-error {{ambiguous}} - } - namespace D { - using A::S; - typedef struct S S; - struct S s; - } - namespace E { - // The standard doesn't say whether this is valid. We interpret - // DR407 as meaning "if lookup finds both a tag and a typedef with the - // same type, then it's OK in an elaborated-type-specifier". - typedef A::S S; - using A::S; - struct S s; - } - namespace F { - typedef A::S S; - } - // The standard doesn't say what to do in these cases either. - namespace G { - using namespace A; - using namespace F; - struct S s; - } - namespace H { - using namespace F; - using namespace A; - struct S s; - } - } -} - -namespace dr408 { // dr408: 3.4 - template<int N> void g() { int arr[N != 1 ? 1 : -1]; } - template<> void g<2>() { } - - template<typename T> struct S { - static int i[]; - void f(); - }; - template<typename T> int S<T>::i[] = { 1 }; - - template<typename T> void S<T>::f() { - g<sizeof (i) / sizeof (int)>(); - } - template<> int S<int>::i[] = { 1, 2 }; - template void S<int>::f(); // uses g<2>(), not g<1>(). - - - template<typename T> struct R { - static int arr[]; - void f(); - }; - template<typename T> int R<T>::arr[1]; - template<typename T> void R<T>::f() { - int arr[sizeof(arr) != sizeof(int) ? 1 : -1]; - } - template<> int R<int>::arr[2]; - template void R<int>::f(); -} - -namespace dr409 { // dr409: yes - template<typename T> struct A { - typedef int B; - B b1; - A::B b2; - A<T>::B b3; - A<T*>::B b4; // expected-error {{missing 'typename'}} - }; -} - -namespace dr410 { // dr410: no - template<class T> void f(T); - void g(int); - namespace M { - template<class T> void h(T); - template<class T> void i(T); - struct A { - friend void f<>(int); - friend void h<>(int); - friend void g(int); - template<class T> void i(T); - friend void i<>(int); - private: - static void z(); // expected-note {{private}} - }; - - template<> void h(int) { A::z(); } - // FIXME: This should be ill-formed. The member A::i<> is befriended, - // not this function. - template<> void i(int) { A::z(); } - } - template<> void f(int) { M::A::z(); } - void g(int) { M::A::z(); } // expected-error {{private}} -} - -// dr412 is in its own file. - -namespace dr413 { // dr413: yes - struct S { - int a; - int : 17; - int b; - }; - S s = { 1, 2, 3 }; // expected-error {{excess elements}} - - struct E {}; - struct T { // expected-note {{here}} - int a; - E e; - int b; - }; - T t1 = { 1, {}, 2 }; - T t2 = { 1, 2 }; // expected-error {{aggregate with no elements requires explicit braces}} -} - -namespace dr414 { // dr414: dup 305 - struct X {}; - void f() { - X x; - struct X {}; - x.~X(); - } -} - -namespace dr415 { // dr415: yes - template<typename T> void f(T, ...) { T::error; } - void f(int, int); - void g() { f(0, 0); } // ok -} - -namespace dr416 { // dr416: yes - extern struct A a; - int &operator+(const A&, const A&); - int &k = a + a; - struct A { float &operator+(A&); }; - float &f = a + a; -} - -namespace dr417 { // dr417: no - struct A; - struct dr417::A {}; // expected-warning {{extra qualification}} - struct B { struct X; }; - struct C : B {}; - struct C::X {}; // expected-error {{no struct named 'X' in 'dr417::C'}} - struct B::X { struct Y; }; - struct C::X::Y {}; // ok! - namespace N { - struct D; - struct E; - struct F; - struct H; - } - // FIXME: This is ill-formed. - using N::D; - struct dr417::D {}; // expected-warning {{extra qualification}} - using namespace N; - struct dr417::E {}; // expected-warning {{extra qualification}} expected-error {{no struct named 'E'}} - struct N::F {}; - struct G; - using N::H; - namespace M { - struct dr417::G {}; // expected-error {{namespace 'M' does not enclose}} - struct dr417::H {}; // expected-error {{namespace 'M' does not enclose}} - } -} - -namespace dr420 { // dr420: yes - template<typename T> struct ptr { - T *operator->() const; - T &operator*() const; - }; - template<typename T, typename P> void test(P p) { - p->~T(); - p->T::~T(); - (*p).~T(); - (*p).T::~T(); - } - struct X {}; - template void test<int>(int*); - template void test<int>(ptr<int>); - template void test<X>(X*); - template void test<X>(ptr<X>); - - template<typename T> - void test2(T p) { - p->template Y<int>::~Y<int>(); - p->~Y<int>(); - // FIXME: This is ill-formed, but this diagnostic is terrible. We should - // reject this in the parser. - p->template ~Y<int>(); // expected-error 2{{no member named '~typename Y<int>'}} - } - template<typename T> struct Y {}; - template void test2(Y<int>*); // expected-note {{instantiation}} - template void test2(ptr<Y<int> >); // expected-note {{instantiation}} - - void test3(int *p, ptr<int> q) { - typedef int Int; - p->~Int(); - q->~Int(); - p->Int::~Int(); - q->Int::~Int(); - } - -#if __cplusplus >= 201103L - template<typename T> using id = T; - struct A { template<typename T> using id = T; }; - void test4(int *p, ptr<int> q) { - p->~id<int>(); - q->~id<int>(); - p->id<int>::~id<int>(); - q->id<int>::~id<int>(); - p->template id<int>::~id<int>(); // expected-error {{'template' keyword not permitted here}} expected-error {{base type 'int' is not a struct}} - q->template id<int>::~id<int>(); // expected-error {{'template' keyword not permitted here}} expected-error {{base type 'int' is not a struct}} - p->A::template id<int>::~id<int>(); - q->A::template id<int>::~id<int>(); - } -#endif -} - -namespace dr421 { // dr421: yes - struct X { X(); int n; int &r; }; - int *p = &X().n; // expected-error-re {{{{taking the address of a temporary|cannot take the address of an rvalue}}}} - int *q = &X().r; -} - -namespace dr422 { // dr422: yes - template<typename T, typename U> void f() { - typedef T type; // expected-note {{prev}} - typedef U type; // expected-error {{redef}} - } - template void f<int, int>(); - template void f<int, char>(); // expected-note {{instantiation}} -} - -namespace dr423 { // dr423: yes - template<typename T> struct X { operator T&(); }; - void f(X<int> x) { x += 1; } -} - -namespace dr424 { // dr424: yes - struct A { - typedef int N; // expected-note {{previous}} - typedef int N; // expected-error {{redefinition}} - - struct X; - typedef X X; // expected-note {{previous}} - struct X {}; - - struct X *p; - struct A::X *q; - X *r; - - typedef X X; // expected-error {{redefinition}} - }; - struct B { - typedef int N; - }; - struct C : B { - typedef int N; // expected-note {{previous}} - typedef int N; // expected-error {{redefinition}} - }; -} - -namespace dr425 { // dr425: yes - struct A { template<typename T> operator T() const; } a; - float f = 1.0f * a; // expected-error {{ambiguous}} expected-note 5+{{built-in candidate}} - - template<typename T> struct is_float; - template<> struct is_float<float> { typedef void type; }; - - struct B { - template<typename T, typename U = typename is_float<T>::type> operator T() const; // expected-error 0-1{{extension}} - } b; - float g = 1.0f * b; // ok -} - -namespace dr427 { // dr427: yes - struct B {}; - struct D : public B { - D(B &) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}} - }; - - extern D d1; - B &b = d1; - const D &d2 = static_cast<const D&>(b); - const D &d3 = (const D&)b; - const D &d4(b); // expected-error {{deleted}} -} - -namespace dr428 { // dr428: yes - template<typename T> T make(); - extern struct X x; // expected-note 5{{forward declaration}} - void f() { - throw void(); // expected-error {{cannot throw}} - throw make<void*>(); - throw make<const volatile void*>(); - throw x; // expected-error {{cannot throw}} - throw make<X&>(); // expected-error {{cannot throw}} - throw make<X*>(); // expected-error {{cannot throw}} - throw make<const volatile X&>(); // expected-error {{cannot throw}} - throw make<const volatile X*>(); // expected-error {{cannot throw}} - } -} - -namespace dr429 { // dr429: yes c++11 - // FIXME: This rule is obviously intended to apply to C++98 as well. - struct A { - static void *operator new(size_t, size_t); - static void operator delete(void*, size_t); - } *a = new (0) A; -#if __cplusplus >= 201103L - // expected-error@-2 {{'new' expression with placement arguments refers to non-placement 'operator delete'}} - // expected-note@-4 {{here}} -#endif - struct B { - static void *operator new(size_t, size_t); - static void operator delete(void*); - static void operator delete(void*, size_t); - } *b = new (0) B; // ok, second delete is not a non-placement deallocation function -} - -namespace dr430 { // dr430: yes c++11 - // resolved by n2239 - // FIXME: This should apply in C++98 too. - void f(int n) { - int a[] = { n++, n++, n++ }; -#if __cplusplus < 201103L - // expected-warning@-2 {{multiple unsequenced modifications to 'n'}} -#endif - } -} - -namespace dr431 { // dr431: yes - struct A { - template<typename T> T *get(); - template<typename T> struct B { - template<typename U> U *get(); - }; - }; - - template<typename T> void f(A a) { - a.get<A>()->get<T>(); - a.get<T>() - ->get<T>(); // expected-error {{use 'template'}} - a.get<T>()->template get<T>(); - a.A::get<T>(); - A::B<int> *b = a.get<A::B<int> >(); - b->get<int>(); - b->A::B<int>::get<int>(); - b->A::B<int>::get<T>(); - b->A::B<T>::get<int>(); // expected-error {{use 'template'}} - b->A::B<T>::template get<int>(); - b->A::B<T>::get<T>(); // expected-error {{use 'template'}} - b->A::B<T>::template get<T>(); - A::B<T> *c = a.get<A::B<T> >(); - c->get<int>(); // expected-error {{use 'template'}} - c->template get<int>(); - } -} - -namespace dr432 { // dr432: yes - template<typename T> struct A {}; - template<typename T> struct B : A<B> {}; // expected-error {{requires template arguments}} expected-note {{declared}} - template<typename T> struct C : A<C<T> > {}; -#if __cplusplus >= 201103L - template<typename T> struct D : decltype(A<D>()) {}; // expected-error {{requires template arguments}} expected-note {{declared}} -#endif -} - -namespace dr433 { // dr433: yes - template<class T> struct S { - void f(union U*); - }; - U *p; - template<class T> void S<T>::f(union U*) {} - - S<int> s; -} - -namespace dr434 { // dr434: yes - void f() { - const int ci = 0; - int *pi = 0; - const int *&rpci = pi; // expected-error {{cannot bind}} - rpci = &ci; - *pi = 1; - } -} - -// dr435: na - -namespace dr436 { // dr436: yes - enum E { f }; // expected-note {{previous}} - void f(); // expected-error {{redefinition}} -} - -namespace dr437 { // dr437: sup 1308 - // This is superseded by 1308, which is in turn superseded by 1330, - // which restores this rule. - template<typename U> struct T : U {}; - struct S { - void f() throw(S); -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - void g() throw(T<S>); -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - struct U; - void h() throw(U); -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - struct U {}; - }; -} - -// dr438 FIXME write a codegen test -// dr439 FIXME write a codegen test -// dr441 FIXME write a codegen test -// dr442: sup 348 -// dr443: na - -namespace dr444 { // dr444: yes - struct D; - struct B { // expected-note {{candidate function (the implicit copy}} expected-note 0-1 {{implicit move}} - D &operator=(D &) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}} - }; - struct D : B { // expected-note {{candidate function (the implicit copy}} expected-note 0-1 {{implicit move}} - using B::operator=; - } extern d; - void f() { - d = d; // expected-error {{deleted}} - } -} - -namespace dr445 { // dr445: yes - class A { void f(); }; // expected-note {{private}} - struct B { - friend void A::f(); // expected-error {{private}} - }; -} - -namespace dr446 { // dr446: yes - struct C; - struct A { - A(); - A(const A&) = delete; // expected-error 0-1{{extension}} expected-note +{{deleted}} - A(const C&); - }; - struct C : A {}; - void f(A a, bool b, C c) { - void(b ? a : a); - b ? A() : a; // expected-error {{deleted}} - b ? a : A(); // expected-error {{deleted}} - b ? A() : A(); -#if __cplusplus <= 201402L - // expected-error@-2 {{deleted}} -#endif - - void(b ? a : c); - b ? a : C(); // expected-error {{deleted}} - b ? c : A(); -#if __cplusplus <= 201402L - // expected-error@-2 {{deleted}} -#endif - b ? A() : C(); -#if __cplusplus <= 201402L - // expected-error@-2 {{deleted}} -#endif - } -} - -namespace dr447 { // dr447: yes - struct A { int n; int a[4]; }; - template<int> struct U { - typedef int type; - template<typename V> static void h(); - }; - template<typename T> U<sizeof(T)> g(T); - template<typename T, int N> void f(int n) { - // ok, not type dependent - g(__builtin_offsetof(A, n)).h<int>(); - g(__builtin_offsetof(T, n)).h<int>(); - // value dependent if first argument is a dependent type - U<__builtin_offsetof(A, n)>::type a; - U<__builtin_offsetof(T, n)>::type b; // expected-error +{{}} expected-warning 0+{{}} - // as an extension, we allow the member-designator to include array indices - g(__builtin_offsetof(A, a[0])).h<int>(); - g(__builtin_offsetof(A, a[N])).h<int>(); - U<__builtin_offsetof(A, a[0])>::type c; - U<__builtin_offsetof(A, a[N])>::type d; // expected-error +{{}} expected-warning 0+{{}} - } -} - -namespace dr448 { // dr448: yes - template<typename T = int> void f(int); // expected-error 0-1{{extension}} expected-note {{no known conversion}} - template<typename T> void g(T t) { - f<T>(t); // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} - dr448::f(t); // expected-error {{no matching function}} - } - template<typename T> void f(T); // expected-note {{should be declared prior to the call site}} - namespace HideFromADL { struct X {}; } - template void g(int); // ok - template void g(HideFromADL::X); // expected-note {{instantiation of}} -} - -// dr449: na - -namespace dr450 { // dr450: yes - typedef int A[3]; - void f1(const A &); - void f2(A &); // expected-note +{{not viable}} - struct S { A n; }; - void g() { - f1(S().n); - f2(S().n); // expected-error {{no match}}} - } -#if __cplusplus >= 201103L - void h() { - f1(A{}); - f2(A{}); // expected-error {{no match}} - } -#endif -} - -namespace dr451 { // dr451: yes - const int a = 1 / 0; // expected-warning {{undefined}} - const int b = 1 / 0; // expected-warning {{undefined}} - int arr[b]; // expected-error +{{variable length arr}} -} - -namespace dr452 { // dr452: yes - struct A { - int a, b, c; - A *p; - int f(); - A() : a(f()), b(this->f() + a), c(this->a), p(this) {} - }; -} - -// dr454 FIXME write a codegen test - -namespace dr456 { // dr456: yes - // sup 903 c++11 - const int null = 0; - void *p = null; -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot initialize}} -#else - // expected-warning@-4 {{null}} -#endif - - const bool f = false; - void *q = f; -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot initialize}} -#else - // expected-warning@-4 {{null}} -#endif -} - -namespace dr457 { // dr457: yes - const int a = 1; - const volatile int b = 1; - int ax[a]; - int bx[b]; // expected-error +{{variable length array}} - - enum E { - ea = a, - eb = b // expected-error {{constant}} expected-note {{read of volatile-qualified}} - }; -} - -namespace dr458 { // dr458: no - struct A { - int T; - int f(); - template<typename> int g(); - }; - - template<typename> struct B : A { - int f(); - template<typename> int g(); - template<typename> int h(); - }; - - int A::f() { - return T; - } - template<typename T> - int A::g() { - return T; // FIXME: this is invalid, it finds the template parameter - } - - template<typename T> - int B<T>::f() { - return T; - } - template<typename T> template<typename U> - int B<T>::g() { - return T; - } - template<typename U> template<typename T> - int B<U>::h() { - return T; // FIXME: this is invalid, it finds the template parameter - } -} - -namespace dr460 { // dr460: yes - namespace X { namespace Q { int n; } } - namespace Y { - using X; // expected-error {{requires a qualified name}} - using dr460::X; // expected-error {{cannot refer to a namespace}} - using X::Q; // expected-error {{cannot refer to a namespace}} - } -} - -// dr461: na -// dr462 FIXME write a codegen test -// dr463: na -// dr464: na -// dr465: na - -namespace dr466 { // dr466: no - typedef int I; - typedef const int CI; - typedef volatile int VI; - void f(int *a, CI *b, VI *c) { - a->~I(); - a->~CI(); - a->~VI(); - a->I::~I(); - a->CI::~CI(); - a->VI::~VI(); - - a->CI::~VI(); // FIXME: This is invalid; CI and VI are not the same scalar type. - - b->~I(); - b->~CI(); - b->~VI(); - b->I::~I(); - b->CI::~CI(); - b->VI::~VI(); - - c->~I(); - c->~CI(); - c->~VI(); - c->I::~I(); - c->CI::~CI(); - c->VI::~VI(); - } -} - -namespace dr467 { // dr467: yes - int stuff(); - - int f() { - static bool done; - if (done) - goto later; - static int k = stuff(); - done = true; - later: - return k; - } - int g() { - goto later; // expected-error {{cannot jump}} - int k = stuff(); // expected-note {{bypasses variable initialization}} - later: - return k; - } -} - -namespace dr468 { // dr468: yes c++11 - // FIXME: Should we allow this in C++98 too? - template<typename> struct A { - template<typename> struct B { - static int C; - }; - }; - int k = dr468::template A<int>::template B<char>::C; -#if __cplusplus < 201103L - // expected-error@-2 2{{'template' keyword outside of a template}} -#endif -} - -namespace dr469 { // dr469: no - template<typename T> struct X; // expected-note {{here}} - template<typename T> struct X<const T> {}; - X<int&> x; // expected-error {{undefined}} -} - -namespace dr470 { // dr470: yes - template<typename T> struct A { - struct B {}; - }; - template<typename T> struct C { - }; - - template struct A<int>; // expected-note {{previous}} - template struct A<int>::B; // expected-error {{duplicate explicit instantiation}} - - // ok, instantiating C<char> doesn't instantiate base class members. - template struct A<char>; - template struct C<char>; -} - -namespace dr471 { // dr471: yes - struct A { int n; }; - struct B : private virtual A {}; - struct C : protected virtual A {}; - struct D : B, C { int f() { return n; } }; - struct E : private virtual A { - using A::n; - }; - struct F : E, B { int f() { return n; } }; - struct G : virtual A { - private: - using A::n; // expected-note {{here}} - }; - struct H : B, G { int f() { return n; } }; // expected-error {{private}} -} - -namespace dr474 { // dr474: yes - namespace N { - struct S { - void f(); - }; - } - void N::S::f() { - void g(); // expected-note {{previous}} - } - int g(); - namespace N { - int g(); // expected-error {{cannot be overloaded}} - } -} - -// dr475 FIXME write a codegen test - -namespace dr477 { // dr477: 3.5 - struct A { - explicit A(); - virtual void f(); - }; - struct B { - friend explicit A::A(); // expected-error {{'explicit' is invalid in friend declarations}} - friend virtual void A::f(); // expected-error {{'virtual' is invalid in friend declarations}} - }; - explicit A::A() {} // expected-error {{can only be specified inside the class definition}} - virtual void A::f() {} // expected-error {{can only be specified inside the class definition}} -} - -namespace dr478 { // dr478: yes - struct A { virtual void f() = 0; }; // expected-note {{unimplemented}} - void f(A *a); - void f(A a[10]); // expected-error {{array of abstract class type}} -} - -namespace dr479 { // dr479: yes - struct S { - S(); - private: - S(const S&); // expected-note +{{here}} - ~S(); // expected-note +{{here}} - }; - void f() { - throw S(); - // expected-error@-1 {{temporary of type 'dr479::S' has private destructor}} - // expected-error@-2 {{exception object of type 'dr479::S' has private destructor}} -#if __cplusplus < 201103L - // expected-error@-4 {{C++98 requires an accessible copy constructor}} -#endif -#if __cplusplus <= 201402L - // expected-error@-7 {{calling a private constructor}} (copy ctor) -#endif - } - void g() { - S s; // expected-error {{private destructor}}} - throw s; - // expected-error@-1 {{calling a private constructor}} - // expected-error@-2 {{exception object of type 'dr479::S' has private destructor}} - } - void h() { - try { - f(); - g(); - } catch (S s) { - // expected-error@-1 {{calling a private constructor}} - // expected-error@-2 {{variable of type 'dr479::S' has private destructor}} - } - } -} - -namespace dr480 { // dr480: yes - struct A { int n; }; - struct B : A {}; - struct C : virtual B {}; - struct D : C {}; - - int A::*a = &A::n; - int D::*b = a; // expected-error {{virtual base}} - - extern int D::*c; - int A::*d = static_cast<int A::*>(c); // expected-error {{virtual base}} - - D *e; - A *f = e; - D *g = static_cast<D*>(f); // expected-error {{virtual base}} - - extern D &i; - A &j = i; - D &k = static_cast<D&>(j); // expected-error {{virtual base}} -} - -namespace dr481 { // dr481: yes - template<class T, T U> class A { T *x; }; - T *x; // expected-error {{unknown type}} - - template<class T *U> class B { T *x; }; - T *y; // ok - - struct C { - template<class T> void f(class D *p); - }; - D *z; // ok - - template<typename A = C, typename C = A> struct E { - void f() { - typedef ::dr481::C c; // expected-note {{previous}} - typedef C c; // expected-error {{different type}} - } - }; - template struct E<>; // ok - template struct E<int>; // expected-note {{instantiation of}} - - template<template<typename U_no_typo_correction> class A, - A<int> *B, - U_no_typo_correction *C> // expected-error {{unknown type}} - struct F { - U_no_typo_correction *x; // expected-error {{unknown type}} - }; - - template<template<class H *> class> struct G { - H *x; - }; - H *q; - - typedef int N; - template<N X, typename N, template<N Y> class T> struct I; - template<char*> struct J; - I<123, char*, J> *j; -} - -namespace dr482 { // dr482: 3.5 - extern int a; - void f(); - - int dr482::a = 0; // expected-warning {{extra qualification}} - void dr482::f() {} // expected-warning {{extra qualification}} - - inline namespace X { // expected-error 0-1{{C++11 feature}} - extern int b; - void g(); - struct S; - } - int dr482::b = 0; // expected-warning {{extra qualification}} - void dr482::g() {} // expected-warning {{extra qualification}} - struct dr482::S {}; // expected-warning {{extra qualification}} - - void dr482::f(); // expected-warning {{extra qualification}} - void dr482::g(); // expected-warning {{extra qualification}} - - // FIXME: The following are valid in DR482's wording, but these are bugs in - // the wording which we deliberately don't implement. - namespace N { typedef int type; } - typedef int N::type; // expected-error {{typedef declarator cannot be qualified}} - struct A { - struct B; - struct A::B {}; // expected-error {{extra qualification}} - -#if __cplusplus >= 201103L - enum class C; - enum class A::C {}; // expected-error {{extra qualification}} -#endif - }; -} - -namespace dr483 { // dr483: yes - namespace climits { - int check1[__SCHAR_MAX__ >= 127 ? 1 : -1]; - int check2[__SHRT_MAX__ >= 32767 ? 1 : -1]; - int check3[__INT_MAX__ >= 32767 ? 1 : -1]; - int check4[__LONG_MAX__ >= 2147483647 ? 1 : -1]; - int check5[__LONG_LONG_MAX__ >= 9223372036854775807 ? 1 : -1]; -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} -#endif - } - namespace cstdint { - int check1[__PTRDIFF_WIDTH__ >= 16 ? 1 : -1]; - int check2[__SIG_ATOMIC_WIDTH__ >= 8 ? 1 : -1]; - int check3[__SIZE_WIDTH__ >= 16 ? 1 : -1]; - int check4[__WCHAR_WIDTH__ >= 8 ? 1 : -1]; - int check5[__WINT_WIDTH__ >= 16 ? 1 : -1]; - } -} - -namespace dr484 { // dr484: yes - struct A { - A(); - void f(); - }; - typedef const A CA; - void CA::f() { - this->~CA(); - this->CA::~A(); - this->CA::A::~A(); - } - CA::A() {} - - struct B : CA { - B() : CA() {} - void f() { return CA::f(); } - }; - - struct C; - typedef C CT; // expected-note {{here}} - struct CT {}; // expected-error {{conflicts with typedef}} - - namespace N { - struct D; - typedef D DT; // expected-note {{here}} - } - struct N::DT {}; // expected-error {{conflicts with typedef}} - - typedef struct { - S(); // expected-error {{requires a type}} - } S; -} - -namespace dr485 { // dr485: yes - namespace N { - struct S {}; - int operator+(S, S); - template<typename T> int f(S); - } - template<typename T> int f(); - - N::S s; - int a = operator+(s, s); - int b = f<int>(s); -} - -namespace dr486 { // dr486: yes - template<typename T> T f(T *); // expected-note 2{{substitution failure}} - int &f(...); - - void g(); - int n[10]; - - void h() { - int &a = f(&g); - int &b = f(&n); - f<void()>(&g); // expected-error {{no match}} - f<int[10]>(&n); // expected-error {{no match}} - } -} - -namespace dr487 { // dr487: yes - enum E { e }; - int operator+(int, E); - int i[4 + e]; // expected-error 2{{variable length array}} -} - -namespace dr488 { // dr488: yes c++11 - template <typename T> void f(T); - void f(int); - void g() { - // FIXME: It seems CWG thought this should be a SFINAE failure prior to - // allowing local types as template arguments. In C++98, we should either - // allow local types as template arguments or treat this as a SFINAE - // failure. - enum E { e }; - f(e); -#if __cplusplus < 201103L - // expected-error@-2 {{local type}} -#endif - } -} - -// dr489: na - -namespace dr490 { // dr490: yes - template<typename T> struct X {}; - - struct A { - typedef int T; - struct K {}; // expected-note {{declared}} - - int f(T); - int g(T); - int h(X<T>); - int X<T>::*i(); // expected-note {{previous}} - int K::*j(); - - template<typename T> T k(); - - operator X<T>(); - }; - - struct B { - typedef char T; - typedef int U; - friend int A::f(T); - friend int A::g(U); - friend int A::h(X<T>); - - // FIXME: Per this DR, these two are valid! That is another defect - // (no number yet...) which will eventually supersede this one. - friend int X<T>::*A::i(); // expected-error {{return type}} - friend int K::*A::j(); // expected-error {{undeclared identifier 'K'; did you mean 'A::K'?}} - - // ok, lookup finds B::T, not A::T, so return type matches - friend char A::k<T>(); - friend int A::k<U>(); - - // A conversion-type-id in a conversion-function-id is always looked up in - // the class of the conversion function first. - friend A::operator X<T>(); - }; -} - -namespace dr491 { // dr491: dup 413 - struct A {} a, b[3] = { a, {} }; - A c[2] = { a, {}, b[1] }; // expected-error {{excess elements}} -} - -// dr492 FIXME write a codegen test - -namespace dr493 { // dr493: dup 976 - struct X { - template <class T> operator const T &() const; - }; - void f() { - if (X()) { - } - } -} - -namespace dr494 { // dr494: dup 372 - class A { - class B {}; - friend class C; - }; - class C : A::B { - A::B x; - class D : A::B { - A::B y; - }; - }; -} - -namespace dr495 { // dr495: 3.5 - template<typename T> - struct S { - operator int() { return T::error; } - template<typename U> operator U(); - }; - S<int> s; - long n = s; - - template<typename T> - struct S2 { - template<typename U> operator U(); - operator int() { return T::error; } - }; - S2<int> s2; - long n2 = s2; -} - -namespace dr496 { // dr496: sup 2094 - struct A { int n; }; - struct B { volatile int n; }; - int check1[ __is_trivially_copyable(const int) ? 1 : -1]; - // This checks the dr2094 behavior, not dr496 - int check2[ __is_trivially_copyable(volatile int) ? 1 : -1]; - int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1]; - int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1]; - int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1]; - int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1]; -} - -namespace dr497 { // dr497: sup 253 - void before() { - struct S { - mutable int i; - }; - const S cs; - int S::*pm = &S::i; - cs.*pm = 88; // expected-error {{not assignable}} - } - - void after() { - struct S { - S() : i(0) {} - mutable int i; - }; - const S cs; - int S::*pm = &S::i; - cs.*pm = 88; // expected-error {{not assignable}} - } -} - -namespace dr499 { // dr499: yes - extern char str[]; - void f() { throw str; } -} diff --git a/test/CXX/drs/dr5xx.cpp b/test/CXX/drs/dr5xx.cpp deleted file mode 100644 index 2099612e23f3..000000000000 --- a/test/CXX/drs/dr5xx.cpp +++ /dev/null @@ -1,1016 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -// FIXME: This is included to avoid a diagnostic with no source location -// pointing at the implicit operator new. We can't match such a diagnostic -// with -verify. -__extension__ typedef __SIZE_TYPE__ size_t; -void *operator new(size_t); // expected-error 0-1{{missing exception spec}} expected-note{{candidate}} -#if __cplusplus > 201402L -namespace std { - enum class align_val_t : size_t {}; -} -void *operator new(size_t, std::align_val_t); // expected-note{{candidate}} -#endif - -namespace dr500 { // dr500: dup 372 - class D; - class A { - class B; - class C; - friend class D; - }; - class A::B {}; - class A::C : public A::B {}; - class D : public A::B {}; -} - -namespace dr501 { // dr501: yes - struct A { - friend void f() {} - void g() { - void (*p)() = &f; // expected-error {{undeclared identifier}} - } - }; -} - -namespace dr502 { // dr502: yes - struct Q {}; - template<typename T> struct A { - enum E { e = 1 }; - void q1() { f(e); } - void q2() { Q arr[sizeof(E)]; f(arr); } - void q3() { Q arr[e]; f(arr); } - void sanity() { Q arr[1]; f(arr); } // expected-error {{undeclared identifier 'f'}} - }; - int f(A<int>::E); - template<int N> int f(Q (&)[N]); - template struct A<int>; -} - -namespace dr505 { // dr505: yes - const char *exts = "\e\(\{\[\%"; // expected-error 5{{use of non-standard escape}} - const char *unknown = "\Q"; // expected-error {{unknown escape sequence}} -} - -namespace dr506 { // dr506: yes - struct NonPod { ~NonPod(); }; - void f(...); - void g(NonPod np) { f(np); } // expected-error {{cannot pass}} -} - -// FIXME: Add tests here once DR260 is resolved. -// dr507: dup 260 - -// dr508: na -// dr509: na -// dr510: na - -namespace dr512 { // dr512: yes - struct A { - A(int); - }; - union U { A a; }; -#if __cplusplus < 201103L - // expected-error@-2 {{has a non-trivial default constructor}} - // expected-note@-6 {{no default constructor}} - // expected-note@-6 {{suppressed by user-declared constructor}} -#endif -} - -// dr513: na - -namespace dr514 { // dr514: yes - namespace A { extern int x, y; } - int A::x = y; -} - -namespace dr515 { // dr515: sup 1017 - // FIXME: dr1017 reverses the wording of dr515, but the current draft has - // dr515's wording, with a different fix for dr1017. - - struct X { int n; }; - template<typename T> struct Y : T { - int f() { return X::n; } - }; - int k = Y<X>().f(); - - struct A { int a; }; - struct B { void f() { int k = sizeof(A::a); } }; -#if __cplusplus < 201103L - // expected-error@-2 {{invalid use of non-static data member}} -#endif -} - -// dr516: na - -namespace dr517 { // dr517: no - // This is NDR, but we should diagnose it anyway. - template<typename T> struct S {}; - template<typename T> int v = 0; // expected-error 0-1{{extension}} - - template struct S<int*>; - template int v<int*>; - - S<char&> s; - int k = v<char&>; - - // FIXME: These are both ill-formed. - template<typename T> struct S<T*> {}; - template<typename T> int v<T*> = 0; // expected-error 0-1{{extension}} - - // FIXME: These are both ill-formed. - template<typename T> struct S<T&> {}; - template<typename T> int v<T&> = 0; // expected-error 0-1{{extension}} -} - -namespace dr518 { // dr518: yes c++11 - enum E { e, }; -#if __cplusplus < 201103L - // expected-error@-2 {{C++11 extension}} -#endif -} - -namespace dr519 { // dr519: yes -// FIXME: Add a codegen test. -#if __cplusplus >= 201103L -#define fold(x) (__builtin_constant_p(x) ? (x) : (x)) - int test[fold((int*)(void*)0) ? -1 : 1]; -#undef fold -#endif -} - -// dr520: na - -// dr521: no -// FIXME: The wording here is broken. It's not reasonable to expect a -// diagnostic here. Once the relevant DR gets a number, mark this as a dup. - -namespace dr522 { // dr522: yes - struct S {}; - template<typename T> void b1(volatile T &); - template<typename T> void b2(volatile T * const *); - template<typename T> void b2(volatile T * const S::*); - template<typename T> void b2(volatile T * const S::* const *); - template<typename T> void b2a(volatile T *S::* const *); // expected-note {{candidate template ignored: deduced type 'volatile int *dr522::S::*const *' of 1st parameter does not match adjusted type 'int *dr522::S::**' of argument}} - - template<typename T> struct Base {}; - struct Derived : Base<int> {}; - template<typename T> void b3(Base<T>); - template<typename T> void b3(Base<T> *); - - void test(int n, const int cn, int **p, int *S::*pm) { - int *a[3], *S::*am[3]; - const Derived cd = Derived(); - Derived d[3]; - - b1(n); - b1(cn); - b2(p); - b2(pm); - b2(a); - b2(am); - b2a(am); // expected-error {{no matching function}} - b3(d); - b3(cd); - } -} - -namespace dr524 { // dr524: yes - template<typename T> void f(T a, T b) { operator+(a, b); } // expected-error {{call}} - - struct S {}; - void operator+(S, S); - template void f(S, S); - - namespace N { struct S {}; } - void operator+(N::S, N::S); // expected-note {{should be declared}} - template void f(N::S, N::S); // expected-note {{instantiation}} -} - -namespace dr525 { // dr525: yes - namespace before { - // Note, the example was correct prior to the change; instantiation is - // required for cases like this: - template <class T> struct D { operator T*(); }; - void g(D<double> ppp) { - delete ppp; - } - } - namespace after { - template <class T> struct D { typename T::error e; }; // expected-error {{prior to '::'}} - void g(D<double> *ppp) { - delete ppp; // expected-note {{instantiation of}} - } - } -} - -namespace dr526 { // dr526: yes - template<int> struct S {}; - template<int N> void f1(S<N> s); - template<int N> void f2(S<(N)> s); // expected-note {{couldn't infer}} - template<int N> void f3(S<+N> s); // expected-note {{couldn't infer}} - template<int N> void g1(int (&)[N]); - template<int N> void g2(int (&)[(N)]); // expected-note {{couldn't infer}} - template<int N> void g3(int (&)[+N]); // expected-note {{couldn't infer}} - - void test(int (&a)[3], S<3> s) { - f1(s); - f2(s); // expected-error {{no matching}} - f3(s); // expected-error {{no matching}} - g1(a); - g2(a); // expected-error {{no matching}} - g3(a); // expected-error {{no matching}} - } - - template<int N> struct X { - typedef int type; - X<N>::type v1; - X<(N)>::type v2; // expected-error {{missing 'typename'}} - X<+N>::type v3; // expected-error {{missing 'typename'}} - }; -} - -namespace dr527 { // dr527: na - // This DR is meaningless. It removes a required diagnostic from the case - // where a not-externally-visible object is odr-used but not defined, which - // requires a diagnostic for a different reason. - extern struct { int x; } a; // FIXME: We should reject this, per dr389. - static struct { int x; } b; - extern "C" struct { int x; } c; - namespace { extern struct { int x; } d; } - typedef struct { int x; } *P; - struct E { static P e; }; // FIXME: We should reject this, per dr389. - namespace { struct F { static P f; }; } - - int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x; -} - -namespace dr530 { // dr530: yes - template<int*> struct S { enum { N = 1 }; }; - template<void(*)()> struct T { enum { N = 1 }; }; - int n; - void f(); - int a[S<&n>::N]; - int b[T<&f>::N]; -} - -namespace dr531 { // dr531: partial - namespace good { - template<typename T> struct A { - void f(T) { T::error; } - template<typename U> void g(T, U) { T::error; } - struct B { typename T::error error; }; - template<typename U> struct C { typename T::error error; }; - static T n; - }; - template<typename T> T A<T>::n = T::error; - - template<> void A<int>::f(int) {} - template<> template<typename U> void A<int>::g(int, U) {} - template<> struct A<int>::B {}; - template<> template<typename U> struct A<int>::C {}; - template<> int A<int>::n = 0; - - void use(A<int> a) { - a.f(a.n); - a.g(0, 0); - A<int>::B b; - A<int>::C<int> c; - } - - template<> struct A<char> { - void f(char); - template<typename U> void g(char, U); - struct B; - template<typename U> struct C; - static char n; - }; - - void A<char>::f(char) {} - template<typename U> void A<char>::g(char, U) {} - struct A<char>::B {}; - template<typename U> struct A<char>::C {}; - char A<char>::n = 0; - } - - namespace bad { - template<typename T> struct A { - void f(T) { T::error; } - template<typename U> void g(T, U) { T::error; } - struct B { typename T::error error; }; - template<typename U> struct C { typename T::error error; }; // expected-note {{here}} - static T n; - }; - template<typename T> T A<T>::n = T::error; - - void A<int>::f(int) {} // expected-error {{requires 'template<>'}} - template<typename U> void A<int>::g(int, U) {} // expected-error {{should be empty}} - struct A<int>::B {}; // expected-error {{requires 'template<>'}} - template<typename U> struct A<int>::C {}; // expected-error {{should be empty}} expected-error {{different kind of symbol}} - int A<int>::n = 0; // expected-error {{requires 'template<>'}} - - template<> struct A<char> { // expected-note 2{{here}} - void f(char); - template<typename U> void g(char, U); - struct B; // expected-note {{here}} - template<typename U> struct C; - static char n; - }; - - template<> void A<char>::f(char) {} // expected-error {{no function template matches}} - // FIXME: This is ill-formed; -pedantic-errors should reject. - template<> template<typename U> void A<char>::g(char, U) {} // expected-warning {{extraneous template parameter list}} - template<> struct A<char>::B {}; // expected-error {{extraneous 'template<>'}} expected-error {{does not specialize}} - // FIXME: This is ill-formed; -pedantic-errors should reject. - template<> template<typename U> struct A<char>::C {}; // expected-warning {{extraneous template parameter list}} - template<> char A<char>::n = 0; // expected-error {{extraneous 'template<>'}} - } - - namespace nested { - template<typename T> struct A { - template<typename U> struct B; - }; - template<> template<typename U> struct A<int>::B { - void f(); - void g(); - template<typename V> void h(); - template<typename V> void i(); - }; - template<> template<typename U> void A<int>::B<U>::f() {} - template<typename U> void A<int>::B<U>::g() {} // expected-error {{should be empty}} - - template<> template<typename U> template<typename V> void A<int>::B<U>::h() {} - template<typename U> template<typename V> void A<int>::B<U>::i() {} // expected-error {{should be empty}} - - template<> template<> void A<int>::B<int>::f() {} - template<> template<> template<typename V> void A<int>::B<int>::h() {} - template<> template<> template<> void A<int>::B<int>::h<int>() {} - - template<> void A<int>::B<char>::f() {} // expected-error {{requires 'template<>'}} - template<> template<typename V> void A<int>::B<char>::h() {} // expected-error {{should be empty}} - } -} - -// PR8130 -namespace dr532 { // dr532: 3.5 - struct A { }; - - template<class T> struct B { - template<class R> int &operator*(R&); - }; - - template<class T, class R> float &operator*(T&, R&); - void test() { - A a; - B<A> b; - int &ir = b * a; - } -} - -// dr533: na - -namespace dr534 { // dr534: yes - struct S {}; - template<typename T> void operator+(S, T); - template<typename T> void operator+<T*>(S, T*) {} // expected-error {{function template partial spec}} -} - -namespace dr535 { // dr535: yes - class X { private: X(const X&); }; - struct A { - X x; - template<typename T> A(T&); - }; - struct B : A { - X y; - B(volatile A&); - }; - - extern A a1; - A a2(a1); // ok, uses constructor template - - extern volatile B b1; - B b2(b1); // ok, uses converting constructor - - void f() { throw a1; } - -#if __cplusplus >= 201103L - struct C { - constexpr C() : n(0) {} - template<typename T> constexpr C(T&t) : n(t.n == 0 ? throw 0 : 0) {} - int n; - }; - constexpr C c() { return C(); } - // ok, copy is elided - constexpr C x = c(); -#endif -} - -// dr537: na -// dr538: na - -// dr539: yes -const dr539( // expected-error {{requires a type specifier}} - const a) { // expected-error {{unknown type name 'a'}} - const b; // expected-error {{requires a type specifier}} - new const; // expected-error {{expected a type}} - try {} catch (const n) {} // expected-error {{unknown type name 'n'}} - try {} catch (const) {} // expected-error {{expected a type}} - if (const n = 0) {} // expected-error {{requires a type specifier}} - switch (const n = 0) {} // expected-error {{requires a type specifier}} - while (const n = 0) {} // expected-error {{requires a type specifier}} - for (const n = 0; // expected-error {{requires a type specifier}} - const m = 0; ) {} // expected-error {{requires a type specifier}} - sizeof(const); // expected-error {{requires a type specifier}} - struct S { - const n; // expected-error {{requires a type specifier}} - operator const(); // expected-error {{expected a type}} - }; -#if __cplusplus >= 201103L - int arr[3]; - // FIXME: The extra braces here are to avoid the parser getting too - // badly confused when recovering here. We should fix this recovery. - { for (const n // expected-error {{unknown type name 'n'}} expected-note {{}} - : arr) ; {} } // expected-error +{{}} - (void) [](const) {}; // expected-error {{requires a type specifier}} - (void) [](const n) {}; // expected-error {{unknown type name 'n'}} - enum E : const {}; // expected-error {{expected a type}} - using T = const; // expected-error {{expected a type}} - auto f() -> const; // expected-error {{expected a type}} -#endif -} - -namespace dr540 { // dr540: yes - typedef int &a; - typedef const a &a; // expected-warning {{has no effect}} - typedef const int &b; - typedef b &b; - typedef const a &c; // expected-note {{previous}} expected-warning {{has no effect}} - typedef const b &c; // expected-error {{different}} expected-warning {{has no effect}} -} - -namespace dr541 { // dr541: yes - template<int> struct X { typedef int type; }; - template<typename T> struct S { - int f(T); - - int g(int); - T g(bool); - - int h(); - int h(T); - - void x() { - // These are type-dependent expressions, even though we could - // determine that all calls have type 'int'. - X<sizeof(f(0))>::type a; // expected-error +{{}} - X<sizeof(g(0))>::type b; // expected-error +{{}} - X<sizeof(h(0))>::type b; // expected-error +{{}} - - typename X<sizeof(f(0))>::type a; - typename X<sizeof(h(0))>::type b; - } - }; -} - -namespace dr542 { // dr542: yes -#if __cplusplus >= 201103L - struct A { A() = delete; int n; }; - A a[32] = {}; // ok, constructor not called - - struct B { - int n; - private: - B() = default; - }; - B b[32] = {}; // ok, constructor not called -#endif -} - -namespace dr543 { // dr543: yes - // In C++98+DR543, this is valid because value-initialization doesn't call a - // trivial default constructor, so we never notice that defining the - // constructor would be ill-formed. - // - // In C++11+DR543, this is ill-formed, because the default constructor is - // deleted, and value-initialization *does* call a deleted default - // constructor, even if it is trivial. - struct A { - const int n; - }; - A a = A(); -#if __cplusplus >= 201103L - // expected-error@-2 {{deleted}} - // expected-note@-5 {{would not be initialized}} -#endif -} - -namespace dr544 { // dr544: yes - int *n; - - template<class T> struct A { int n; }; - template<class T> struct B : A<T> { int get(); }; - template<> int B<int>::get() { return n; } - int k = B<int>().get(); -} - -namespace dr546 { // dr546: yes - template<typename T> struct A { void f(); }; - template struct A<int>; - template<typename T> void A<T>::f() { T::error; } -} - -namespace dr547 { // dr547: yes - template<typename T> struct X; - template<typename T> struct X<T() const> {}; - template<typename T, typename C> X<T> f(T C::*) { return X<T>(); } - - struct S { void f() const; }; - X<void() const> x = f(&S::f); -} - -namespace dr548 { // dr548: dup 482 - template<typename T> struct S {}; - template<typename T> void f() {} - template struct dr548::S<int>; - template void dr548::f<int>(); -} - -namespace dr551 { // dr551: yes c++11 - // FIXME: This obviously should apply in C++98 mode too. - template<typename T> void f() {} - template inline void f<int>(); -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be 'inline'}} -#endif - - template<typename T> inline void g() {} - template inline void g<int>(); -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be 'inline'}} -#endif - - template<typename T> struct X { - void f() {} - }; - template inline void X<int>::f(); -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be 'inline'}} -#endif -} - -namespace dr552 { // dr552: yes - template<typename T, typename T::U> struct X {}; - struct Y { typedef int U; }; - X<Y, 0> x; -} - -struct dr553_class { - friend void *operator new(size_t, dr553_class); -}; -namespace dr553 { - dr553_class c; - // Contrary to the apparent intention of the DR, operator new is not actually - // looked up with a lookup mechanism that performs ADL; the standard says it - // "is looked up in global scope", where it is not visible. - void *p = new (c) int; // expected-error {{no matching function}} - - struct namespace_scope { - friend void *operator new(size_t, namespace_scope); // expected-error {{cannot be declared inside a namespace}} - }; -} - -// dr556: na - -namespace dr557 { // dr557: yes - template<typename T> struct S { - friend void f(S<T> *); - friend void g(S<S<T> > *); - }; - void x(S<int> *p, S<S<int> > *q) { - f(p); - g(q); - } -} - -namespace dr558 { // dr558: yes - wchar_t a = L'\uD7FF'; - wchar_t b = L'\xD7FF'; - wchar_t c = L'\uD800'; // expected-error {{invalid universal character}} - wchar_t d = L'\xD800'; - wchar_t e = L'\uDFFF'; // expected-error {{invalid universal character}} - wchar_t f = L'\xDFFF'; - wchar_t g = L'\uE000'; - wchar_t h = L'\xE000'; -} - -template<typename> struct dr559 { typedef int T; dr559::T u; }; // dr559: yes - -namespace dr561 { // dr561: yes - template<typename T> void f(int); - template<typename T> void g(T t) { - f<T>(t); - } - namespace { - struct S {}; - template<typename T> static void f(S); - } - void h(S s) { - g(s); - } -} - -namespace dr564 { // dr564: yes - extern "C++" void f(int); - void f(int); // ok - extern "C++" { extern int n; } - int n; // ok -} - -namespace dr565 { // dr565: yes - namespace N { - template<typename T> int f(T); // expected-note {{target}} - } - using N::f; // expected-note {{using}} - template<typename T> int f(T*); - template<typename T> void f(T); - template<typename T, int = 0> int f(T); // expected-error 0-1{{extension}} - template<typename T> int f(T, int = 0); - template<typename T> int f(T); // expected-error {{conflicts with}} -} - -namespace dr566 { // dr566: yes -#if __cplusplus >= 201103L - int check[int(-3.99) == -3 ? 1 : -1]; -#endif -} - -// dr567: na - -namespace dr568 { // dr568: yes c++11 - // FIXME: This is a DR issue against C++98, so should probably apply there - // too. - struct x { int y; }; - class trivial : x { - x y; - public: - int n; - }; - int check_trivial[__is_trivial(trivial) ? 1 : -1]; - - struct std_layout { - std_layout(); - std_layout(const std_layout &); - ~std_layout(); - private: - int n; - }; - int check_std_layout[__is_standard_layout(std_layout) ? 1 : -1]; - - struct aggregate { - int x; - int y; - trivial t; - std_layout sl; - }; - aggregate aggr = {}; - - void f(...); - void g(trivial t) { f(t); } -#if __cplusplus < 201103L - // expected-error@-2 {{non-POD}} -#endif - - void jump() { - goto x; -#if __cplusplus < 201103L - // expected-error@-2 {{cannot jump}} - // expected-note@+2 {{non-POD}} -#endif - trivial t; - x: ; - } -} - -namespace dr569 { // dr569: yes c++11 - // FIXME: This is a DR issue against C++98, so should probably apply there - // too. - ;;;;; -#if __cplusplus < 201103L - // expected-error@-2 {{C++11 extension}} -#endif -} - -namespace dr570 { // dr570: dup 633 - int n; - int &r = n; // expected-note {{previous}} - int &r = n; // expected-error {{redefinition}} -} - -namespace dr571 { // dr571 unknown - // FIXME: Add a codegen test. - typedef int &ir; - int n; - const ir r = n; // expected-warning {{has no effect}} FIXME: Test if this has internal linkage. -} - -namespace dr572 { // dr572: yes - enum E { a = 1, b = 2 }; - int check[a + b == 3 ? 1 : -1]; -} - -namespace dr573 { // dr573: no - void *a; - int *b = reinterpret_cast<int*>(a); - void (*c)() = reinterpret_cast<void(*)()>(a); - void *d = reinterpret_cast<void*>(c); -#if __cplusplus < 201103L - // expected-error@-3 {{extension}} - // expected-error@-3 {{extension}} -#endif - void f() { delete a; } // expected-error {{cannot delete}} - int n = d - a; // expected-error {{arithmetic on pointers to void}} - // FIXME: This is ill-formed. - template<void*> struct S; - template<int*> struct T; -} - -namespace dr574 { // dr574: yes - struct A { - A &operator=(const A&) const; // expected-note {{different qualifiers}} - }; - struct B { - B &operator=(const B&) volatile; // expected-note {{different qualifiers}} - }; -#if __cplusplus >= 201103L - struct C { - C &operator=(const C&) &; // expected-note {{not viable}} expected-note {{candidate}} expected-note {{here}} - }; - struct D { - D &operator=(const D&) &&; // expected-note {{not viable}} expected-note {{candidate}} expected-note {{here}} - }; - void test(C c, D d) { - c = c; - C() = c; // expected-error {{no viable}} - d = d; // expected-error {{no viable}} - D() = d; - } -#endif - struct Test { - friend A &A::operator=(const A&); // expected-error {{does not match}} - friend B &B::operator=(const B&); // expected-error {{does not match}} -#if __cplusplus >= 201103L - // FIXME: We shouldn't produce the 'cannot overload' diagnostics here. - friend C &C::operator=(const C&); // expected-error {{does not match}} expected-error {{cannot overload}} - friend D &D::operator=(const D&); // expected-error {{does not match}} expected-error {{cannot overload}} -#endif - }; -} - -namespace dr575 { // dr575: yes - template<typename T, typename U = typename T::type> void a(T); void a(...); // expected-error 0-1{{extension}} - template<typename T, typename T::type U = 0> void b(T); void b(...); // expected-error 0-1{{extension}} - template<typename T, int U = T::value> void c(T); void c(...); // expected-error 0-1{{extension}} - template<typename T> void d(T, int = T::value); void d(...); // expected-error {{cannot be used prior to '::'}} - void x() { - a(0); - b(0); - c(0); - d(0); // expected-note {{in instantiation of default function argument}} - } - - template<typename T = int&> void f(T* = 0); // expected-error 0-1{{extension}} - template<typename T = int> void f(T = 0); // expected-error 0-1{{extension}} - void g() { f<>(); } - - template<typename T> T &h(T *); - template<typename T> T *h(T *); - void *p = h((void*)0); -} - -namespace dr576 { // dr576: yes - typedef void f() {} // expected-error {{function definition declared 'typedef'}} - void f(typedef int n); // expected-error {{invalid storage class}} - void f(char c) { typedef int n; } -} - -namespace dr577 { // dr577: yes - typedef void V; - typedef const void CV; - void a(void); - void b(const void); // expected-error {{qualifiers}} - void c(V); - void d(CV); // expected-error {{qualifiers}} - void (*e)(void) = c; - void (*f)(const void); // expected-error {{qualifiers}} - void (*g)(V) = a; - void (*h)(CV); // expected-error {{qualifiers}} - template<typename T> void i(T); // expected-note 2{{requires 1 arg}} - template<typename T> void j(void (*)(T)); // expected-note 2{{argument may not have 'void' type}} - void k() { - a(); - c(); - i<void>(); // expected-error {{no match}} - i<const void>(); // expected-error {{no match}} - j<void>(0); // expected-error {{no match}} - j<const void>(0); // expected-error {{no match}} - } -} - -namespace dr580 { // dr580: partial - class C; - struct A { static C c; }; - struct B { static C c; }; - class C { - C(); // expected-note {{here}} - ~C(); // expected-note {{here}} - - typedef int I; // expected-note 2{{here}} - template<int> struct X; - template<int> friend struct Y; - template<int> void f(); - template<int> friend void g(); - friend struct A; - }; - - template<C::I> struct C::X {}; - template<C::I> struct Y {}; - template<C::I> struct Z {}; // expected-error {{private}} - - struct C2 { - class X { - struct A; - typedef int I; - friend struct A; - }; - class Y { - template<X::I> struct A {}; // FIXME: We incorrectly accept this - // because we think C2::Y::A<...> might - // instantiate to C2::X::A - }; - }; - - template<C::I> void C::f() {} - template<C::I> void g() {} - template<C::I> void h() {} // expected-error {{private}} - - C A::c; - C B::c; // expected-error 2{{private}} -} - -// dr582: na - -namespace dr583 { // dr583: 4 - // see n3624 - int *p; - bool b1 = p < 0; // expected-error {{ordered comparison between pointer and zero}} - bool b2 = p > 0; // expected-error {{ordered comparison between pointer and zero}} - bool b3 = p <= 0; // expected-error {{ordered comparison between pointer and zero}} - bool b4 = p >= 0; // expected-error {{ordered comparison between pointer and zero}} -} - -// dr584: na - -namespace dr585 { // dr585: yes - template<typename> struct T; - struct A { - friend T; -#if __cplusplus <= 201402L - // expected-error@-2 {{requires a type specifier}} expected-error@-2 {{can only be classes or functions}} -#else - // expected-error@-4 {{use of class template 'T' requires template arguments; argument deduction not allowed in friend declaration}} - // expected-note@-7 {{here}} -#endif - // FIXME: It's not clear whether the standard allows this or what it means, - // but the DR585 writeup suggests it as an alternative. - template<typename U> friend T<U>; // expected-error {{must use an elaborated type}} - }; - template<template<typename> class T> struct B { - friend T; -#if __cplusplus <= 201402L - // expected-error@-2 {{requires a type specifier}} expected-error@-2 {{can only be classes or functions}} -#else - // expected-error@-4 {{use of template template parameter 'T' requires template arguments; argument deduction not allowed in friend declaration}} - // expected-note@-6 {{here}} -#endif - template<typename U> friend T<U>; // expected-error {{must use an elaborated type}} - }; -} - -// dr586: na - -namespace dr587 { // dr587: yes - template<typename T> void f(bool b, const T x, T y) { - const T *p = &(b ? x : y); - } - struct S {}; - template void f(bool, const int, int); - template void f(bool, const S, S); -} - -namespace dr588 { // dr588: yes - struct A { int n; }; // expected-note {{ambiguous}} - template<typename T> int f() { - struct S : A, T { int f() { return n; } } s; - int a = s.f(); - int b = s.n; // expected-error {{found in multiple}} - } - struct B { int n; }; // expected-note {{ambiguous}} - int k = f<B>(); // expected-note {{here}} -} - -namespace dr589 { // dr589: yes - struct B { }; - struct D : B { }; - D f(); - extern const B &b; - bool a; - const B *p = &(a ? f() : b); // expected-error {{temporary}} - const B *q = &(a ? D() : b); // expected-error {{temporary}} -} - -namespace dr590 { // dr590: yes - template<typename T> struct A { - struct B { - struct C { - A<T>::B::C f(A<T>::B::C); // ok, no 'typename' required. - }; - }; - }; - template<typename T> typename A<T>::B::C A<T>::B::C::f(A<T>::B::C) {} -} - -namespace dr591 { // dr591: no - template<typename T> struct A { - typedef int M; - struct B { - typedef void M; - struct C; - }; - }; - - template<typename T> struct A<T>::B::C : A<T> { - // FIXME: Should find member of non-dependent base class A<T>. - M m; // expected-error {{incomplete type 'dr591::A::B::M' (aka 'void'}} - }; -} - -// dr592: na -// dr593 needs an IRGen test. -// dr594: na - -namespace dr595 { // dr595: dup 1330 - template<class T> struct X { - void f() throw(T) {} -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - }; - struct S { - X<S> xs; - }; -} - -// dr597: na - -namespace dr598 { // dr598: yes - namespace N { - void f(int); - void f(char); - // Not found by ADL. - void g(void (*)(int)); - void h(void (*)(int)); - - namespace M { - struct S {}; - int &h(void (*)(S)); - } - void i(M::S); - void i(); - } - int &g(void(*)(char)); - int &r = g(N::f); - int &s = h(N::f); // expected-error {{undeclared}} - int &t = h(N::i); -} - -namespace dr599 { // dr599: partial - typedef int Fn(); - struct S { operator void*(); }; - struct T { operator Fn*(); }; - struct U { operator int*(); operator void*(); }; // expected-note 2{{conversion}} - struct V { operator int*(); operator Fn*(); }; - void f(void *p, void (*q)(), S s, T t, U u, V v) { - delete p; // expected-error {{cannot delete}} - delete q; // expected-error {{cannot delete}} - delete s; // expected-error {{cannot delete}} - delete t; // expected-error {{cannot delete}} - // FIXME: This is valid, but is rejected due to a non-conforming GNU - // extension allowing deletion of pointers to void. - delete u; // expected-error {{ambiguous}} - delete v; - } -} diff --git a/test/CXX/drs/dr6xx.cpp b/test/CXX/drs/dr6xx.cpp deleted file mode 100644 index b4247b22607d..000000000000 --- a/test/CXX/drs/dr6xx.cpp +++ /dev/null @@ -1,1122 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking - -namespace std { - struct type_info {}; - __extension__ typedef __SIZE_TYPE__ size_t; -} // namespace std - -namespace dr601 { // dr601: yes -#if __cplusplus >= 201103L -#define MAX __LLONG_MAX__ -#else -#define MAX __LONG_MAX__ -#endif - -#if 0x8000 < -1 -#error 0x8000 should be signed -#endif - -#if MAX > 0xFFFFFFFF && 0x80000000 < -1 -#error 0x80000000 should be signed -#endif - -#if __INT_MAX__ == 0x7FFFFFFF -_Static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); // expected-error {{C11}} -#endif - -#if MAX > 0xFFFFFFFFFFFFFFFF && 0x8000000000000000 < -1 -#error 0x8000000000000000 should be signed -#endif - -#if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFFFFFFFFFFFFFF -static_assert(0x8000000000000000 < -1, "0x8000000000000000 should be unsigned"); // expected-error {{C11}} -#endif - -#undef MAX -} - -namespace dr602 { // dr602: yes - template<class T> struct A { - template<class U> friend struct A; - }; - - template<class T> struct B { - class C { - template<class U> friend struct B; - typedef int type; - }; - typename C::type ct; // ok, befriended - }; - B<int> b; -} - -namespace dr603 { // dr603: yes - template<unsigned char> struct S {}; - typedef S<'\001'> S1; - typedef S<(1ul << __CHAR_BIT__) + 1> S1; -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be narrowed}} -#endif -} - -// dr604: na -// dr605 needs IRGen test - -namespace dr606 { // dr606: yes -#if __cplusplus >= 201103L - template<typename T> struct S {}; - template<typename T> void f(S<T> &&); // expected-note {{no known conversion from 'S<int>' to 'S<int> &&'}} - template<typename T> void g(T &&); - template<typename T> void h(const T &&); // expected-note {{no known conversion from 'S<int>' to 'const dr606::S<int> &&'}} - - void test(S<int> s) { - f(s); // expected-error {{no match}} - g(s); - h(s); // expected-error {{no match}} - - g(test); - h(test); // ok, an rvalue reference can bind to a function lvalue - } -#endif -} - -namespace dr608 { // dr608: yes - struct A { virtual void f(); }; - struct B : A {}; - struct C : A { void f(); }; - struct D : B, C {}; -} - -int dr610[-0u == 0u ? 1 : -1]; // dr610: yes - -namespace dr611 { // dr611: yes - int k; - struct S { int &r; } s = { k ? k : k }; -} - -// dr612: na - -namespace dr613 { // dr613: yes c++11 - // see also n2253 - struct A { int n; static void f(); }; - int f(int); - struct B { virtual void f(); }; - B &g(int); - - int an1 = sizeof(A::n); - int an2 = sizeof(A::n + 1); // valid per dr850 - int an3 = sizeof A::n; - int an4 = sizeof(f(A::n)); - int an5 = sizeof(g(A::n)); - const std::type_info &an6 = typeid(A::n); - const std::type_info &an7 = typeid(A::n + 1); - const std::type_info &an8 = typeid(f(A::n)); - const std::type_info &an9 = typeid(g(A::n)); // expected-error {{non-static}} -#if __cplusplus < 201103L - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} -#endif - - void A::f() { - int an1 = sizeof n; - const std::type_info &an2 = typeid(n + 1); -#if __cplusplus < 201103L - // expected-error@-3 {{static}} - // expected-error@-3 {{static}} -#endif - const std::type_info &an3 = typeid(g(n)); // expected-error {{static}} - } -} - -int dr614_a[(-1) / 2 == 0 ? 1 : -1]; // dr614: yes -int dr614_b[(-1) % 2 == -1 ? 1 : -1]; - -namespace dr615 { // dr615: yes - int f(); - static int n = f(); -} - -namespace dr616 { // dr616: 4 -#if __cplusplus >= 201103L - struct S { int n; } s; - S f(); - using T = decltype((S().n)); - using T = decltype((static_cast<S&&>(s).n)); - using T = decltype((f().n)); - using T = decltype(S().*&S::n); - using T = decltype(static_cast<S&&>(s).*&S::n); - using T = decltype(f().*&S::n); - using T = int&&; - - using U = decltype(S().n); - using U = decltype(static_cast<S&&>(s).n); - using U = int; -#endif -} - -namespace dr618 { // dr618: yes -#if (unsigned)-1 > 0 -#error wrong -#endif -} - -namespace dr619 { // dr619: yes - extern int x[10]; - struct S { static int x[10]; }; - - int x[]; - _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}} - extern int x[]; - _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}} - - int S::x[]; - _Static_assert(sizeof(S::x) == sizeof(int) * 10, ""); // expected-error {{C11}} - - void f() { - extern int x[]; - sizeof(x); // expected-error {{incomplete}} - } -} - -// dr620: dup 568 - -namespace dr621 { - template<typename T> T f(); - template<> int f() {} // expected-note {{previous}} - template<> int f<int>() {} // expected-error {{redefinition}} -} - -// dr623: na -// FIXME: Add documentation saying we allow invalid pointer values. - -// dr624 needs an IRGen check. - -namespace dr625 { // dr625: yes - template<typename T> struct A {}; - A<auto> x = A<int>(); // expected-error {{'auto' not allowed in template argument}} expected-error 0-1{{extension}} - void f(int); - void (*p)(auto) = f; // expected-error {{'auto' not allowed in function prototype}} expected-error 0-1{{extension}} -} - -namespace dr626 { // dr626: yes -#define STR(x) #x - char c[2] = STR(c); // ok, type matches - wchar_t w[2] = STR(w); // expected-error {{initializing wide char array with non-wide string literal}} -} - -namespace dr627 { // dr627: yes - void f() { - true a = 0; // expected-error +{{}} expected-warning {{unused}} - } -} - -// dr628: na - -namespace dr629 { // dr629: yes - typedef int T; - int n = 1; - void f() { - auto T = 2; -#if __cplusplus < 201103L - // expected-error@-2 {{expected unqualified-id}} -#else - // expected-note@-4 {{previous}} -#endif - - auto T(n); -#if __cplusplus >= 201103L - // expected-error@-2 {{redefinition of 'T'}} -#endif - } -} - -namespace dr630 { // dr630: yes -const bool MB_EQ_WC = - ' ' == L' ' && '\t' == L'\t' && '\v' == L'\v' && '\r' == L'\r' && - '\n' == L'\n' && // - 'a' == L'a' && 'b' == L'b' && 'c' == L'c' && 'd' == L'd' && 'e' == L'e' && - 'f' == L'f' && 'g' == L'g' && 'h' == L'h' && 'i' == L'i' && 'j' == L'j' && - 'k' == L'k' && 'l' == L'l' && 'm' == L'm' && 'n' == L'n' && 'o' == L'o' && - 'p' == L'p' && 'q' == L'q' && 'r' == L'r' && 's' == L's' && 't' == L't' && - 'u' == L'u' && 'v' == L'v' && 'w' == L'w' && 'x' == L'x' && 'y' == L'y' && - 'z' == L'z' && // - 'A' == L'A' && 'B' == L'B' && 'C' == L'C' && 'D' == L'D' && 'E' == L'E' && - 'F' == L'F' && 'G' == L'G' && 'H' == L'H' && 'I' == L'I' && 'J' == L'J' && - 'K' == L'K' && 'L' == L'L' && 'M' == L'M' && 'N' == L'N' && 'O' == L'O' && - 'P' == L'P' && 'Q' == L'Q' && 'R' == L'R' && 'S' == L'S' && 'T' == L'T' && - 'U' == L'U' && 'V' == L'V' && 'W' == L'W' && 'X' == L'X' && 'Y' == L'Y' && - 'Z' == L'Z' && // - '0' == L'0' && '1' == L'1' && '2' == L'2' && '3' == L'3' && '4' == L'4' && - '5' == L'5' && '6' == L'6' && '7' == L'7' && '8' == L'8' && - '9' == L'9' && // - '_' == L'_' && '{' == L'{' && '}' == L'}' && '[' == L'[' && ']' == L']' && - '#' == L'#' && '(' == L'(' && ')' == L')' && '<' == L'<' && '>' == L'>' && - '%' == L'%' && ':' == L':' && ';' == L';' && '.' == L'.' && '?' == L'?' && - '*' == L'*' && '+' == L'+' && '-' == L'-' && '/' == L'/' && '^' == L'^' && - '&' == L'&' && '|' == L'|' && '~' == L'~' && '!' == L'!' && '=' == L'=' && - ',' == L',' && '\\' == L'\\' && '"' == L'"' && '\'' == L'\''; -#if __STDC_MB_MIGHT_NEQ_WC__ -#ifndef __FreeBSD__ // PR22208, FreeBSD expects us to give a bad (but conforming) answer here. -_Static_assert(!MB_EQ_WC, "__STDC_MB_MIGHT_NEQ_WC__ but all basic source characters have same representation"); // expected-error {{C11}} -#endif -#else -_Static_assert(MB_EQ_WC, "!__STDC_MB_MIGHT_NEQ_WC__ but some character differs"); // expected-error {{C11}} -#endif -} - -// dr631: na - -namespace dr632 { // dr632: yes - struct S { int n; } s = {{5}}; // expected-warning {{braces}} -} - -// dr633: na -// see also n2993 - -namespace dr634 { // dr634: yes - struct S { S(); S(const S&); virtual void f(); ~S(); }; - int f(...); - char f(int); - template<typename T> int (&g(T))[sizeof f(T())]; - int (&a)[sizeof(int)] = g(S()); - int (&b)[1] = g(0); - int k = f(S()); // expected-error {{cannot pass}} -} - -namespace dr635 { // dr635: yes - template<typename T> struct A { A(); ~A(); }; - template<typename T> A<T>::A<T>() {} // expected-error {{cannot have template arguments}} - template<typename T> A<T>::~A<T>() {} - - template<typename T> struct B { B(); ~B(); }; - template<typename T> B<T>::B() {} - template<typename T> B<T>::~B() {} - - struct C { template<typename T> C(); C(); }; - template<typename T> C::C() {} - C::C() {} - template<> C::C<int>() {} // expected-error {{constructor name}} expected-error {{unqualified-id}} - /*FIXME: needed for error recovery:*/; - - template<typename T> struct D { template<typename U> D(); D(); }; - template<typename T> D<T>::D() {} // expected-note {{previous}} - template<typename T> template<typename U> D<T>::D() {} - template<typename T> D<T>::D<T>() {} // expected-error {{redefinition}} expected-error {{cannot have template arg}} -} - -namespace dr637 { // dr637: yes - void f(int i) { - i = ++i + 1; - i = i++ + 1; // expected-warning {{unsequenced}} - } -} - -namespace dr638 { // dr638: no - template<typename T> struct A { - struct B; - void f(); - void g(); - struct C { - void h(); - }; - }; - - class X { - typedef int type; - template<class T> friend struct A<T>::B; // expected-warning {{not supported}} - template<class T> friend void A<T>::f(); // expected-warning {{not supported}} - template<class T> friend void A<T>::g(); // expected-warning {{not supported}} - template<class T> friend void A<T>::C::h(); // expected-warning {{not supported}} - }; - - template<> struct A<int> { - X::type a; // FIXME: private - struct B { - X::type b; // ok - }; - int f() { X::type c; } // FIXME: private - void g() { X::type d; } // ok - struct D { - void h() { X::type e; } // FIXME: private - }; - }; -} - -namespace dr639 { // dr639: yes - void f(int i) { - void((i = 0) + (i = 0)); // expected-warning {{unsequenced}} - } -} - -namespace dr641 { // dr641: yes - namespace std_example { - struct abc; - - struct xyz { - xyz(); // expected-note 0-1{{candidate}} - xyz(xyz &); // expected-note 0-1{{candidate}} - - operator xyz &() = delete; // expected-error 0-1{{extension}} expected-warning {{will never be used}} - operator abc &() = delete; // expected-error 0-1{{extension}} - }; - - struct abc : xyz {}; - - template<typename T> - void use(T &); // expected-note {{expects an l-value}} - void test() { - use<xyz>(xyz()); // expected-error {{no match}} - use<const xyz>(xyz()); -#if __cplusplus < 201103L - // expected-error-re@-2 {{no viable constructor copying parameter of type '{{.*}}xyz'}} -#endif - } - } - - template<typename T> struct error { typedef typename T::error type; }; - - struct A { - template<typename T, typename error<T>::type = 0> operator T() const; // expected-error 0-1{{extension}} - }; - A a; - void f(A&); // expected-note 2{{candidate}} - void g(const A ca) { - f(A()); // expected-error {{no match}} - f(ca); // expected-error {{no match}} - (void)A(); - (void)ca; - } -} - -namespace dr642 { // dr642: yes - void f() { - const int i = 2; - { - char i[i]; - _Static_assert(sizeof(i) == 2, ""); // expected-error {{C11}} - } - } - - struct s { int a; }; - void g(int s) { - struct s *p = new struct s; - p->a = s; - } -} - -#if __cplusplus >= 201103L -namespace dr643 { // dr643: yes - struct A { - int x; - auto f() -> decltype(this->x); - auto f(A &a) -> decltype(a.x); - auto g() -> decltype(x); - auto h() -> decltype(this->y); // expected-error {{no member named 'y'}} - auto h(A &a) -> decltype(a.y); // expected-error {{no member named 'y'}} - auto i() -> decltype(y); // expected-error {{undeclared identifier 'y'}} - int y; - }; -} -#endif - -#if __cplusplus >= 201103L -namespace dr644 { // dr644: partial - struct A { - A() = default; - int x, y; - }; - static_assert(__is_literal_type(A), ""); - - struct B : A {}; - static_assert(__is_literal_type(B), ""); - - struct C : virtual A {}; - static_assert(!__is_literal_type(C), ""); - - struct D { C c; }; - static_assert(!__is_literal_type(D), ""); - - // FIXME: According to DR644, E<C> is a literal type despite having virtual - // base classes. This appears to be a wording defect. - template<typename T> - struct E : T { - constexpr E() = default; - }; - static_assert(!__is_literal_type(E<C>), ""); -} -#endif - -// dr645 increases permission to optimize; it's not clear that it's possible to -// test for this. -// dr645: na - -#if __cplusplus >= 201103L -namespace dr646 { // dr646: sup 981 - struct A { - constexpr A(const A&) = default; // ok - }; - - struct B { - constexpr B() {} - B(B&); - }; - constexpr B b = {}; // ok -} -#endif - -#if __cplusplus >= 201103L -namespace dr647 { // dr647: yes - // This is partially superseded by dr1358. - struct A { - constexpr virtual void f() const; - constexpr virtual void g() const {} // expected-error {{virtual function cannot be constexpr}} - }; - - struct X { virtual void f() const; }; // expected-note {{overridden}} - struct B : X { - constexpr void f() const {} // expected-error {{virtual function cannot be constexpr}} - }; - - struct NonLiteral { NonLiteral() {} }; // expected-note {{not an aggregate and has no constexpr constructors}} - - struct C { - constexpr C(NonLiteral); - constexpr C(NonLiteral, int) {} // expected-error {{not a literal type}} - constexpr C() try {} catch (...) {} -#if __cplusplus <= 201703L - // expected-error@-2 {{function try block in constexpr constructor is a C++2a extension}} -#endif -#if __cplusplus < 201402L - // expected-error@-5 {{use of this statement in a constexpr constructor is a C++14 extension}} -#endif - }; - - struct D { - operator int() const; - constexpr D(int) {} - D(float); // expected-note 2{{declared here}} - }; - constexpr int get(); - struct E { - int n; - D d; - - // FIXME: We should diagnose this, as the conversion function is not - // constexpr. However, that part of this issue is supreseded by dr1364 and - // others; no diagnostic is required for this any more. - constexpr E() - : n(D(0)), - d(0) {} - - constexpr E(int) // expected-error {{never produces a constant expression}} - : n(0), - d(0.0f) {} // expected-note {{non-constexpr constructor}} - constexpr E(float f) // expected-error {{never produces a constant expression}} - : n(get()), - d(D(0) + f) {} // expected-note {{non-constexpr constructor}} - }; -} -#endif - -#if __cplusplus >= 201103L -namespace dr648 { // dr648: yes - int f(); - constexpr int a = (true ? 1 : f()); - constexpr int b = false && f(); - constexpr int c = true || f(); -} -#endif - -#if __cplusplus >= 201103L -namespace dr649 { // dr649: yes - alignas(0x20000000) int n; // expected-error {{requested alignment}} - struct alignas(0x20000000) X {}; // expected-error {{requested alignment}} - struct Y { int n alignas(0x20000000); }; // expected-error {{requested alignment}} - struct alignas(256) Z {}; - // This part is superseded by dr2130 and eventually by aligned allocation support. - auto *p = new Z; -} -#endif - -// dr650 FIXME: add codegen test - -#if __cplusplus >= 201103L -namespace dr651 { // dr651: yes - struct X { - virtual X &f(); - }; - struct Y : X { - Y &f(); - }; - using T = decltype(((X&&)Y()).f()); - using T = X &; -} -#endif - -#if __cplusplus >= 201103L -namespace dr652 { // dr652: yes - constexpr int n = 1.2 * 3.4; - static_assert(n == 4, ""); -} -#endif - -// dr653 FIXME: add codegen test - -#if __cplusplus >= 201103L -namespace dr654 { // dr654: yes - void f() { - if (nullptr) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}} - bool b = nullptr; // expected-warning {{implicit conversion of nullptr constant to 'bool'}} - if (nullptr == 0) {} - if (nullptr != 0) {} - if (nullptr <= 0) {} // expected-error {{invalid operands}} - if (nullptr == 1) {} // expected-error {{invalid operands}} - if (!nullptr) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}} - decltype(nullptr) n = 0; - static_cast<int>(nullptr); // expected-error {{not allowed}} - (void)static_cast<decltype(nullptr)>(0); - static_cast<decltype(nullptr)>(1); // expected-error {{not allowed}} - void(true ? nullptr : 0); - void(true ? 0 : nullptr); - } -} -#endif - -namespace dr655 { // dr655: yes - struct A { A(int); }; // expected-note 2-3{{not viable}} - struct B : A { - A a; - B(); - B(int) : B() {} // expected-error 0-1 {{C++11}} - B(int*) : A() {} // expected-error {{no matching constructor}} - }; -} - -namespace dr656 { // dr656: yes - struct A { A(const A&) = delete; }; // expected-error 0-1 {{C++11}} - struct B : A {}; - struct X { operator B(); } x; - const A &r = x; - struct Y : private A { // expected-note 2{{here}} expected-note 2{{candidate}} - operator B() volatile; - }; - extern Y y; - extern volatile Y vy; - // Conversion not considered due to reference-related types. - const A &s = y; // expected-error {{private base class}} - const A &t = vy; // expected-error {{drops 'volatile'}} - - struct C { operator struct D(); } c; - struct D : C {}; - const D &d = c; // ok, D not reference-related to C - - template<typename T> void accept(T); // expected-note {{candidate}} - template<typename T> void accept(...) = delete; // expected-error 0-1 {{C++11}} expected-note {{candidate}} - void f() { - accept<const A&>(x); - accept<const A&>(y); // expected-error {{private base class}} - accept<const A&>(vy); // expected-error {{call to deleted}} expected-error {{no matching constructor}} - accept<const D&>(c); - } -} - -namespace dr657 { // dr657: partial - struct Abs { virtual void x() = 0; }; - struct Der : public Abs { virtual void x(); }; - - struct Cnvt { template<typename F> Cnvt(F); }; - - void foo(Cnvt a); - void foo(Abs &a); - void f(Abs *a) { foo(*a); } - - void bar(Abs &a); - template<typename T> void bar(T); - void g(Abs *a) { bar(*a); } - - // FIXME: The following examples demonstrate that we might be accepting the - // above cases for the wrong reason. - - // FIXME: We should reject this. - struct C { C(Abs) {} }; - // FIXME: We should reject this. - struct Q { operator Abs() { __builtin_unreachable(); } } q; -#if __cplusplus >= 201703L - // FIXME: We should *definitely* reject this. - C c = Q().operator Abs(); -#endif - - template<typename F> struct Cnvt2 { Cnvt2(F); typedef int type; }; - - // FIXME: We should reject this. - void baz(Abs &a); - template<typename T> typename Cnvt2<T>::type baz(T); - void h(Abs *a) { baz(*a); } - - // FIXME: We should reject this too. - Cnvt2<Abs>::type err; -} - -// dr658 FIXME: add codegen test - -#if __cplusplus >= 201103L -namespace dr659 { // dr659: yes - static_assert(alignof(char) == alignof(char&), ""); - static_assert(alignof(int) == alignof(int&), ""); - int n = alignof(int(&)()); // expected-error {{application of 'alignof' to a function type}} - struct A; // expected-note {{forward}} - int m = alignof(A&); // expected-error {{application of 'alignof' to an incomplete type}} -} -#endif - -#if __cplusplus >= 201103L -namespace dr660 { // dr660: yes - enum : int { a }; - enum class { b }; // expected-error {{requires a name}} - auto x = a; - - struct X { - enum : int { a }; - enum class { b }; // expected-error {{requires a name}} - }; - auto y = X::a; -} -#endif - -// dr661 FIXME: add codegen test - -namespace dr662 { // dr662: yes - template <typename T> void f(T t) { - T &tr = t; - T *tp = &t; // expected-error {{pointer to a reference}} -#if __cplusplus >= 201103L - auto *ap = &t; -#endif - } - void g(int n) { f<int&>(n); } // expected-note {{instantiation of}} -} - -namespace dr663 { // dr663: yes c++11 - int ЍЎ = 123; -#if __cplusplus < 201103L - // expected-error@-2 {{non-ASCII}} -#endif -} - -#if __cplusplus >= 201103L -namespace dr664 { // dr664: yes - struct A { A(const A&) = delete; }; - A &&f(A &&a, int n) { - if (n) - return f(static_cast<A&&>(a), n - 1); - return static_cast<A&&>(a); - } -} -#endif - -namespace dr665 { // dr665: yes - struct A { virtual ~A(); }; - struct B : A {} *b; - struct C : private A {} *c; // expected-note {{here}} - struct D : B, C {} *d; - - struct VB : virtual A {} *vb; - struct VC : private virtual A {} *vc; // expected-note {{here}} - struct VD : VB, VC {} *vd; - - void f() { - (void)dynamic_cast<A*>(b); - (void)dynamic_cast<A*>(c); // expected-error {{private}} - (void)dynamic_cast<A*>(d); // expected-error {{ambiguous}} - (void)dynamic_cast<A*>(vb); - (void)dynamic_cast<A*>(vc); // expected-error {{private}}, even though it could be valid at runtime - (void)dynamic_cast<A*>(vd); - } -} - -namespace dr666 { // dr666: yes - struct P { friend P operator*(P, P); P(int); } p(0); - - template<int> int f(); - template<typename T> int f() { - T::type *p = 0; // expected-error {{missing 'typename'}} - int a(T::type); // expected-error {{missing 'typename'}} - return f<T::type>(); // expected-error {{missing 'typename'}} - } - struct X { static const int type = 0; }; - struct Y { typedef int type; }; - int a = f<X>(); - int b = f<Y>(); // expected-note {{instantiation of}} -} - -// Triviality is entirely different in C++98. -#if __cplusplus >= 201103L -namespace dr667 { // dr667: yes - struct A { - A() = default; // expected-warning {{explicitly defaulted default constructor is implicitly deleted}} - int &r; // expected-note {{because field 'r' of reference type 'int &' would not be initialized}} - }; - static_assert(!__is_trivially_constructible(A), ""); - - struct B { ~B() = delete; }; - union C { B b; }; - static_assert(!__is_trivially_destructible(C), ""); - - struct D { D(const D&) = delete; }; - struct E : D {}; - static_assert(!__is_trivially_constructible(E, const E&), ""); - - struct F { F &operator=(F&&) = delete; }; - struct G : F {}; - static_assert(!__is_trivially_assignable(G, G&&), ""); -} -#endif - -// dr668 FIXME: add codegen test - -#if __cplusplus >= 201103L -namespace dr669 { // dr669: yes - void f() { - int n; - using T = decltype(n); - using T = int; - using U = decltype((n)); - using U = int &; - - [=] { - using V = decltype(n); - using V = int; - using W = decltype((n)); - using W = const int&; - } (); - - struct X { - int n; - void f() const { - using X = decltype(n); - using X = int; - using Y = decltype((n)); - using Y = const int&; - } - }; - } -} -#endif - -namespace dr671 { // dr671: yes - enum class E { e }; // expected-error 0-1 {{C++11}} - E e = static_cast<E>(0); - int n = static_cast<int>(E::e); // expected-error 0-1 {{C++11}} - int m = static_cast<int>(e); // expected-error 0-1 {{C++11}} -} - -// dr672 FIXME: add codegen test - -namespace dr673 { // dr673: yes - template<typename> struct X { static const int n = 0; }; - - class A { - friend class B *f(); - class C *f(); - void f(class D *); - enum { e = X<struct E>::n }; - void g() { extern struct F *p; } - }; - B *b; - C *c; - D *d; - E *e; - F *f; // expected-error {{unknown type name}} -} - -namespace dr674 { // dr674: 8 - template<typename T> int f(T); - - int g(int); - template<typename T> int g(T); - - int h(int); - template<typename T> int h(T); - - class X { - friend int dr674::f(int); - friend int dr674::g(int); - friend int dr674::h<>(int); - int n; // expected-note 2{{private}} - }; - - template<typename T> int f(T) { return X().n; } - int g(int) { return X().n; } - template<typename T> int g(T) { return X().n; } // expected-error {{private}} - int h(int) { return X().n; } // expected-error {{private}} - template<typename T> int h(T) { return X().n; } - - template int f(int); - template int g(int); // expected-note {{in instantiation of}} - template int h(int); - - - struct Y { - template<typename T> int f(T); - - int g(int); - template<typename T> int g(T); - - int h(int); - template<typename T> int h(T); - }; - - class Z { - friend int Y::f(int); - friend int Y::g(int); - friend int Y::h<>(int); - int n; // expected-note 2{{private}} - }; - - template<typename T> int Y::f(T) { return Z().n; } - int Y::g(int) { return Z().n; } - template<typename T> int Y::g(T) { return Z().n; } // expected-error {{private}} - int Y::h(int) { return Z().n; } // expected-error {{private}} - template<typename T> int Y::h(T) { return Z().n; } - - // FIXME: Should the <> be required here? - template int Y::f<>(int); - template int Y::g<>(int); // expected-note {{in instantiation of}} - template int Y::h<>(int); -} - -namespace dr675 { // dr675: dup 739 - template<typename T> struct A { T n : 1; }; -#if __cplusplus >= 201103L - static_assert(A<char>{1}.n < 0, ""); - static_assert(A<int>{1}.n < 0, ""); - static_assert(A<long long>{1}.n < 0, ""); -#endif -} - -// dr676: na - -namespace dr677 { // dr677: no - struct A { - void *operator new(std::size_t); - void operator delete(void*) = delete; // expected-error 0-1{{C++11}} expected-note {{deleted}} - }; - struct B { - void *operator new(std::size_t); - void operator delete(void*) = delete; // expected-error 0-1{{C++11}} expected-note 2{{deleted}} - virtual ~B(); - }; - void f(A *p) { delete p; } // expected-error {{deleted}} - // FIXME: This appears to be valid; we shouldn't even be looking up the 'operator delete' here. - void f(B *p) { delete p; } // expected-error {{deleted}} - B::~B() {} // expected-error {{deleted}} -} - -// dr678 FIXME: check that the modules ODR check catches this - -namespace dr679 { // dr679: yes - struct X {}; - template<int> void operator+(X, X); - template<> void operator+<0>(X, X) {} // expected-note {{previous}} - template<> void operator+<0>(X, X) {} // expected-error {{redefinition}} -} - -// dr680: na - -#if __cplusplus >= 201103L -namespace dr681 { // dr681: partial - auto *a() -> int; // expected-error {{must specify return type 'auto', not 'auto *'}} - auto (*b)() -> int; - // FIXME: The errors here aren't great. - auto (*c()) -> int; // expected-error {{expected function body}} - auto ((*d)()) -> int; // expected-error {{expected ';'}} expected-error {{requires an initializer}} - - // FIXME: This is definitely wrong. This should be - // "function of () returning pointer to function of () returning int" - // not a function with a deduced return type. - auto (*e())() -> int; // expected-error 0-1{{C++14}} - - auto f() -> int (*)(); - auto g() -> auto (*)() -> int; -} -#endif - -#if __cplusplus >= 201103L -namespace dr683 { // dr683: yes - struct A { - A() = default; - A(const A&) = default; - A(A&); - }; - static_assert(__is_trivially_constructible(A, const A&), ""); - static_assert(!__is_trivially_constructible(A, A&), ""); - static_assert(!__is_trivial(A), ""); - - struct B : A {}; - static_assert(__is_trivially_constructible(B, const B&), ""); - static_assert(__is_trivially_constructible(B, B&), ""); - static_assert(__is_trivial(B), ""); -} -#endif - -#if __cplusplus >= 201103L -namespace dr684 { // dr684: sup 1454 - void f() { - int a; // expected-note {{here}} - constexpr int *p = &a; // expected-error {{constant expression}} expected-note {{pointer to 'a'}} - } -} -#endif - -#if __cplusplus >= 201103L -namespace dr685 { // dr685: yes - enum E : long { e }; - void f(int); - int f(long); - int a = f(e); - - enum G : short { g }; - int h(short); - void h(long); - int b = h(g); - - int i(int); - void i(long); - int c = i(g); - - int j(unsigned int); // expected-note {{candidate}} - void j(long); // expected-note {{candidate}} - int d = j(g); // expected-error {{ambiguous}} - - int k(short); // expected-note {{candidate}} - void k(int); // expected-note {{candidate}} - int x = k(g); // expected-error {{ambiguous}} -} -#endif - -namespace dr686 { // dr686: yes - void f() { - (void)dynamic_cast<struct A*>(0); // expected-error {{incomplete}} expected-note {{forward}} - (void)dynamic_cast<struct A{}*>(0); // expected-error {{cannot be defined in a type specifier}} - (void)typeid(struct B*); - (void)typeid(struct B{}*); // expected-error {{cannot be defined in a type specifier}} - (void)static_cast<struct C*>(0); - (void)static_cast<struct C{}*>(0); // expected-error {{cannot be defined in a type specifier}} - (void)reinterpret_cast<struct D*>(0); - (void)reinterpret_cast<struct D{}*>(0); // expected-error {{cannot be defined in a type specifier}} - (void)const_cast<struct E*>(0); // expected-error {{not allowed}} - (void)const_cast<struct E{}*>(0); // expected-error {{cannot be defined in a type specifier}} - (void)sizeof(struct F*); - (void)sizeof(struct F{}*); // expected-error {{cannot be defined in a type specifier}} - (void)new struct G*; - (void)new struct G{}*; // expected-error {{cannot be defined in a type specifier}} -#if __cplusplus >= 201103L - (void)alignof(struct H*); - (void)alignof(struct H{}*); // expected-error {{cannot be defined in a type specifier}} -#endif - (void)(struct I*)0; - (void)(struct I{}*)0; // expected-error {{cannot be defined in a type specifier}} - if (struct J *p = 0) {} - if (struct J {} *p = 0) {} // expected-error {{cannot be defined in a condition}} - for (struct K *p = 0; struct L *q = 0; ) {} - for (struct K {} *p = 0; struct L {} *q = 0; ) {} // expected-error {{'L' cannot be defined in a condition}} -#if __cplusplus >= 201103L - using M = struct {}; -#endif - struct N { - operator struct O{}(){}; // expected-error {{cannot be defined in a type specifier}} - }; - try {} - catch (struct P *) {} // expected-error {{incomplete}} expected-note {{forward}} - catch (struct P {} *) {} // expected-error {{cannot be defined in a type specifier}} -#if __cplusplus < 201703L - void g() throw(struct Q); // expected-error {{incomplete}} expected-note {{forward}} - void h() throw(struct Q {}); // expected-error {{cannot be defined in a type specifier}} -#endif - } - template<struct R *> struct X; - template<struct R {} *> struct Y; // expected-error {{cannot be defined in a type specifier}} -} - -namespace dr687 { // dr687 still open - template<typename T> void f(T a) { - // FIXME: This is valid in C++20. - g<int>(a); // expected-error {{undeclared}} expected-error {{'('}} - - // This is not. - template g<int>(a); // expected-error {{expected expression}} - } -} - -namespace dr692 { // dr692: no - namespace temp_func_order_example2 { - template <typename T, typename U> struct A {}; - template <typename T, typename U> void f(U, A<U, T> *p = 0); // expected-note {{candidate}} - template <typename U> int &f(U, A<U, U> *p = 0); // expected-note {{candidate}} - template <typename T> void g(T, T = T()); - template <typename T, typename... U> void g(T, U...); // expected-error 0-1{{C++11}} - void h() { - int &r = f<int>(42, (A<int, int> *)0); - f<int>(42); // expected-error {{ambiguous}} - // FIXME: We should reject this due to ambiguity between the pack and the - // default argument. Only parameters with arguments are considered during - // partial ordering of function templates. - g(42); - } - } - - namespace temp_func_order_example3 { - template <typename T, typename... U> void f(T, U...); // expected-error 0-1{{C++11}} - template <typename T> void f(T); - template <typename T, typename... U> int &g(T *, U...); // expected-error 0-1{{C++11}} - template <typename T> void g(T); - void h(int i) { - // This is made ambiguous by dr692, but made valid again by dr1395. - f(&i); - int &r = g(&i); - } - } - - namespace temp_deduct_partial_example { - template <typename... Args> char &f(Args... args); // expected-error 0-1{{C++11}} - template <typename T1, typename... Args> short &f(T1 a1, Args... args); // expected-error 0-1{{C++11}} - template <typename T1, typename T2> int &f(T1 a1, T2 a2); - void g() { - char &a = f(); - short &b = f(1, 2, 3); - int &c = f(1, 2); - } - } - - namespace temp_deduct_type_example1 { - template <class T1, class ...Z> class S; // expected-error 0-1{{C++11}} - template <class T1, class ...Z> class S<T1, const Z&...>; // expected-error 0-1{{C++11}} - template <class T1, class T2> class S<T1, const T2&> {}; - S<int, const int&> s; - - // FIXME: This should select the first partial specialization. Deduction of - // the second from the first should succeed, because we should ignore the - // trailing pack in A with no corresponding P. - template<class T, class... U> struct A; // expected-error 0-1{{C++11}} - template<class T1, class T2, class... U> struct A<T1,T2*,U...>; // expected-note {{matches}} expected-error 0-1{{C++11}} - template<class T1, class T2> struct A<T1,T2> {}; // expected-note {{matches}} - template struct A<int, int*>; // expected-error {{ambiguous}} - } - - namespace temp_deduct_type_example3 { - // FIXME: This should select the first template, as in the case above. - template<class T, class... U> void f(T*, U...){} // expected-note {{candidate}} expected-error 0-1{{C++11}} - template<class T> void f(T){} // expected-note {{candidate}} - template void f(int*); // expected-error {{ambiguous}} - } -} diff --git a/test/CXX/drs/dr7xx.cpp b/test/CXX/drs/dr7xx.cpp deleted file mode 100644 index d02582b5b40c..000000000000 --- a/test/CXX/drs/dr7xx.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr727 { // dr727: partial - struct A { - template<typename T> struct C; // expected-note 6{{here}} - template<typename T> void f(); // expected-note {{here}} - template<typename T> static int N; // expected-error 0-1{{C++14}} expected-note 6{{here}} - - template<> struct C<int>; - template<> void f<int>(); - template<> static int N<int>; - - template<typename T> struct C<T*>; - template<typename T> static int N<T*>; - - struct B { - template<> struct C<float>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<> void f<float>(); // expected-error {{no function template matches}} - template<> static int N<float>; // expected-error {{not in class 'A' or an enclosing namespace}} - - template<typename T> struct C<T**>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<typename T> static int N<T**>; // expected-error {{not in class 'A' or an enclosing namespace}} - - template<> struct A::C<double>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<> void A::f<double>(); // expected-error {{no function template matches}} expected-error {{cannot have a qualified name}} - template<> static int A::N<double>; // expected-error {{not in class 'A' or an enclosing namespace}} expected-error {{cannot have a qualified name}} - - template<typename T> struct A::C<T***>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<typename T> static int A::N<T***>; // expected-error {{not in class 'A' or an enclosing namespace}} expected-error {{cannot have a qualified name}} - }; - }; - - template<> struct A::C<char>; - template<> void A::f<char>(); - template<> int A::N<char>; - - template<typename T> struct A::C<T****>; - template<typename T> int A::N<T****>; - - namespace C { - template<> struct A::C<long>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<> void A::f<long>(); // expected-error {{not in class 'A' or an enclosing namespace}} - template<> int A::N<long>; // expected-error {{not in class 'A' or an enclosing namespace}} - - template<typename T> struct A::C<T*****>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<typename T> int A::N<T*****>; // expected-error {{not in class 'A' or an enclosing namespace}} - } - - template<typename> - struct D { - template<typename T> struct C { typename T::error e; }; // expected-error {{no members}} - template<typename T> void f() { T::error; } // expected-error {{no members}} - template<typename T> static const int N = T::error; // expected-error 2{{no members}} expected-error 0-1{{C++14}} - - template<> struct C<int> {}; - template<> void f<int>() {} - template<> static const int N<int>; - - template<typename T> struct C<T*> {}; - template<typename T> static const int N<T*>; - }; - - void d(D<int> di) { - D<int>::C<int>(); - di.f<int>(); - int a = D<int>::N<int>; // FIXME: expected-note {{instantiation of}} - - D<int>::C<int*>(); - int b = D<int>::N<int*>; - - D<int>::C<float>(); // expected-note {{instantiation of}} - di.f<float>(); // expected-note {{instantiation of}} - int c = D<int>::N<float>; // expected-note {{instantiation of}} - } -} - -namespace dr777 { // dr777: 3.7 -#if __cplusplus >= 201103L -template <typename... T> -void f(int i = 0, T ...args) {} -void ff() { f(); } - -template <typename... T> -void g(int i = 0, T ...args, T ...args2) {} - -template <typename... T> -void h(int i = 0, T ...args, int j = 1) {} -#endif -} diff --git a/test/CXX/drs/dr9xx.cpp b/test/CXX/drs/dr9xx.cpp deleted file mode 100644 index b37e17d6b098..000000000000 --- a/test/CXX/drs/dr9xx.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-no-diagnostics -#endif - -namespace std { - __extension__ typedef __SIZE_TYPE__ size_t; - - template<typename T> struct initializer_list { - const T *p; size_t n; - initializer_list(const T *p, size_t n); - }; -} - -namespace dr990 { // dr990: 3.5 -#if __cplusplus >= 201103L - struct A { // expected-note 2{{candidate}} - A(std::initializer_list<int>); // expected-note {{candidate}} - }; - struct B { - A a; - }; - B b1 { }; - B b2 { 1 }; // expected-error {{no viable conversion from 'int' to 'dr990::A'}} - B b3 { { 1 } }; - - struct C { - C(); - C(int); - C(std::initializer_list<int>) = delete; // expected-note {{here}} - }; - C c1[3] { 1 }; // ok - C c2[3] { 1, {2} }; // expected-error {{call to deleted}} - - struct D { - D(); - D(std::initializer_list<int>); - D(std::initializer_list<double>); - }; - D d{}; -#endif -} - -namespace dr948 { // dr948: 3.7 -#if __cplusplus >= 201103L - class A { - public: - constexpr A(int v) : v(v) { } - constexpr operator int() const { return v; } - private: - int v; - }; - - constexpr int id(int x) - { - return x; - } - - void f() { - if (constexpr int i = id(101)) { } - switch (constexpr int i = id(2)) { default: break; case 2: break; } - for (; constexpr int i = id(0); ) { } - while (constexpr int i = id(0)) { } - - if (constexpr A i = 101) { } - switch (constexpr A i = 2) { default: break; case 2: break; } - for (; constexpr A i = 0; ) { } - while (constexpr A i = 0) { } - } -#endif -} |