1 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=ref20 %s
2 // RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=ref23 %s
3 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=expected20 %s -fexperimental-new-constant-interpreter
4 // RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=expected23 %s -fexperimental-new-constant-interpreter
7 // expected23-no-diagnostics
10 /// FIXME: The new interpreter is missing all the 'control flows through...' diagnostics.
12 constexpr int f(int n
) { // ref20-error {{constexpr function never produces a constant expression}} \
13 // ref23-error {{constexpr function never produces a constant expression}}
14 static const int m
= n
; // ref20-note {{control flows through the definition of a static variable}} \
15 // ref20-warning {{is a C++23 extension}} \
16 // ref23-note {{control flows through the definition of a static variable}} \
17 // expected20-warning {{is a C++23 extension}}
21 constexpr int g(int n
) { // ref20-error {{constexpr function never produces a constant expression}} \
22 // ref23-error {{constexpr function never produces a constant expression}}
23 thread_local
const int m
= n
; // ref20-note {{control flows through the definition of a thread_local variable}} \
24 // ref20-warning {{is a C++23 extension}} \
25 // ref23-note {{control flows through the definition of a thread_local variable}} \
26 // expected20-warning {{is a C++23 extension}}
30 constexpr int c_thread_local(int n
) { // ref20-error {{constexpr function never produces a constant expression}} \
31 // ref23-error {{constexpr function never produces a constant expression}}
32 static _Thread_local
int m
= 0; // ref20-note {{control flows through the definition of a thread_local variable}} \
33 // ref20-warning {{is a C++23 extension}} \
34 // ref23-note {{control flows through the definition of a thread_local variable}} \
35 // expected20-warning {{is a C++23 extension}}
40 constexpr int gnu_thread_local(int n
) { // ref20-error {{constexpr function never produces a constant expression}} \
41 // ref23-error {{constexpr function never produces a constant expression}}
42 static __thread
int m
= 0; // ref20-note {{control flows through the definition of a thread_local variable}} \
43 // ref20-warning {{is a C++23 extension}} \
44 // ref23-note {{control flows through the definition of a thread_local variable}} \
45 // expected20-warning {{is a C++23 extension}}
49 constexpr int h(int n
) { // ref20-error {{constexpr function never produces a constant expression}} \
50 // ref23-error {{constexpr function never produces a constant expression}}
51 static const int m
= n
; // ref20-note {{control flows through the definition of a static variable}} \
52 // ref20-warning {{is a C++23 extension}} \
53 // ref23-note {{control flows through the definition of a static variable}} \
54 // expected20-warning {{is a C++23 extension}}
58 constexpr int i(int n
) { // ref20-error {{constexpr function never produces a constant expression}} \
59 // ref23-error {{constexpr function never produces a constant expression}}
60 thread_local
const int m
= n
; // ref20-note {{control flows through the definition of a thread_local variable}} \
61 // ref20-warning {{is a C++23 extension}} \
62 // ref23-note {{control flows through the definition of a thread_local variable}} \
63 // expected20-warning {{is a C++23 extension}}
67 constexpr int j(int n
) {
70 static const int m
= n
; // ref20-warning {{is a C++23 extension}} \
71 // expected20-warning {{is a C++23 extension}}
74 constexpr int j0
= j(0);
76 constexpr int k(int n
) {
79 thread_local
const int m
= n
; // ref20-warning {{is a C++23 extension}} \
80 // expected20-warning {{is a C++23 extension}}
84 constexpr int k0
= k(0);