1
- // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
2
- // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
3
- // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
4
- // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
5
- // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
6
- // RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
7
-
8
- # if __cplusplus < 201103L
9
- // expected-error@+1 {{variadic macro}}
1
+ // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
2
+ // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
3
+ // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
4
+ // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
5
+ // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
6
+ // RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
7
+ // RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
8
+
9
+ # if __cplusplus == 199711L
10
10
#define static_assert (...) __extension__ _Static_assert (__VA_ARGS__)
11
+ // cxx98-error@-1 {{variadic macros are a C99 feature}}
11
12
#endif
12
13
13
14
namespace dr2100 { // dr2100: 12
@@ -18,15 +19,14 @@ namespace dr2100 { // dr2100: 12
18
19
return X<&n>::n; // ok, value-dependent
19
20
}
20
21
int g () {
21
- static const int n = 2 ;
22
+ static const int n = 2 ; // #dr2100-n
22
23
return X<&n>::n; // ok, value-dependent
23
- #if __cplusplus < 201702L
24
- // expected-error@-2 {{does not have linkage}} expected-note@-3 {{here}}
25
- #endif
24
+ // cxx98-14-error@-1 {{non-type template argument refers to object 'n' that does not have linkage}}
25
+ // cxx98-14-note@#dr2100-n {{non-type template argument refers to object here}}
26
26
}
27
27
};
28
28
template <const int *P> struct X <P> {
29
- #if __cplusplus < 201103L
29
+ #if __cplusplus == 199711L
30
30
static const int n = 0 ;
31
31
#else
32
32
static const int n = *P;
@@ -40,11 +40,13 @@ namespace dr2100 { // dr2100: 12
40
40
template <typename T> struct B {
41
41
static const int n = 1 ;
42
42
int f () {
43
- return Y<n>::declared_later; // expected-error {{no member named 'declared_later'}}
43
+ return Y<n>::declared_later;
44
+ // expected-error@-1 {{no member named 'declared_later' in 'dr2100::Y<1>'}}
44
45
}
45
46
int g () {
46
47
static const int n = 2 ;
47
- return Y<n>::declared_later; // expected-error {{no member named 'declared_later'}}
48
+ return Y<n>::declared_later;
49
+ // expected-error@-1 {{no member named 'declared_later' in 'dr2100::Y<2>'}}
48
50
}
49
51
};
50
52
template <int N> struct Y <N> {
@@ -55,10 +57,12 @@ namespace dr2100 { // dr2100: 12
55
57
namespace dr2103 { // dr2103: yes
56
58
void f () {
57
59
int a;
58
- int &r = a; // expected-note {{here}}
60
+ int &r = a; // #dr2103-r
59
61
struct Inner {
60
62
void f () {
61
- int &s = r; // expected-error {{enclosing function}}
63
+ int &s = r;
64
+ // expected-error@-1 {{reference to local variable 'r' declared in enclosing function 'dr2103::f'}}
65
+ // expected-note@#dr2103-r {{'r' declared here}}
62
66
(void )s;
63
67
}
64
68
};
@@ -84,28 +88,46 @@ namespace dr2126 { // dr2126: 12
84
88
A &b = (A &)(const A &)A{1 }; // const temporary
85
89
A &&c = (A &&)(const A &)A{1 }; // const temporary
86
90
87
- A &&d = {1 }; // non-const temporary expected-note {{here}}
88
- const A &e = (A &)(A &&) A{1 }; // non-const temporary expected-note {{here}}
89
- A &&f = (A &&)(A &&) A{1 }; // non-const temporary expected-note {{here}}
91
+ A &&d = {1 }; // non-const temporary #dr21260-d
92
+ const A &e = (A &)(A &&) A{1 }; // non-const temporary #dr21260-e
93
+ A &&f = (A &&)(A &&) A{1 }; // non-const temporary #dr21260-f
90
94
91
95
constexpr const A &g = {1 }; // const temporary
92
- constexpr A &&h = {1 }; // non-const temporary expected-note {{here}}
96
+ constexpr A &&h = {1 }; // non-const temporary #dr21260-h
93
97
94
98
struct B { const A &a; };
95
- B i = {{1 }}; // extending decl not usable in constant expr expected-note {{here}}
96
- const B j = {{1 }}; // extending decl not usable in constant expr expected-note {{here}}
99
+ B i = {{1 }}; // extending decl not usable in constant expr #dr21260-i
100
+ const B j = {{1 }}; // extending decl not usable in constant expr #dr21260-j
97
101
constexpr B k = {{1 }}; // extending decl usable in constant expr
98
102
99
103
static_assert (a.n == 1 , " " );
100
104
static_assert (b.n == 1 , " " );
101
105
static_assert (c.n == 1 , " " );
102
- static_assert (d.n == 1 , " " ); // expected-error {{constant}} expected-note {{read of temporary}}
103
- static_assert (e.n == 1 , " " ); // expected-error {{constant}} expected-note {{read of temporary}}
104
- static_assert (f.n == 1 , " " ); // expected-error {{constant}} expected-note {{read of temporary}}
106
+ static_assert (d.n == 1 , " " );
107
+ // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
108
+ // since-cxx11-note@-2 {{read of temporary is not allowed in a constant expression outside the expression that created the temporary}}
109
+ // since-cxx11-note@#dr21260-d {{temporary created here}}
110
+ static_assert (e.n == 1 , " " );
111
+ // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
112
+ // since-cxx11-note@-2 {{read of temporary is not allowed in a constant expression outside the expression that created the temporary}}
113
+ // since-cxx11-note@#dr21260-e {{temporary created here}}
114
+ static_assert (f.n == 1 , " " );
115
+ // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
116
+ // since-cxx11-note@-2 {{read of temporary is not allowed in a constant expression outside the expression that created the temporary}}
117
+ // since-cxx11-note@#dr21260-f {{temporary created here}}
105
118
static_assert (g.n == 1 , " " );
106
- static_assert (h.n == 1 , " " ); // expected-error {{constant}} expected-note {{read of temporary}}
107
- static_assert (i.a.n == 1 , " " ); // expected-error {{constant}} expected-note {{read of non-constexpr variable}}
108
- static_assert (j.a.n == 1 , " " ); // expected-error {{constant}} expected-note {{read of temporary}}
119
+ static_assert (h.n == 1 , " " );
120
+ // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
121
+ // since-cxx11-note@-2 {{read of temporary is not allowed in a constant expression outside the expression that created the temporary}}
122
+ // since-cxx11-note@#dr21260-h {{temporary created here}}
123
+ static_assert (i.a.n == 1 , " " );
124
+ // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
125
+ // since-cxx11-note@-2 {{read of non-constexpr variable 'i' is not allowed in a constant expression}}
126
+ // since-cxx11-note@#dr21260-i {{declared here}}
127
+ static_assert (j.a.n == 1 , " " );
128
+ // since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
129
+ // since-cxx11-note@-2 {{read of temporary is not allowed in a constant expression outside the expression that created the temporary}}
130
+ // since-cxx11-note@#dr21260-j {{temporary created here}}
109
131
static_assert (k.a.n == 1 , " " );
110
132
#endif
111
133
}
@@ -128,19 +150,27 @@ struct B{};
128
150
129
151
void foo () {
130
152
struct A *b = (1 == 1 ) ? new struct A : new struct A ;
131
- struct S *a = (1 == 1 ) ? new struct S : new struct S ; // expected-error 2{{allocation of incomplete type}} // expected-note 2{{forward}}
153
+ struct S *a = (1 == 1 ) ? new struct S : new struct S ;
154
+ // expected-error@-1 {{allocation of incomplete type 'struct S'}}
155
+ // expected-note@-2 {{forward declaration of 'S'}}
156
+ // expected-error@-3 {{allocation of incomplete type 'struct S'}}
157
+ // expected-note@-4 {{forward declaration of 'S'}}
132
158
133
159
#if __cplusplus >= 201103L
134
160
A *aa = new struct A {};
135
161
B<int > *bb = new struct B <int >{};
136
- (void )new struct C {}; // expected-error {{allocation of incomplete type }} // expected-note {{forward}}
162
+ (void )new struct C {};
163
+ // since-cxx11-error@-1 {{allocation of incomplete type 'struct C'}}
164
+ // since-cxx11-note@-2 {{forward declaration of 'C'}}
137
165
138
166
struct A *c = (1 == 1 ) ? new struct A {} : new struct A {};
139
167
140
- alignof (struct D {}); // expected-error {{cannot be defined in a type specifier}}
168
+ alignof (struct D {});
169
+ // since-cxx11-error@-1 {{'D' cannot be defined in a type specifier}}
141
170
#endif
142
171
143
- sizeof (struct E {}); // expected-error {{cannot be defined in a type specifier}}
172
+ sizeof (struct E {});
173
+ // expected-error@-1 {{'E' cannot be defined in a type specifier}}
144
174
145
175
}
146
176
}
@@ -149,7 +179,8 @@ namespace dr2157 { // dr2157: 11
149
179
#if __cplusplus >= 201103L
150
180
enum E : int ;
151
181
struct X {
152
- enum dr2157::E : int (); // expected-error {{only allows ':' in member enumeration declaration to introduce a fixed underlying type}}
182
+ enum dr2157::E : int ();
183
+ // since-cxx11-error@-1 {{ISO C++ only allows ':' in member enumeration declaration to introduce a fixed underlying type, not an anonymous bit-field}}
153
184
};
154
185
#endif
155
186
}
@@ -159,11 +190,13 @@ namespace dr2157 { // dr2157: 11
159
190
namespace dr2170 { // dr2170: 9
160
191
#if __cplusplus >= 201103L
161
192
void f () {
162
- constexpr int arr[3 ] = {1 , 2 , 3 }; // expected-note {{here}}
193
+ constexpr int arr[3 ] = {1 , 2 , 3 }; // #dr2170-arr
163
194
struct S {
164
195
int get (int n) { return arr[n]; }
165
- const int &get_ref (int n) { return arr[n]; } // expected-error {{enclosing function}}
166
- // FIXME: expected-warning@-1 {{reference to stack}}
196
+ const int &get_ref (int n) { return arr[n]; }
197
+ // since-cxx11-warning@-1 {{reference to stack memory associated with local variable 'arr' returned}} FIXME
198
+ // since-cxx11-error@-2 {{reference to local variable 'arr' declared in enclosing function 'dr2170::f'}}
199
+ // since-cxx11-note@#dr2170-arr {{'arr' declared here}}
167
200
};
168
201
}
169
202
#endif
@@ -198,22 +231,32 @@ static_assert(!__is_trivially_assignable(NonConstCopy &&, NonConstCopy &&), "");
198
231
199
232
namespace dr2180 { // dr2180: yes
200
233
class A {
201
- A &operator =(const A &); // expected-note 0-2{{here}}
202
- A &operator =(A &&); // expected-note 0-2{{here}} expected-error 0-1{{extension}}
234
+ A &operator =(const A &); // #dr2180-A-copy
235
+ A &operator =(A &&); // #dr2180-A-move
236
+ // cxx98-error@-1 {{rvalue references are a C++11 extension}}
203
237
};
204
238
205
- struct B : virtual A {
239
+ struct B : virtual A { // #dr2180-B
206
240
B &operator =(const B &);
207
- B &operator =(B &&); // expected-error 0-1{{extension}}
241
+ B &operator =(B &&);
242
+ // cxx98-error@-1 {{rvalue references are a C++11 extension}}
208
243
virtual void foo () = 0;
209
244
};
210
- #if __cplusplus < 201103L
211
- B &B::operator =(const B&) = default ; // expected-error {{private member}} expected-error {{extension}} expected-note {{here}}
212
- B &B::operator =(B&&) = default ; // expected-error {{private member}} expected-error 2{{extension}} expected-note {{here}}
213
- #else
214
- B &B::operator =(const B&) = default ; // expected-error {{would delete}} expected-note@-9{{inaccessible copy assignment}}
215
- B &B::operator =(B&&) = default ; // expected-error {{would delete}} expected-note@-10{{inaccessible move assignment}}
216
- #endif
245
+ B &B::operator =(const B&) = default ; // #dr2180-B-copy
246
+ // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
247
+ // cxx98-error@-2 {{'operator=' is a private member of 'dr2180::A'}}
248
+ // cxx98-note@-3 {{in defaulted copy assignment operator for 'dr2180::B' first required here}}
249
+ // cxx98-note@#dr2180-A-copy {{implicitly declared private here}}
250
+ // since-cxx11-error@#dr2180-B-copy {{defaulting this copy assignment operator would delete it after its first declaration}}
251
+ // since-cxx11-note@#dr2180-B {{copy assignment operator of 'B' is implicitly deleted because base class 'A' has an inaccessible copy assignment operator}}
252
+ B &B::operator =(B&&) = default ; // #dr2180-B-move
253
+ // cxx98-error@-1 {{rvalue references are a C++11 extension}}
254
+ // cxx98-error@-2 {{defaulted function definitions are a C++11 extension}}
255
+ // cxx98-error@-3 {{'operator=' is a private member of 'dr2180::A'}}
256
+ // cxx98-note@-4 {{in defaulted move assignment operator for 'dr2180::B' first required here}}
257
+ // cxx98-note@#dr2180-A-move {{implicitly declared private here}}
258
+ // since-cxx11-error@#dr2180-B-move {{defaulting this move assignment operator would delete it after its first declaration}}
259
+ // since-cxx11-note@#dr2180-B {{move assignment operator of 'B' is implicitly deleted because base class 'A' has an inaccessible move assignment operator}}
217
260
}
218
261
219
262
namespace dr2199 { // dr2199: 3.8
0 commit comments