Author: Timm Bäder Date: 2024-05-23T10:21:02+02:00 New Revision: 335e00faaf74f3f7463b32a415d39af0973f521f
URL: https://github.com/llvm/llvm-project/commit/335e00faaf74f3f7463b32a415d39af0973f521f DIFF: https://github.com/llvm/llvm-project/commit/335e00faaf74f3f7463b32a415d39af0973f521f.diff LOG: [clang][Interp][NFC] Add another union test case Added: Modified: clang/test/AST/Interp/unions.cpp Removed: ################################################################################ diff --git a/clang/test/AST/Interp/unions.cpp b/clang/test/AST/Interp/unions.cpp index bc5604c2b2d04..73e42d57a7b77 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, ""); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits