|
1 | 1 | // UNSUPPORTED: target={{.*}}-zos{{.*}}
|
2 | 2 | // RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=ref,ref20,all,all20 %s
|
3 |
| -// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=ref,ref23,all %s |
| 3 | +// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=ref,ref23,all,all23 %s |
4 | 4 | // RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=expected20,all,all20 %s -fexperimental-new-constant-interpreter
|
5 |
| -// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=expected23,all %s -fexperimental-new-constant-interpreter |
| 5 | +// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=expected23,all,all23 %s -fexperimental-new-constant-interpreter |
6 | 6 |
|
7 |
| -/// FIXME: The new interpreter is missing all the 'control flows through...' diagnostics. |
8 |
| - |
9 |
| -constexpr int f(int n) { // ref20-error {{constexpr function never produces a constant expression}} |
10 |
| - static const int m = n; // ref20-note {{control flows through the definition of a static variable}} \ |
11 |
| - // ref20-warning {{is a C++23 extension}} \ |
12 |
| - // expected20-warning {{is a C++23 extension}} |
| 7 | +constexpr int f(int n) { // all20-error {{constexpr function never produces a constant expression}} |
| 8 | + static const int m = n; // all-note {{control flows through the definition of a static variable}} \ |
| 9 | + // all20-note {{control flows through the definition of a static variable}} \ |
| 10 | + // all20-warning {{is a C++23 extension}} |
13 | 11 |
|
14 | 12 | return m;
|
15 | 13 | }
|
16 |
| -constexpr int g(int n) { // ref20-error {{constexpr function never produces a constant expression}} |
17 |
| - thread_local const int m = n; // ref20-note {{control flows through the definition of a thread_local variable}} \ |
18 |
| - // ref20-warning {{is a C++23 extension}} \ |
19 |
| - // expected20-warning {{is a C++23 extension}} |
| 14 | +static_assert(f(0) == 0, ""); // all-error {{not an integral constant expression}} \ |
| 15 | + // all-note {{in call to}} |
| 16 | + |
| 17 | +constexpr int g(int n) { // all20-error {{constexpr function never produces a constant expression}} |
| 18 | + thread_local const int m = n; // all-note {{control flows through the definition of a thread_local variable}} \ |
| 19 | + // all20-note {{control flows through the definition of a thread_local variable}} \ |
| 20 | + // all20-warning {{is a C++23 extension}} |
20 | 21 | return m;
|
21 | 22 | }
|
| 23 | +static_assert(g(0) == 0, ""); // all-error {{not an integral constant expression}} \ |
| 24 | + // all-note {{in call to}} |
22 | 25 |
|
23 |
| -constexpr int c_thread_local(int n) { // ref20-error {{constexpr function never produces a constant expression}} \ |
24 |
| - // expected20-error {{constexpr function never produces a constant expression}} |
25 |
| - static _Thread_local int m = 0; // ref20-note {{control flows through the definition of a thread_local variable}} \ |
26 |
| - // ref20-warning {{is a C++23 extension}} \ |
27 |
| - // expected20-warning {{is a C++23 extension}} \ |
28 |
| - // expected20-note {{declared here}} |
29 |
| - return m; // expected20-note {{read of non-const variable}} |
| 26 | +constexpr int c_thread_local(int n) { // all20-error {{constexpr function never produces a constant expression}} |
| 27 | + static _Thread_local int m = 0; // all20-note 2{{control flows through the definition of a thread_local variable}} \ |
| 28 | + // all23-note {{control flows through the definition of a thread_local variable}} \ |
| 29 | + // all20-warning {{is a C++23 extension}} |
| 30 | + return m; |
30 | 31 | }
|
| 32 | +static_assert(c_thread_local(0) == 0, ""); // all-error {{not an integral constant expression}} \ |
| 33 | + // all-note {{in call to}} |
31 | 34 |
|
32 | 35 |
|
33 |
| -constexpr int gnu_thread_local(int n) { // ref20-error {{constexpr function never produces a constant expression}} \ |
34 |
| - // expected20-error {{constexpr function never produces a constant expression}} |
35 |
| - static __thread int m = 0; // ref20-note {{control flows through the definition of a thread_local variable}} \ |
36 |
| - // ref20-warning {{is a C++23 extension}} \ |
37 |
| - // expected20-warning {{is a C++23 extension}} \ |
38 |
| - // expected20-note {{declared here}} |
39 |
| - return m; // expected20-note {{read of non-const variable}} |
| 36 | +constexpr int gnu_thread_local(int n) { // all20-error {{constexpr function never produces a constant expression}} |
| 37 | + static __thread int m = 0; // all20-note 2{{control flows through the definition of a thread_local variable}} \ |
| 38 | + // all23-note {{control flows through the definition of a thread_local variable}} \ |
| 39 | + // all20-warning {{is a C++23 extension}} |
| 40 | + return m; |
40 | 41 | }
|
| 42 | +static_assert(gnu_thread_local(0) == 0, ""); // all-error {{not an integral constant expression}} \ |
| 43 | + // all-note {{in call to}} |
41 | 44 |
|
42 |
| -constexpr int h(int n) { // ref20-error {{constexpr function never produces a constant expression}} |
43 |
| - static const int m = n; // ref20-note {{control flows through the definition of a static variable}} \ |
44 |
| - // ref20-warning {{is a C++23 extension}} \ |
45 |
| - // expected20-warning {{is a C++23 extension}} |
| 45 | +constexpr int h(int n) { // all20-error {{constexpr function never produces a constant expression}} |
| 46 | + static const int m = n; // all20-note {{control flows through the definition of a static variable}} \ |
| 47 | + // all20-warning {{is a C++23 extension}} |
46 | 48 | return &m - &m;
|
47 | 49 | }
|
48 | 50 |
|
49 |
| -constexpr int i(int n) { // ref20-error {{constexpr function never produces a constant expression}} |
50 |
| - thread_local const int m = n; // ref20-note {{control flows through the definition of a thread_local variable}} \ |
51 |
| - // ref20-warning {{is a C++23 extension}} \ |
52 |
| - // expected20-warning {{is a C++23 extension}} |
| 51 | +constexpr int i(int n) { // all20-error {{constexpr function never produces a constant expression}} |
| 52 | + thread_local const int m = n; // all20-note {{control flows through the definition of a thread_local variable}} \ |
| 53 | + // all20-warning {{is a C++23 extension}} |
53 | 54 | return &m - &m;
|
54 | 55 | }
|
55 | 56 |
|
|
0 commit comments