1
- // RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=ref20,all,all-20 %s
1
+ // RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=ref20,all,all20 %s
2
2
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=ref23,all %s
3
- // RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=expected20,all,all-20 %s -fexperimental-new-constant-interpreter
3
+ // RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify=expected20,all,all20 %s -fexperimental-new-constant-interpreter
4
4
// RUN: %clang_cc1 -std=c++23 -fsyntax-only -fcxx-exceptions -verify=expected23,all %s -fexperimental-new-constant-interpreter
5
5
6
6
// / FIXME: The new interpreter is missing all the 'control flows through...' diagnostics.
@@ -108,9 +108,9 @@ namespace StaticOperators {
108
108
static_assert (f2() == 3 );
109
109
110
110
struct S1 {
111
- constexpr S1 () { // all-20 -error {{never produces a constant expression}}
111
+ constexpr S1 () { // all20 -error {{never produces a constant expression}}
112
112
throw ; // all-note {{not valid in a constant expression}} \
113
- // all-20 -note {{not valid in a constant expression}}
113
+ // all20 -note {{not valid in a constant expression}}
114
114
}
115
115
static constexpr int operator ()() { return 3 ; } // ref20-warning {{C++23 extension}} \
116
116
// expected20-warning {{C++23 extension}}
@@ -121,3 +121,19 @@ namespace StaticOperators {
121
121
122
122
123
123
}
124
+
125
+ int test_in_lambdas () {
126
+ auto c = [](int n) constexpr {
127
+ if (n == 0 )
128
+ return 0 ;
129
+ else
130
+ goto test; // all-note {{subexpression not valid in a constant expression}} \
131
+ // all20-warning {{use of this statement in a constexpr function is a C++23 extension}}
132
+ test:
133
+ return 1 ;
134
+ };
135
+ c (0 );
136
+ constexpr auto A = c (1 ); // all-error {{must be initialized by a constant expression}} \
137
+ // all-note {{in call to}}
138
+ return 0 ;
139
+ }
0 commit comments