================
@@ -9543,6 +9543,48 @@ bool 
SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
   if (DiagKind == -1)
     return false;
 
+  if (this->S.Context.getLangOpts().CPlusPlus26 && inUnion() &&
+      CSM == CXXSpecialMemberKind::Destructor) {
+    // [class.dtor]/7 In C++26, a destructor for a union X is only deleted 
under
+    // the additional conditions that:
+
+    // overload resolution to select a constructor to default-initialize an
+    // object of type X either fails or selects a constructor that is either
+    // deleted or not trivial, or
+    // or X has a variant member V of class type M (or possibly
+    // multi-dimensional array thereof) where V has a default member 
initializer
+    // and M has a destructor that is non-trivial,
+
+    RecordDecl *Parent = Field->getParent();
+    while (Parent &&
+           (Parent->isAnonymousStructOrUnion() ||
+            (Parent->isUnion() && Parent->getIdentifier() == nullptr))) {
+      if (auto RD = dyn_cast_or_null<RecordDecl>(Parent->getParent())) {
+        Parent = RD;
+      } else {
----------------
bcardosolopes wrote:

No curly braces needed in both `if` legs

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

Reply via email to