Skip to content

Commit eff1265

Browse files
committed
[clang][NFC] Fix expected directives in C++ DRs
If directive is put inside `#if __cplusplus`, it should reflect the condition, instead of being generic `expected`.
1 parent 2a593bb commit eff1265

File tree

15 files changed

+166
-172
lines changed

15 files changed

+166
-172
lines changed

clang/test/CXX/drs/cwg0xx.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,11 @@ namespace cwg39 { // cwg39: no
709709
// expected-error@#cwg39-sizeof {{unknown type name}}
710710
#if __cplusplus >= 201103L
711711
decltype(D::n) n;
712-
/* expected-error@-1
712+
/* since-cxx11-error@-1
713713
{{non-static member 'n' found in multiple base-class subobjects of type 'A':
714714
struct cwg39::PR5916::D -> B -> A
715715
struct cwg39::PR5916::D -> C -> A}} */
716-
// expected-note@#cwg39-A-n {{member found by ambiguous name lookup}}
716+
// since-cxx11-note@#cwg39-A-n {{member found by ambiguous name lookup}}
717717
#endif
718718
}
719719
} // namespace cwg39
@@ -1150,8 +1150,8 @@ namespace cwg73 { // cwg73: sup 1652
11501150
#if __cplusplus >= 201103L
11511151
int a, b;
11521152
static_assert(&a + 1 != &b, "");
1153-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
1154-
// expected-note@-2 {{comparison against pointer '&a + 1' that points past the end of a complete object has unspecified value}}
1153+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
1154+
// since-cxx11-note@-2 {{comparison against pointer '&a + 1' that points past the end of a complete object has unspecified value}}
11551155
#endif
11561156
} // namespace cwg73
11571157

@@ -1255,14 +1255,14 @@ namespace cwg85 { // cwg85: 3.4
12551255
enum E1 : int;
12561256
enum E1 : int { e1 }; // #cwg85-E1-def
12571257
enum E1 : int;
1258-
// expected-error@-1 {{class member cannot be redeclared}}
1259-
// expected-note@#cwg85-E1-def {{previous declaration is here}}
1258+
// since-cxx11-error@-1 {{class member cannot be redeclared}}
1259+
// since-cxx11-note@#cwg85-E1-def {{previous declaration is here}}
12601260

12611261
enum class E2;
12621262
enum class E2 { e2 }; // #cwg85-E2-def
12631263
enum class E2;
1264-
// expected-error@-1 {{class member cannot be redeclared}}
1265-
// expected-note@#cwg85-E2-def {{previous declaration is here}}
1264+
// since-cxx11-error@-1 {{class member cannot be redeclared}}
1265+
// since-cxx11-note@#cwg85-E2-def {{previous declaration is here}}
12661266
#endif
12671267
};
12681268

clang/test/CXX/drs/cwg14xx.cpp

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ struct A;
9393
void f() {
9494
constexpr A* a = nullptr;
9595
constexpr int p = &*a;
96-
// expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}}
96+
// since-cxx11-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}}
9797
constexpr A *p2 = &*a;
9898
}
9999

