Skip to content

Commit b596108

Browse files
committed
Move tests from Ast/Bytecode to SemaCxx
1 parent d4af25b commit b596108

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -376,42 +376,3 @@ constexpr int N = [] // expected-error {{must be initialized by a constant expre
376376
return s.a[0];
377377
}();
378378
#endif
379-
380-
constexpr int modify_const_variable() {
381-
const int a = 10;
382-
new ((int *)&a) int(12); // both-note {{modification of object of const-qualified type 'const int' is not allowed in a constant expression}}
383-
return a;
384-
}
385-
static_assert(modify_const_variable()); // both-error {{not an integral constant expression}} \
386-
// both-note {{in call to}}
387-
388-
typedef const int T0;
389-
typedef T0 T1;
390-
constexpr T1 modify_const_variable_td() {
391-
T1 a = 10;
392-
new ((int *)&a) int(12); // both-note {{modification of object of const-qualified type 'T1' (aka 'const int') is not allowed in a constant expression}}
393-
return a;
394-
}
395-
static_assert(modify_const_variable_td()); // both-error {{not an integral constant expression}} \
396-
// both-note {{in call to}}
397-
398-
template<typename T>
399-
constexpr T modify_const_variable_tmpl() {
400-
T a = 10;
401-
new ((int *)&a) int(12); // both-note {{modification of object of const-qualified type 'const int' is not allowed in a constant expression}}
402-
return a;
403-
}
404-
static_assert(modify_const_variable_tmpl<const int>()); // both-error {{not an integral constant expression}} \
405-
// both-note {{in call to}}
406-
407-
namespace ModifyMutableMember {
408-
struct S {
409-
mutable int a {10};
410-
};
411-
constexpr int modify_mutable_member() {
412-
const S s;
413-
new ((int *)&s.a) int(12);
414-
return s.a;
415-
}
416-
static_assert(modify_mutable_member() == 12);
417-
}

clang/test/SemaCXX/cxx2c-constexpr-placement-new.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,42 @@ constexpr bool bleh() {
114114
}
115115
static_assert(bleh()); // expected-error {{not an integral constant expression}} \
116116
// expected-note {{in call to 'bleh()'}}
117+
118+
constexpr int modify_const_variable() {
119+
const int a = 10;
120+
new ((int *)&a) int(12); // both-note {{modification of object of const-qualified type 'const int' is not allowed in a constant expression}}
121+
return a;
122+
}
123+
static_assert(modify_const_variable()); // both-error {{not an integral constant expression}} \
124+
// both-note {{in call to}}
125+
126+
typedef const int T0;
127+
typedef T0 T1;
128+
constexpr T1 modify_const_variable_td() {
129+
T1 a = 10;
130+
new ((int *)&a) int(12); // both-note {{modification of object of const-qualified type 'T1' (aka 'const int') is not allowed in a constant expression}}
131+
return a;
132+
}
133+
static_assert(modify_const_variable_td()); // both-error {{not an integral constant expression}} \
134+
// both-note {{in call to}}
135+
136+
template<typename T>
137+
constexpr T modify_const_variable_tmpl() {
138+
T a = 10;
139+
new ((int *)&a) int(12); // both-note {{modification of object of const-qualified type 'const int' is not allowed in a constant expression}}
140+
return a;
141+
}
142+
static_assert(modify_const_variable_tmpl<const int>()); // both-error {{not an integral constant expression}} \
143+
// both-note {{in call to}}
144+
145+
namespace ModifyMutableMember {
146+
struct S {
147+
mutable int a {10};
148+
};
149+
constexpr int modify_mutable_member() {
150+
const S s;
151+
new ((int *)&s.a) int(12);
152+
return s.a;
153+
}
154+
static_assert(modify_mutable_member() == 12);
155+
}

0 commit comments

Comments
 (0)