diff options
author | Timm Bäder <tbaeder@redhat.com> | 2024-05-23 10:20:42 +0200 |
---|---|---|
committer | Timm Bäder <tbaeder@redhat.com> | 2024-05-23 10:21:02 +0200 |
commit | 335e00faaf74f3f7463b32a415d39af0973f521f (patch) | |
tree | beff87aadab1d40e64295c6906b5236a3b62a60c | |
parent | 951b13d9a7220d761b1ee0dc09a50b635692ecf8 (diff) | |
download | llvm-335e00faaf74f3f7463b32a415d39af0973f521f.zip llvm-335e00faaf74f3f7463b32a415d39af0973f521f.tar.gz llvm-335e00faaf74f3f7463b32a415d39af0973f521f.tar.bz2 |
[clang][Interp][NFC] Add another union test case
-rw-r--r-- | clang/test/AST/Interp/unions.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/AST/Interp/unions.cpp b/clang/test/AST/Interp/unions.cpp index bc5604c..73e42d5 100644 --- a/clang/test/AST/Interp/unions.cpp +++ b/clang/test/AST/Interp/unions.cpp @@ -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, ""); +} |