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

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 7 13:39:04 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 374a600df7207fbe2002e754a799c7595a0e4833 9271e67ab27f850413e3d6d6f1383454067efe75 -- clang/test/SemaCXX/constexpr-union-temp-ctor-cxx.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ef4e274389..0ed750375d 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -2393,11 +2393,11 @@ 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 &&
+    } 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(

``````````

</details>


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


More information about the cfe-commits mailing list