1
- // RUN: %clang_cc1 -Wno-string-plus-int -fexperimental-new-constant-interpreter %s -verify
2
- // RUN: %clang_cc1 -Wno-string-plus-int -fexperimental-new-constant-interpreter -triple i686 %s -verify
3
- // RUN: %clang_cc1 -Wno-string-plus-int -verify=ref %s -Wno-constant-evaluated
4
- // RUN: %clang_cc1 -std=c++20 -Wno-string-plus-int -fexperimental-new-constant-interpreter %s -verify
5
- // RUN: %clang_cc1 -std=c++20 -Wno-string-plus-int -fexperimental-new-constant-interpreter -triple i686 %s -verify
6
- // RUN: %clang_cc1 -std=c++20 -Wno-string-plus-int -verify=ref %s -Wno-constant-evaluated
7
- // RUN: %clang_cc1 -triple avr -std=c++20 -Wno-string-plus-int -fexperimental-new-constant-interpreter %s -verify
8
- // RUN: %clang_cc1 -triple avr -std=c++20 -Wno-string-plus-int -verify=ref %s -Wno-constant-evaluated
1
+ // RUN: %clang_cc1 -Wno-string-plus-int -fexperimental-new-constant-interpreter %s -verify=expected,both
2
+ // RUN: %clang_cc1 -Wno-string-plus-int -fexperimental-new-constant-interpreter -triple i686 %s -verify=expected,both
3
+ // RUN: %clang_cc1 -Wno-string-plus-int -verify=ref,both %s -Wno-constant-evaluated
4
+ // RUN: %clang_cc1 -std=c++20 -Wno-string-plus-int -fexperimental-new-constant-interpreter %s -verify=expected,both
5
+ // RUN: %clang_cc1 -std=c++20 -Wno-string-plus-int -fexperimental-new-constant-interpreter -triple i686 %s -verify=expected,both
6
+ // RUN: %clang_cc1 -std=c++20 -Wno-string-plus-int -verify=ref,both %s -Wno-constant-evaluated
7
+ // RUN: %clang_cc1 -triple avr -std=c++20 -Wno-string-plus-int -fexperimental-new-constant-interpreter %s -verify=expected,both
8
+ // RUN: %clang_cc1 -triple avr -std=c++20 -Wno-string-plus-int -verify=ref,both %s -Wno-constant-evaluated
9
9
10
10
11
11
namespace strcmp {
@@ -23,23 +23,17 @@ namespace strcmp {
23
23
static_assert (__builtin_strcmp(" abab\0 banana" , " abab" ) == 0 , " " );
24
24
static_assert (__builtin_strcmp(" abab" , " abab\0 banana" ) == 0 , " " );
25
25
static_assert (__builtin_strcmp(" abab\0 banana" , " abab\0 canada" ) == 0 , " " );
26
- static_assert (__builtin_strcmp(0 , " abab" ) == 0 , " " ); // expected-error {{not an integral constant}} \
27
- // expected-note {{dereferenced null}} \
28
- // expected-note {{in call to}} \
29
- // ref-error {{not an integral constant}} \
30
- // ref-note {{dereferenced null}}
31
- static_assert (__builtin_strcmp(" abab" , 0 ) == 0 , " " ); // expected-error {{not an integral constant}} \
32
- // expected-note {{dereferenced null}} \
33
- // expected-note {{in call to}} \
34
- // ref-error {{not an integral constant}} \
35
- // ref-note {{dereferenced null}}
26
+ static_assert (__builtin_strcmp(0 , " abab" ) == 0 , " " ); // both-error {{not an integral constant}} \
27
+ // both-note {{dereferenced null}} \
28
+ // expected-note {{in call to}}
29
+ static_assert (__builtin_strcmp(" abab" , 0 ) == 0 , " " ); // both-error {{not an integral constant}} \
30
+ // both-note {{dereferenced null}} \
31
+ // expected-note {{in call to}}
36
32
37
33
static_assert (__builtin_strcmp(kFoobar , kFoobazfoobar ) == -1 , " " );
38
- static_assert (__builtin_strcmp(kFoobar , kFoobazfoobar + 6 ) == 0 , " " ); // expected-error {{not an integral constant}} \
39
- // expected-note {{dereferenced one-past-the-end}} \
40
- // expected-note {{in call to}} \
41
- // ref-error {{not an integral constant}} \
42
- // ref-note {{dereferenced one-past-the-end}}
34
+ static_assert (__builtin_strcmp(kFoobar , kFoobazfoobar + 6 ) == 0 , " " ); // both-error {{not an integral constant}} \
35
+ // both-note {{dereferenced one-past-the-end}} \
36
+ // expected-note {{in call to}}
43
37
}
44
38
45
39
// / Copied from constant-expression-cxx11.cpp
@@ -69,41 +63,27 @@ constexpr const char *a = "foo\0quux";
69
63
static_assert (check(b), " " );
70
64
static_assert (check(c), " " );
71
65
72
- constexpr int over1 = __builtin_strlen(a + 9 ); // expected-error {{constant expression}} \
73
- // expected-note {{one-past-the-end}} \
74
- // expected-note {{in call to}} \
75
- // ref-error {{constant expression}} \
76
- // ref-note {{one-past-the-end}}
77
- constexpr int over2 = __builtin_strlen(b + 9 ); // expected-error {{constant expression}} \
78
- // expected-note {{one-past-the-end}} \
79
- // expected-note {{in call to}} \
80
- // ref-error {{constant expression}} \
81
- // ref-note {{one-past-the-end}}
82
- constexpr int over3 = __builtin_strlen(c + 9 ); // expected-error {{constant expression}} \
83
- // expected-note {{one-past-the-end}} \
84
- // expected-note {{in call to}} \
85
- // ref-error {{constant expression}} \
86
- // ref-note {{one-past-the-end}}
87
-
88
- constexpr int under1 = __builtin_strlen(a - 1 ); // expected-error {{constant expression}} \
89
- // expected-note {{cannot refer to element -1}} \
90
- // ref-error {{constant expression}} \
91
- // ref-note {{cannot refer to element -1}}
92
- constexpr int under2 = __builtin_strlen(b - 1 ); // expected-error {{constant expression}} \
93
- // expected-note {{cannot refer to element -1}} \
94
- // ref-error {{constant expression}} \
95
- // ref-note {{cannot refer to element -1}}
96
- constexpr int under3 = __builtin_strlen(c - 1 ); // expected-error {{constant expression}} \
97
- // expected-note {{cannot refer to element -1}} \
98
- // ref-error {{constant expression}} \
99
- // ref-note {{cannot refer to element -1}}
66
+ constexpr int over1 = __builtin_strlen(a + 9 ); // both-error {{constant expression}} \
67
+ // both-note {{one-past-the-end}} \
68
+ // expected-note {{in call to}}
69
+ constexpr int over2 = __builtin_strlen(b + 9 ); // both-error {{constant expression}} \
70
+ // both-note {{one-past-the-end}} \
71
+ // expected-note {{in call to}}
72
+ constexpr int over3 = __builtin_strlen(c + 9 ); // both-error {{constant expression}} \
73
+ // both-note {{one-past-the-end}} \
74
+ // expected-note {{in call to}}
75
+
76
+ constexpr int under1 = __builtin_strlen(a - 1 ); // both-error {{constant expression}} \
77
+ // both-note {{cannot refer to element -1}}
78
+ constexpr int under2 = __builtin_strlen(b - 1 ); // both-error {{constant expression}} \
79
+ // both-note {{cannot refer to element -1}}
80
+ constexpr int under3 = __builtin_strlen(c - 1 ); // both-error {{constant expression}} \
81
+ // both-note {{cannot refer to element -1}}
100
82
101
83
constexpr char d[] = { ' f' , ' o' , ' o' }; // no nul terminator.
102
- constexpr int bad = __builtin_strlen(d); // expected-error {{constant expression}} \
103
- // expected-note {{one-past-the-end}} \
104
- // expected-note {{in call to}} \
105
- // ref-error {{constant expression}} \
106
- // ref-note {{one-past-the-end}}
84
+ constexpr int bad = __builtin_strlen(d); // both-error {{constant expression}} \
85
+ // both-note {{one-past-the-end}} \
86
+ // expected-note {{in call to}}
107
87
}
108
88
109
89
namespace nan {
@@ -115,8 +95,7 @@ namespace nan {
115
95
// expected-error@-2 {{must be initialized by a constant expression}}
116
96
#endif
117
97
118
- constexpr double NaN3 = __builtin_nan(" foo" ); // expected-error {{must be initialized by a constant expression}} \
119
- // ref-error {{must be initialized by a constant expression}}
98
+ constexpr double NaN3 = __builtin_nan(" foo" ); // both-error {{must be initialized by a constant expression}}
120
99
constexpr float NaN4 = __builtin_nanf(" " );
121
100
// constexpr long double NaN5 = __builtin_nanf128("");
122
101
@@ -126,8 +105,7 @@ namespace nan {
126
105
127
106
// / FIXME: Current interpreter misses diagnostics.
128
107
constexpr char f2[] = {' 0' , ' x' , ' A' , ' E' }; // / No trailing 0 byte.
129
- constexpr double NaN7 = __builtin_nan(f2); // ref-error {{must be initialized by a constant expression}} \
130
- // expected-error {{must be initialized by a constant expression}} \
108
+ constexpr double NaN7 = __builtin_nan(f2); // both-error {{must be initialized by a constant expression}} \
131
109
// expected-note {{read of dereferenced one-past-the-end pointer}} \
132
110
// expected-note {{in call to}}
133
111
static_assert (!__builtin_issignaling(__builtin_nan(" " )), " " );
@@ -370,9 +348,6 @@ namespace EhReturnDataRegno {
370
348
case __builtin_eh_return_data_regno (0 ): // constant foldable.
371
349
break ;
372
350
}
373
-
374
- __builtin_eh_return_data_regno (X); // expected-error {{argument to '__builtin_eh_return_data_regno' must be a constant integer}} \
375
- // ref-error {{argument to '__builtin_eh_return_data_regno' must be a constant integer}}
376
-
351
+ __builtin_eh_return_data_regno (X); // both-error {{argument to '__builtin_eh_return_data_regno' must be a constant integer}}
377
352
}
378
353
}
0 commit comments