File tree Expand file tree Collapse file tree 2 files changed +33
-35
lines changed Expand file tree Collapse file tree 2 files changed +33
-35
lines changed Original file line number Diff line number Diff line change @@ -1321,4 +1321,37 @@ namespace GH139160{
1321
1321
// expected-note@-2 {{non-constexpr function 'make_struct' cannot be used in a constant expression}}
1322
1322
};
1323
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
+ };
1324
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-note@-1 {{subexpression not valid in a constant expression}}
1346
+ constexpr operator bool () {
1347
+ return b;
1348
+ }
1349
+ bool b;
1350
+ };
1351
+ constexpr bool f2 () {
1352
+ for (bool b = false ; Y x = {b}; b = true ) {} // expected-note {{in call to 'x.~Y()'}}
1353
+ return true ;
1354
+ }
1355
+ static_assert (f2()); // expected-error {{static assertion expression is not an integral constant expression}}
1356
+ // expected-note@-1 {{in call to 'f2()'}}
1357
+ };
Original file line number Diff line number Diff line change @@ -416,38 +416,3 @@ static_assert(
416
416
// expected-note@-1 {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
417
417
);
418
418
}
419
-
420
- // taken from: https://github.com/llvm/llvm-project/issues/139818
421
- namespace GH139818 {
422
- struct A {
423
- constexpr ~A () { ref = false ; }
424
- constexpr operator bool () {
425
- return b;
426
- }
427
- bool b;
428
- bool & ref;
429
- };
430
-
431
- constexpr bool f1 () {
432
- bool ret = true ;
433
- for (bool b = false ; A x{b, ret}; b = true ) {}
434
- return ret;
435
- }
436
-
437
- static_assert (!f1());
438
-
439
- struct Y {
440
- constexpr ~Y () noexcept (false ) { throw " oops" ; } // expected-error {{cannot use 'throw' with exceptions disabled}}
441
- // expected-note@-1 {{subexpression not valid in a constant expression}}
442
- constexpr operator bool () {
443
- return b;
444
- }
445
- bool b;
446
- };
447
- constexpr bool f2 () {
448
- for (bool b = false ; Y x = {b}; b = true ) {} // expected-note {{in call to 'x.~Y()'}}
449
- return true ;
450
- }
451
- static_assert (f2()); // expected-error {{static assertion expression is not an integral constant expression}}
452
- // expected-note@-1 {{in call to 'f2()'}}
453
- };
You can’t perform that action at this time.
0 commit comments