From 335e00faaf74f3f7463b32a415d39af0973f521f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 23 May 2024 10:20:42 +0200 Subject: [PATCH] [clang][Interp][NFC] Add another union test case --- clang/test/AST/Interp/unions.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/clang/test/AST/Interp/unions.cpp b/clang/test/AST/Interp/unions.cpp index bc5604c2b2d044..73e42d57a7b772 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, ""); +}