Skip to content

Commit 78a2091

Browse files
committed
Moved Test to cxx2a-consteval.cpp
1 parent e3a5868 commit 78a2091

File tree

2 files changed

+33
-35
lines changed

2 files changed

+33
-35
lines changed

clang/test/SemaCXX/cxx2a-consteval.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,4 +1321,37 @@ namespace GH139160{
13211321
// expected-note@-2 {{non-constexpr function 'make_struct' cannot be used in a constant expression}}
13221322
};
13231323

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+
};
13241334

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+
};

clang/test/SemaCXX/static-assert-cxx26.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -416,38 +416,3 @@ static_assert(
416416
// expected-note@-1 {{read of dereferenced one-past-the-end pointer is not allowed in a constant expression}}
417417
);
418418
}
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-
};

0 commit comments

Comments
 (0)