Skip to content

Commit 52efe03

Browse files
authored
[clang][bytecode] Enable some placement-new tests (#171567)
They used to cause problems. Use the BYTECODE define to enable them at least for the bytecode interpreter.
1 parent 5759a3a commit 52efe03

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

clang/test/AST/ByteCode/placement-new.cpp

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,41 +68,40 @@ consteval int ok5() {
6868
} s;
6969
new (&s) S[1]{{12, 13}};
7070

71+
/// FIXME: Broken in the current interpreter.
72+
#if BYTECODE
73+
return s.a + s.b;
74+
#else
7175
return 25;
72-
// return s.a + s.b; FIXME: Broken in the current interpreter.
76+
#endif
7377
}
7478
static_assert(ok5() == 25);
7579

76-
/// FIXME: Broken in both interpreters.
77-
#if 0
78-
consteval int ok5() {
80+
consteval int ok6() {
81+
int i[2];
82+
new (i) int(100);
83+
new (i + 1) int(200);
84+
return i[0] + i[1];
85+
}
86+
static_assert(ok6() == 300);
87+
88+
/// FIXME: Broken in the current interpreter.
89+
#if BYTECODE
90+
consteval int ok7() {
7991
int i;
80-
new (&i) int[1]{1}; // expected-note {{assignment to dereferenced one-past-the-end pointer}}
92+
new (&i) int[1]{1};
8193
return i;
8294
}
83-
static_assert(ok5() == 1); // expected-error {{not an integral constant expression}} \
84-
// expected-note {{in call to}}
85-
#endif
95+
static_assert(ok7() == 1);
8696

87-
/// FIXME: Crashes the current interpreter.
88-
#if 0
89-
consteval int ok6() {
97+
consteval int ok8() {
9098
int i[2];
9199
new (&i) int(100);
92100
return i[0];
93101
}
94-
static_assert(ok6() == 100);
102+
static_assert(ok8() == 100);
95103
#endif
96104

97-
consteval int ok6() {
98-
int i[2];
99-
new (i) int(100);
100-
new (i + 1) int(200);
101-
return i[0] + i[1];
102-
}
103-
static_assert(ok6() == 300);
104-
105-
106105
consteval auto fail1() {
107106
int b;
108107
new (&b) float(1.0); // both-note {{placement new would change type of storage from 'int' to 'float'}}

0 commit comments

Comments
 (0)