1 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 namespace dr1611 { // dr1611: dup 1658
8 struct B : virtual A { virtual void f() = 0; };
9 struct C : B { C() : A(0) {} void f(); };
13 namespace dr1684 { // dr1684: 3.6
14 #if __cplusplus >= 201103L
15 struct NonLiteral { // expected-note {{because}}
17 constexpr int f() { return 0; } // expected-warning 0-1{{will not be implicitly 'const'}}
19 constexpr int f(NonLiteral &) { return 0; }
20 constexpr int f(NonLiteral) { return 0; } // expected-error {{not a literal type}}
24 namespace dr1631 { // dr1631: 3.7
25 #if __cplusplus >= 201103L
26 // Incorrect overload resolution for single-element initializer-list
28 struct A { int a[1]; };
31 void f(B, int, int = 0);
35 f({0}, {{1}}); // expected-warning {{braces around scalar init}}
38 namespace with_error {
39 void f(B, int); // TODO: expected- note {{candidate function}}
40 void f(int, A); // expected-note {{candidate function}}
41 void f(int, A, int = 0); // expected-note {{candidate function}}
44 f({0}, {{1}}); // expected-error{{call to 'f' is ambiguous}}
50 namespace dr1638 { // dr1638: yes
51 #if __cplusplus >= 201103L
52 template<typename T> struct A {
53 enum class E; // expected-note {{previous}}
54 enum class F : T; // expected-note 2{{previous}}
57 template<> enum class A<int>::E;
58 template<> enum class A<int>::E {};
59 template<> enum class A<int>::F : int;
60 template<> enum class A<int>::F : int {};
62 template<> enum class A<short>::E : int;
63 template<> enum class A<short>::E : int {};
65 template<> enum class A<short>::F; // expected-error {{different underlying type}}
66 template<> enum class A<char>::E : char; // expected-error {{different underlying type}}
67 template<> enum class A<char>::F : int; // expected-error {{different underlying type}}
69 enum class A<unsigned>::E; // expected-error {{template specialization requires 'template<>'}} expected-error {{nested name specifier}}
70 template enum class A<unsigned>::E; // expected-error {{enumerations cannot be explicitly instantiated}}
71 enum class A<unsigned>::E *e; // expected-error {{must use 'enum' not 'enum class'}}
74 friend enum class A<unsigned>::E; // expected-error {{must use 'enum' not 'enum class'}}
79 namespace dr1645 { // dr1645: 3.9
80 #if __cplusplus >= 201103L
82 constexpr A(int, float = 0); // expected-note 2{{candidate}}
83 explicit A(int, int = 0); // expected-note 2{{candidate}}
84 A(int, int, int = 0) = delete; // expected-note {{candidate}}
87 struct B : A { // expected-note 2{{candidate}}
88 using A::A; // expected-note 5{{inherited here}}
91 constexpr B a(0); // expected-error {{ambiguous}}
92 constexpr B b(0, 0); // expected-error {{ambiguous}}
96 namespace dr1653 { // dr1653: 4 c++17
100 #if __cplusplus <= 201402L
101 // expected-warning@-3 {{deprecated}} expected-warning@-2 {{deprecated}}
103 // expected-error@-5 {{incrementing expression of type bool}} expected-error@-4 {{incrementing expression of type bool}}
105 --b; // expected-error {{cannot decrement expression of type bool}}
106 b--; // expected-error {{cannot decrement expression of type bool}}
112 namespace dr1658 { // dr1658: 5
114 class A { A(); }; // expected-note 0-2{{here}}
115 class B { ~B(); }; // expected-note 0-2{{here}}
117 // The stars align! An abstract class does not construct its virtual bases.
118 struct C : virtual A { C(); virtual void foo() = 0; };
119 C::C() = default; // ok, not deleted, expected-error 0-1{{extension}}
120 struct D : virtual B { D(); virtual void foo() = 0; };
121 D::D() = default; // ok, not deleted, expected-error 0-1{{extension}}
123 // In all other cases, we are not so lucky.
124 struct E : A { E(); virtual void foo() = 0; };
125 #if __cplusplus < 201103L
126 E::E() = default; // expected-error {{private default constructor}} expected-error {{extension}} expected-note {{here}}
128 E::E() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible default constructor}}
130 struct F : virtual A { F(); };
131 #if __cplusplus < 201103L
132 F::F() = default; // expected-error {{private default constructor}} expected-error {{extension}} expected-note {{here}}
134 F::F() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible default constructor}}
137 struct G : B { G(); virtual void foo() = 0; };
138 #if __cplusplus < 201103L
139 G::G() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}}
141 G::G() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}}
143 struct H : virtual B { H(); };
144 #if __cplusplus < 201103L
145 H::H() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}}
147 H::H() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}}
152 class B { ~B(); }; // expected-note 0-2{{here}}
154 struct D : virtual B { ~D(); virtual void foo() = 0; };
155 D::~D() = default; // ok, not deleted, expected-error 0-1{{extension}}
157 struct G : B { ~G(); virtual void foo() = 0; };
158 #if __cplusplus < 201103L
159 G::~G() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}}
161 G::~G() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}}
163 struct H : virtual B { ~H(); };
164 #if __cplusplus < 201103L
165 H::~H() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}}
167 H::~H() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}}
172 struct A { A(int); }; // expected-note {{here}}
173 struct B : virtual A {
175 virtual void f() = 0;
177 struct C : virtual A {
178 C() {} // expected-error {{must explicitly initialize}}
182 namespace CopyCtorParamType {
184 struct B : virtual A { virtual void f() = 0; };
185 struct C : virtual A { virtual void f(); };
186 struct D : A { virtual void f() = 0; };
189 friend B::B(const B&) throw();
196 class A { A(const A&); A(A&&); }; // expected-note 0-4{{here}} expected-error 0-1{{extension}}
198 struct C : virtual A { C(const C&); C(C&&); virtual void foo() = 0; }; // expected-error 0-1{{extension}}
199 C::C(const C&) = default; // expected-error 0-1{{extension}}
200 C::C(C&&) = default; // expected-error 0-2{{extension}}
202 struct E : A { E(const E&); E(E&&); virtual void foo() = 0; }; // expected-error 0-1{{extension}}
203 #if __cplusplus < 201103L
204 E::E(const E&) = default; // expected-error {{private copy constructor}} expected-error {{extension}} expected-note {{here}}
205 E::E(E&&) = default; // expected-error {{private move constructor}} expected-error 2{{extension}} expected-note {{here}}
207 E::E(const E&) = default; // expected-error {{would delete}} expected-note@-5{{inaccessible copy constructor}}
208 E::E(E&&) = default; // expected-error {{would delete}} expected-note@-6{{inaccessible move constructor}}
210 struct F : virtual A { F(const F&); F(F&&); }; // expected-error 0-1{{extension}}
211 #if __cplusplus < 201103L
212 F::F(const F&) = default; // expected-error {{private copy constructor}} expected-error {{extension}} expected-note {{here}}
213 F::F(F&&) = default; // expected-error {{private move constructor}} expected-error 2{{extension}} expected-note {{here}}
215 F::F(const F&) = default; // expected-error {{would delete}} expected-note@-5{{inaccessible copy constructor}}
216 F::F(F&&) = default; // expected-error {{would delete}} expected-note@-6{{inaccessible move constructor}}
220 // assignment case is superseded by dr2180