================
@@ -77,3 +77,38 @@ namespace use_self {
 
   int fib(int n) { return FibTree{n}.v; }
 }
+
+namespace nested_union {
+  union Test1 {
+    union {
+      int inner { 42 };
+    };
+    int outer;
+  };
+  static_assert(Test1{}.inner == 42, "");
+  struct Test2 {
+    union {
+      struct {
+        int inner : 32 { 42 }; // expected-warning {{C++20 extension}}
+      };
+      int outer;
+    };
+  };
+  static_assert(Test2{}.inner == 42, "");
----------------
zygoloid wrote:

Might be useful to also test that the rest of the union member gets initialized.
```suggestion
  struct Test2 {
    union {
      struct {
        int inner : 32 { 42 }; // expected-warning {{C++20 extension}}
        int inner_no_init;
      };
      int outer;
    };
  };
  static_assert(Test2{}.inner == 42, "");
  static_assert(Test2{}.inner_no_init == 0, "");
```

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

Reply via email to