Skip to content

Commit 2b97fe2

Browse files
committed
[clang][Interp][NFC] Add more tests for bitfield initializers
1 parent b49f846 commit 2b97fe2

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

clang/test/AST/Interp/bitfields.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -Wno-bitfield-constant-conversion -verify %s
22
// RUN: %clang_cc1 -verify=ref -Wno-bitfield-constant-conversion %s
3+
// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter -Wno-bitfield-constant-conversion -verify %s
4+
// RUN: %clang_cc1 -std=c++20 -verify=ref -Wno-bitfield-constant-conversion %s
35

46
// expected-no-diagnostics
57
// ref-no-diagnostics
@@ -31,6 +33,27 @@ namespace Basic {
3133
return a.a = 10;
3234
}
3335
static_assert(storeA2() == 2, "");
36+
37+
#if __cplusplus >= 202002
38+
struct Init1 {
39+
unsigned a : 2 = 1;
40+
};
41+
constexpr Init1 I1{};
42+
static_assert(I1.a == 1, "");
43+
44+
struct Init2 {
45+
unsigned a : 2 = 100;
46+
};
47+
constexpr Init2 I2{};
48+
static_assert(I2.a == 0, "");
49+
#endif
50+
51+
struct Init3 {
52+
unsigned a : 2;
53+
constexpr Init3() : a(100) {}
54+
};
55+
constexpr Init3 I3{};
56+
static_assert(I3.a == 0, "");
3457
}
3558

3659
namespace Overflow {

0 commit comments

Comments
 (0)