[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
================
@@ -208,3 +208,54 @@ namespace dr2565 { // dr2565: 16 open
#endif
}
+
+
+namespace dr2598 { // dr2598: 18
+#if __cplusplus >= 201103L
+struct NonLiteral {
+ NonLiteral();
+};
+
+struct anonymous1 {
+ union {} a;
+};
+static_assert(__is_literal(anonymous1), "");
+
+struct anonymous2 {
+ union { char c; };
+};
+static_assert(__is_literal(anonymous2), "");
+
+struct anonymous3 {
+ union { char c; NonLiteral NL; };
+};
+static_assert(__is_literal(anonymous3), "");
+
+struct anonymous4 {
+ union { NonLiteral NL; };
+};
+static_assert(!__is_literal(anonymous4), "");
+
+union empty {};
+static_assert(__is_literal(empty), "");
+
+union union1 { char c; };
+static_assert(__is_literal(union1), "");
+
+union union2 { char c; NonLiteral NL;};
+static_assert(__is_literal(union2), "");
+
+union union3 { NonLiteral NL;};
+static_assert(!__is_literal(union3), "");
+
+union union4 { union4(); };
+static_assert(!__is_literal(union4), "");
+
+union union5 { static NonLiteral NL; };
+static_assert(__is_literal(union5), "");
+
+struct Literal { constexpr Literal() {} };
+union union6 { NonLiteral NL; Literal L; };
----------------
shafik wrote:
Can we also include the exact example from CWG2598 as well, just to be complete.
https://github.com/llvm/llvm-project/pull/78195
More information about the cfe-commits
mailing list