@@ -108,27 +108,27 @@ namespace cwg1460 { // cwg1460: 3.5
108108
namespace DRExample {
109109
union A {
110110
union {};
111-
// expected-error@-1 {{declaration does not declare anything}}
111+
// since-cxx11-error@-1 {{declaration does not declare anything}}
112112
union {};
113-
// expected-error@-1 {{declaration does not declare anything}}
113+
// since-cxx11-error@-1 {{declaration does not declare anything}}
114114
constexpr A() {}
115115
};
116116
constexpr A a = A();
117117

118118
union B {
119119
union {};
120-
// expected-error@-1 {{declaration does not declare anything}}
120+
// since-cxx11-error@-1 {{declaration does not declare anything}}
121121
union {};
122-
// expected-error@-1 {{declaration does not declare anything}}
122+
// since-cxx11-error@-1 {{declaration does not declare anything}}
123123
constexpr B() = default;
124124
};
125125
constexpr B b = B();
126126

127127
union C {
128128
union {};
129-
// expected-error@-1 {{declaration does not declare anything}}
129+
// since-cxx11-error@-1 {{declaration does not declare anything}}
130130
union {};
131-
// expected-error@-1 {{declaration does not declare anything}}
131+
// since-cxx11-error@-1 {{declaration does not declare anything}}
132132
};
133133
constexpr C c = C();
134134
#if __cplusplus >= 201403L
@@ -141,7 +141,7 @@ namespace cwg1460 { // cwg1460: 3.5
141141
union B { int n; }; // #cwg1460-B
142142
union C { int n = 0; };
143143
struct D { union {}; };
144-
// expected-error@-1 {{declaration does not declare anything}}
144+
// since-cxx11-error@-1 {{declaration does not declare anything}}
145145
struct E { union { int n; }; }; // #cwg1460-E
146146
struct F { union { int n = 0; }; };
147147

@@ -173,7 +173,7 @@ namespace cwg1460 { // cwg1460: 3.5
173173
// cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}}
174174
union C { int n = 0; constexpr C() = default; };
175175
struct D { union {}; constexpr D() = default; };
176-
// expected-error@-1 {{declaration does not declare anything}}
176+
// since-cxx11-error@-1 {{declaration does not declare anything}}
177177
struct E { union { int n; }; constexpr E() = default; };
178178
// cxx11-17-error@-1 {{defaulted definition of default constructor cannot be marked constexpr}}
179179
struct F { union { int n = 0; }; constexpr F() = default; };
@@ -222,25 +222,25 @@ namespace cwg1460 { // cwg1460: 3.5
222222
union G {
223223
int a = 0; // #cwg1460-G-a
224224
int b = 0;
225-
// expected-error@-1 {{initializing multiple members of union}}
226-
// expected-note@#cwg1460-G-a {{previous initialization is here}}
225+
// since-cxx11-error@-1 {{initializing multiple members of union}}
226+
// since-cxx11-note@#cwg1460-G-a {{previous initialization is here}}
227227
};
228228
union H {
229229
union {
230230
int a = 0; // #cwg1460-H-a
231231
};
232232
union {
233233
int b = 0;
234-
// expected-error@-1 {{initializing multiple members of union}}
235-
// expected-note@#cwg1460-H-a {{previous initialization is here}}
234+
// since-cxx11-error@-1 {{initializing multiple members of union}}
235+
// since-cxx11-note@#cwg1460-H-a {{previous initialization is here}}
236236
};
237237
};
238238
struct I {
239239
union {
240240
int a = 0; // #cwg1460-I-a
241241
int b = 0;
242-
// expected-error@-1 {{initializing multiple members of union}}
243-
// expected-note@#cwg1460-I-a {{previous initialization is here}}
242+
// since-cxx11-error@-1 {{initializing multiple members of union}}
243+
// since-cxx11-note@#cwg1460-I-a {{previous initialization is here}}
244244
};
245245
};
246246
struct J {
@@ -264,23 +264,23 @@ namespace cwg1460 { // cwg1460: 3.5
264264
};
265265
static_assert(B().a == 1, "");
266266
static_assert(B().b == 2, "");
267-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
268-
// expected-note@-2 {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}}
267+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
268+
// since-cxx11-note@-2 {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}}
269269
static_assert(B('x').a == 0, "");
270-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
271-
// expected-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}}
270+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
271+
// since-cxx11-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}}
272272
static_assert(B('x').b == 4, "");
273273
static_assert(B(123).b == 2, "");
274-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
275-
// expected-note@-2 {{read of member 'b' of union with active member 'c' is not allowed in a constant expression}}
274+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
275+
// since-cxx11-note@-2 {{read of member 'b' of union with active member 'c' is not allowed in a constant expression}}
276276
static_assert(B(123).c == 3, "");
277277
static_assert(B("").a == 1, "");
278-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
279-
// expected-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}}
278+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
279+
// since-cxx11-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}}
280280
static_assert(B("").b == 2, "");
281281
static_assert(B("").c == 3, "");
282-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
283-
// expected-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
282+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
283+
// since-cxx11-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
284284

285285
struct C {
286286
union { int a, b = 2, c; };
@@ -294,54 +294,54 @@ namespace cwg1460 { // cwg1460: 3.5
294294

295295
static_assert(C().a == 1, "");
296296
static_assert(C().b == 2, "");
297-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
298-
// expected-note@-2 {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}}
297+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
298+
// since-cxx11-note@-2 {{read of member 'b' of union with active member 'a' is not allowed in a constant expression}}
299299
static_assert(C().d == 4, "");
300-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
301-
// expected-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}}
300+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
301+
// since-cxx11-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}}
302302
static_assert(C().e == 5, "");
303303

304304
static_assert(C('x').b == 2, "");
305-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
306-
// expected-note@-2 {{read of member 'b' of union with active member 'c' is not allowed in a constant expression}}
305+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
306+
// since-cxx11-note@-2 {{read of member 'b' of union with active member 'c' is not allowed in a constant expression}}
307307
static_assert(C('x').c == 3, "");
308308
static_assert(C('x').d == 4, "");
309-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
310-
// expected-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}}
309+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
310+
// since-cxx11-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}}
311311
static_assert(C('x').e == 5, "");
312312

313313
static_assert(C(1).b == 2, "");
314314
static_assert(C(1).c == 3, "");
315-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
316-
// expected-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
315+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
316+
// since-cxx11-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
317317
static_assert(C(1).d == 4, "");
318318
static_assert(C(1).e == 5, "");
319-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
320-
// expected-note@-2 {{read of member 'e' of union with active member 'd' is not allowed in a constant expression}}
319+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
320+
// since-cxx11-note@-2 {{read of member 'e' of union with active member 'd' is not allowed in a constant expression}}
321321

322322
static_assert(C(1.f).b == 2, "");
323323
static_assert(C(1.f).c == 3, "");
324-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
325-
// expected-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
324+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
325+
// since-cxx11-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
326326
static_assert(C(1.f).e == 5, "");
327-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
328-
// expected-note@-2 {{read of member 'e' of union with active member 'f' is not allowed in a constant expression}}
327+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
328+
// since-cxx11-note@-2 {{read of member 'e' of union with active member 'f' is not allowed in a constant expression}}
329329
static_assert(C(1.f).f == 6, "");
330330

331331
static_assert(C("").a == 1, "");
332-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
333-
// expected-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}}
332+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
333+
// since-cxx11-note@-2 {{read of member 'a' of union with active member 'b' is not allowed in a constant expression}}
334334
static_assert(C("").b == 2, "");
335335
static_assert(C("").c == 3, "");
336-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
337-
// expected-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
336+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
337+
// since-cxx11-note@-2 {{read of member 'c' of union with active member 'b' is not allowed in a constant expression}}
338338
static_assert(C("").d == 4, "");
339-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
340-
// expected-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}}
339+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
340+
// since-cxx11-note@-2 {{read of member 'd' of union with active member 'e' is not allowed in a constant expression}}
341341
static_assert(C("").e == 5, "");
342342
static_assert(C("").f == 6, "");
343-
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
344-
// expected-note@-2 {{read of member 'f' of union with active member 'e' is not allowed in a constant expression}}
343+
// since-cxx11-error@-1 {{static assertion expression is not an integral constant expression}}
344+
// since-cxx11-note@-2 {{read of member 'f' of union with active member 'e' is not allowed in a constant expression}}
345345

346346
struct D;
347347
extern const D d;

clang/test/CXX/drs/cwg18xx.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// 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,cxx11-17,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,since-cxx14,cxx98-14,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
4-
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx14,since-cxx17,cxx11-17,since-cxx11,since-cxx14,cxx17 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
5-
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx14,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
2+
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,cxx98-14,cxx11-17,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,cxx11-20,since-cxx14,cxx98-14,cxx11-17,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
4+
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx14,since-cxx17,cxx11-17,since-cxx11,since-cxx14,cxx17 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
5+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx14,since-cxx17,since-cxx20,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
66
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx14,since-cxx17,since-cxx20,since-cxx23,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
77
// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx14,since-cxx17,since-cxx20,since-cxx23,since-cxx11,since-cxx14 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
88

@@ -274,8 +274,8 @@ void d2() {
274274
#if __cplusplus >= 201103L
275275
auto e = [] {
276276
typedef int cwg1820::A;
277-
// expected-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
278-
// expected-error@-2 {{typedef declarator cannot be qualified}}
277+
// since-cxx11-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
278+
// since-cxx11-error@-2 {{typedef declarator cannot be qualified}}
279279
};
280280
#endif
281281
} // namespace cwg1820
@@ -325,9 +325,9 @@ enum E { // #cwg1832-E
325325

326326
#if __cplusplus >= 201103L
327327
enum E2: decltype(static_cast<E2>(0), 0) {};
328-
// expected-error@-1 {{unknown type name 'E2'}}
328+
// since-cxx11-error@-1 {{unknown type name 'E2'}}
329329
enum class E3: decltype(static_cast<E3>(0), 0) {};
330-
// expected-error@-1 {{unknown type name 'E3'}}
330+
// since-cxx11-error@-1 {{unknown type name 'E3'}}
331331
#endif
332332
} // namespace cwg1832
333333

@@ -488,15 +488,12 @@ namespace cwg1872 { // cwg1872: 9
488488
// cxx11-17-error@-1 {{constexpr variable 'y2' must be initialized by a constant expression}}
489489
// cxx11-17-note@-2 {{cannot evaluate call to virtual function in a constant expression in C++ standards before C++20}}
490490
#if __cplusplus >= 202002L
491-
static_assert(y == 0);
491+
static_assert(y2 == 0);
492492
#endif
493493
constexpr int z = A<Z>().f();
494-
// since-cxx11-error@-1 {{constexpr variable 'z' must be initialized by a constant expression}}a
495-
#if __cplusplus < 202302L
496-
// since-cxx11-note@-3 {{non-literal type 'A<Z>' cannot be used in a constant expression}}
497-
#else
498-
// since-cxx23-note@-5 {{cannot construct object of type 'A<cwg1872::Z>' with virtual base class in a constant expression}}
499-
#endif
494+
// since-cxx11-error@-1 {{constexpr variable 'z' must be initialized by a constant expression}}
495+
// cxx11-20-note@-2 {{non-literal type 'A<Z>' cannot be used in a constant expression}}
496+
// since-cxx23-note@-3 {{cannot construct object of type 'A<cwg1872::Z>' with virtual base class in a constant expression}}
500497
#endif
501498
} // namespace cwg1872
502499

0 commit comments

Comments
 (0)