[clang][Interp][NFC] Add another union test case

This commit is contained in:
Timm Bäder
2024-05-23 10:20:42 +02:00
parent 951b13d9a7
commit 335e00faaf

View File

@@ -30,3 +30,16 @@ constexpr A ab = {.d = 1.0};
static_assert(ab.d == 1.0, "");
static_assert(ab.a == 1, ""); // both-error {{not an integral constant expression}} \
// both-note {{read of member 'a' of union with active member 'd'}}
namespace SimpleStore {
union A {
int a;
int b;
};
constexpr int foo() {
A a{.b = 4};
a.b = 10;
return a.b;
}
static_assert(foo() == 10, "");
}