[clang] [Clang] Implement CWG2598: Union of non-literal types (PR #78195)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 14:35:16 PST 2024


================
@@ -1383,6 +1383,34 @@ void CXXRecordDecl::addedMember(Decl *D) {
   }
 }
 
+bool CXXRecordDecl::isLiteral() const {
+  const LangOptions &LangOpts = getLangOpts();
+  if (!(LangOpts.CPlusPlus20 ? hasConstexprDestructor()
+                             : hasTrivialDestructor()))
+    return false;
+
+  if (isLambda() && !LangOpts.CPlusPlus17)
+    return false;
+
+  if (hasNonLiteralTypeFieldsOrBases()) {
+    // CWG2598
+    // is an aggregate union type that has either no variant
+    // members or at least one variant member of non-volatile literal type,
+    if (!isUnion())
+      return false;
+    bool HasAtLeastOneTrivialMember =
----------------
shafik wrote:

Why use trivial here? The DRs don't refer to trivial it refers to non-volatile literal type.

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


More information about the cfe-commits mailing list