File tree 2 files changed +36
-37
lines changed 2 files changed +36
-37
lines changed Original file line number Diff line number Diff line change @@ -1320,40 +1320,3 @@ namespace GH139160{
1320
1320
// expected-error@-1 {{call to consteval function 'GH139160::get_value' is not a constant expression}}
1321
1321
// expected-note@-2 {{non-constexpr function 'make_struct' cannot be used in a constant expression}}
1322
1322
};
1323
-
1324
- // taken from: https://github.com/llvm/llvm-project/issues/139818
1325
- namespace GH139818 {
1326
- struct A {
1327
- constexpr ~A () { ref = false ; }
1328
- constexpr operator bool () {
1329
- return b;
1330
- }
1331
- bool b;
1332
- bool & ref;
1333
- };
1334
-
1335
- constexpr bool f1 () {
1336
- bool ret = true ;
1337
- for (bool b = false ; A x{b, ret}; b = true ) {}
1338
- return ret;
1339
- }
1340
-
1341
- static_assert (!f1());
1342
-
1343
- struct Y {
1344
- constexpr ~Y () noexcept (false ) { throw " oops" ; } // expected-error {{cannot use 'throw' with exceptions disabled}}
1345
- // expected-error@-1 {{constexpr function never produces a constant expression}}
1346
- // expected-note@-2 {{subexpression not valid in a constant expression}}
1347
- // expected-note@-3 {{subexpression not valid in a constant expression}}
1348
- constexpr operator bool () {
1349
- return b;
1350
- }
1351
- bool b;
1352
- };
1353
- constexpr bool f2 () {
1354
- for (bool b = false ; Y x = {b}; b = true ) {} // expected-note {{in call to 'x.~Y()'}}
1355
- return true ;
1356
- }
1357
- static_assert (f2()); // expected-error {{static assertion expression is not an integral constant expression}}
1358
- // expected-note@-1 {{in call to 'f2()'}}
1359
- };
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -std=c++23 -fsyntax-only %s -verify
2
+ // RUN: %clang_cc1 -std=c++23 -fsyntax-only %s -verify -fexperimental-new-constant-interpreter
3
+
4
+ namespace GH139818 {
5
+ struct A {
6
+ constexpr ~A () { ref = false ; }
7
+ constexpr operator bool () {
8
+ return b;
9
+ }
10
+ bool b;
11
+ bool & ref;
12
+ };
13
+
14
+ constexpr bool f1 () {
15
+ bool ret = true ;
16
+ for (bool b = false ; A x{b, ret}; b = true ) {}
17
+ return ret;
18
+ }
19
+
20
+ static_assert (!f1());
21
+
22
+ struct Y {
23
+ constexpr ~Y () noexcept (false ) { throw " oops" ; } // expected-error {{cannot use 'throw' with exceptions disabled}}
24
+ // expected-note@-1 {{subexpression not valid in a constant expression}}
25
+ constexpr operator bool () {
26
+ return b;
27
+ }
28
+ bool b;
29
+ };
30
+ constexpr bool f2 () {
31
+ for (bool b = false ; Y x = {b}; b = true ) {} // expected-note {{in call to 'x.~Y()'}}
32
+ return true ;
33
+ }
34
+ static_assert (f2()); // expected-error {{static assertion expression is not an integral constant expression}}
35
+ // expected-note@-1 {{in call to 'f2()'}}
36
+ };
You can’t perform that action at this time.
0 commit comments