Skip to content

Commit 1438639

Browse files
committed
[LLDB] Remove undefined behavior in TestConstStaticIntegralMember.py
Setting an enum without a fixed underlying type to a value which is outside the value range is undefined behavior. The initializer needs to be a constant expression and therefore this was always ill-formed we just were not diagnosing it before. See D130058 and D131307 for more details. Differential Revision: https://reviews.llvm.org/D131460
1 parent 03e345b commit 1438639

File tree

2 files changed

+0
-4
lines changed

2 files changed

+0
-4
lines changed

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ def test(self):
5353

5454
# Test an unscoped enum.
5555
self.expect_expr("A::enum_val", result_value="enum_case2")
56-
# Test an unscoped enum with an invalid enum case.
57-
self.expect_expr("A::invalid_enum_val", result_value="enum_case1 | enum_case2 | 0x4")
5856

5957
# Test a scoped enum.
6058
self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")

lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ struct A {
4747
std::numeric_limits<unsigned long long>::min();
4848

4949
const static Enum enum_val = enum_case2;
50-
const static Enum invalid_enum_val = static_cast<Enum>(enum_case2 + 5);
5150
const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
5251
const static ScopedEnum invalid_scoped_enum_val = static_cast<ScopedEnum>(5);
5352
const static ScopedCharEnum scoped_char_enum_val = ScopedCharEnum::case2;
@@ -102,7 +101,6 @@ int main() {
102101
int member_copy = ClassWithOnlyConstStatic::member;
103102

104103
Enum e = A::enum_val;
105-
e = A::invalid_enum_val;
106104
ScopedEnum se = A::scoped_enum_val;
107105
se = A::invalid_scoped_enum_val;
108106
ScopedCharEnum sce = A::scoped_char_enum_val;

0 commit comments

Comments
 (0)