Skip to content

Commit 258ba7f

Browse files
committed
Moved Test to Different File
1 parent a880c60 commit 258ba7f

File tree

2 files changed

+36
-37
lines changed

2 files changed

+36
-37
lines changed

clang/test/SemaCXX/cxx2a-consteval.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,40 +1320,3 @@ namespace GH139160{
13201320
// expected-error@-1 {{call to consteval function 'GH139160::get_value' is not a constant expression}}
13211321
// expected-note@-2 {{non-constexpr function 'make_struct' cannot be used in a constant expression}}
13221322
};
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-
};

clang/test/SemaCXX/gh139818.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
};

0 commit comments

Comments
 (0)