================
@@ -2393,6 +2393,25 @@ static bool CheckConstexprFunctionBody(Sema &SemaRef, 
const FunctionDecl *Dcl,
                                              Kind))
             return false;
       }
+    } else if (!Constructor->isDelegatingConstructor()) {
+      for (const Decl *decl : RD->decls()) {
+        if (const auto *inner = dyn_cast<CXXRecordDecl>(decl)) {
+          if (inner->isUnion()) {
+            if (Constructor->getNumCtorInitializers() == 0 &&
+                RD->hasVariantMembers()) {
+              if (Kind == Sema::CheckConstexprKind::Diagnose) {
+                SemaRef.Diag(
+                    Dcl->getLocation(),
+                    SemaRef.getLangOpts().CPlusPlus20
+                        ? diag::warn_cxx17_compat_constexpr_union_ctor_no_init
+                        : diag::ext_constexpr_union_ctor_no_init);
+              } else if (!SemaRef.getLangOpts().CPlusPlus20) {
+                return false;
+              }
----------------
mahtohappy wrote:

by unify you mean, put the check in the new function and call it at that place?

https://github.com/llvm/llvm-project/pull/81042
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to