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

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 20:03:05 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}}
+};
+constexpr D<int> d;
----------------
shafik wrote:

Please add a newline at the end of the file.

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


More information about the cfe-commits mailing list