1 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -Wno-bitfield-constant-conversion -verify=expected,both %s
2 // RUN: %clang_cc1 -verify=ref,both -Wno-bitfield-constant-conversion %s
3 // RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter -Wno-bitfield-constant-conversion -verify=expected,both %s
4 // RUN: %clang_cc1 -std=c++20 -verify=ref,both -Wno-bitfield-constant-conversion %s
9 constexpr A() : a(0) {}
10 constexpr A(int a
) : a(a
) {}
14 static_assert(a
.a
== 1, "");
17 static_assert(a2
.a
== 2, "");
20 constexpr int storeA() {
26 static_assert(storeA() == 2, "");
28 constexpr int storeA2() {
32 static_assert(storeA2() == 2, "");
34 #if __cplusplus >= 202002
39 static_assert(I1
.a
== 1, "");
45 static_assert(I2
.a
== 0, "");
50 constexpr Init3() : a(100) {}
53 static_assert(I3
.a
== 0, "");
64 static_assert(f() == 3, "");
70 constexpr A() : a(0) {}
71 constexpr A(int a
) : a(a
) {}
74 constexpr unsigned add() {
79 static_assert(add() == 2, "");
81 constexpr unsigned sub() {
86 static_assert(sub() == 2, "");
88 constexpr unsigned mul() {
93 static_assert(mul() == 1, "");
95 constexpr unsigned div() {
100 static_assert(div() == 1, "");
104 extern int int_source();
120 c
.onebit
= int_source();
124 namespace NonConstBitWidth
{
125 int n3
= 37; // both-note {{declared here}}
127 int l
: n3
; // both-error {{constant expression}} \
128 // both-note {{read of non-const variable}}