1 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 namespace std
{ struct type_info
; }
8 namespace dr1902
{ // dr1902: 3.7
12 #if __cplusplus >= 201103L
13 // expected-note@-2 {{candidate}}
17 #if __cplusplus < 201103L
18 // expected-error@-2 {{extension}}
21 B(const B
&) // expected-note {{deleted here}}
22 #if __cplusplus >= 201103L
23 // expected-note@-2 {{candidate}}
25 // expected-error@+2 {{extension}}
33 B
b2(b1
); // expected-error {{call to deleted}}
35 #if __cplusplus >= 201103L
36 // This is ambiguous, even though calling the B(const B&) constructor would
37 // both directly and indirectly call a deleted function.
38 B
b({}); // expected-error {{ambiguous}}
67 namespace dr1909
{ // dr1909: yes
69 template<typename T
> struct A
{}; // expected-error {{member 'A' has the same name as its class}}
72 template<typename T
> void B() {} // expected-error {{constructor cannot have a return type}}
75 template<typename T
> static int C
; // expected-error {{member 'C' has the same name as its class}} expected-error 0-1{{extension}}
78 template<typename T
> using D
= int; // expected-error {{member 'D' has the same name as its class}} expected-error 0-1{{extension}}
82 namespace dr1940
{ // dr1940: yes
83 #if __cplusplus >= 201103L
85 static_assert(true, ""); // ok
86 static_assert(false, ""); // expected-error {{static assertion failed}}
92 namespace dr1941
{ // dr1941: 3.9
93 #if __cplusplus >= 201402L
97 base(T a
, T b
, decltype(void(*T()), 0) = 0) {
98 while (a
!= b
) (void)*a
++;
102 base(T a
, X x
, decltype(void(T(0) * 1), 0) = 0) {
103 for (T n
= 0; n
!= a
; ++n
) (void)X(x
);
107 struct derived
: base
<int> {
112 iter
operator++(int);
114 friend bool operator!=(iter
, iter
);
122 namespace dr1947
{ // dr1947: yes
123 #if __cplusplus >= 201402L
124 unsigned o
= 0'01; // ok
125 unsigned b
= 0b'01; // expected-error {{invalid digit 'b' in octal constant}}
126 unsigned x
= 0x'01; // expected-error {{invalid suffix 'x'01' on integer constant}}
130 #if __cplusplus >= 201103L
132 // FIXME: This diagnostic could be improved.
133 void *operator new(__SIZE_TYPE__
) noexcept
{ return nullptr; } // expected-error{{exception specification in declaration does not match previous declaration}}
136 namespace dr1959
{ // dr1959: 3.9
137 #if __cplusplus >= 201103L
142 a(const a
&) = delete; // expected-note {{deleted}}
143 a(const b
&) = delete; // not inherited
144 a(c
&&) = delete; // expected-note {{not viable}}
145 template<typename T
> a(T
) = delete; // expected-note {{would take its own class type by value}}
148 struct b
: a
{ // expected-note {{cannot bind}} expected-note {{deleted because}}
149 using a::a
; // expected-note 2{{inherited here}}
153 // FIXME: As a resolution to an open DR against P0136R0, we disallow
154 // use of inherited constructors to construct from a single argument
155 // where the base class is reference-related to the argument type.
156 b y
= x
; // expected-error {{no viable conversion}}
157 b z
= z
; // expected-error {{deleted}}
163 // FIXME: As a resolution to an open DR against P0136R0, we disallow
164 // use of inherited constructors to construct from a single argument
165 // where the base class is reference-related to the argument type.
166 c
q(static_cast<c
&&>(q
));
170 namespace dr1960
{ // dr1960: no
184 // FIXME: both declarations are ill-formed, because A::f and A::g
185 // are not accessible.
191 namespace dr1966
{ // dr1966: 11
192 #if __cplusplus >= 201103L
194 enum E
: int {1}; // expected-error {{expected identifier}} (not bit-field)
196 auto *p1
= new enum E
: int; // expected-error {{only permitted as a standalone declaration}}
197 auto *p2
= new enum F
: int {}; // expected-error {{only permitted as a standalone declaration}}
198 auto *p3
= true ? new enum G
: int {}; // expected-error {{forward reference}} expected-error {{incomplete}} expected-note {{declaration}}
199 auto h() -> enum E
: int {}; // expected-error {{only permitted as a standalone declaration}}
201 enum X
: enum Y
: int {} {}; // expected-error {{cannot be defined in a type specifier}}
203 enum X
: enum Y
: int {} {}; // expected-error +{{}}
208 namespace dr1968
{ // dr1968: no
209 #if __cplusplus >= 201103L
210 // FIXME: According to DR1968, both of these should be considered
212 static_assert(&typeid(int) == &typeid(int), "");
214 constexpr const std::type_info
*f() { return &typeid(int); }
215 static_assert(f() == f(), "");
219 namespace dr1991
{ // dr1991: 3.9
220 #if __cplusplus >= 201103L
222 A(int, int) = delete;
227 B(int, int, int = 0);
230 // FIXME: As a resolution to an open DR against P0136R1, we treat derived
231 // class constructors as better than base class constructors in the presence
233 B
b(0, 0); // ok, calls B constructor