mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 09:57:08 +08:00
[clang][Interp][NFC] Add another union test case
This commit is contained in:
@@ -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, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user