[clang] [Clang][Sema] Diagnosis for constexpr constructor not initializing a union member (PR #81042)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 8 03:12:34 PST 2024


================
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++14 -verify -fcxx-exceptions -Werror=c++14-extensions -Werror=c++20-extensions %s
+
+template <class> struct C {
+    union {
+      int i;
+    };
+    constexpr C() {} // expected-error {{constexpr union constructor that does not initialize any member is a C++20 extension}}
+};
+constexpr C<int> c;
+
+template <class> class D {
+    union {
+      int i;
+    };
+public:
+    constexpr D() {} // expected-error {{constexpr union constructor that does not initialize any member is a C++20 extension}}
----------------
Fznamznon wrote:

Can we add a test checking if we do initialize something there is no error?

https://github.com/llvm/llvm-project/pull/81042


More information about the cfe-commits mailing list