================
@@ -359,3 +359,29 @@ struct alignment { // c17-error {{redefinition of 
'alignment'}} \
                       c23-error {{type 'struct alignment' has a member with an 
attribute which currently causes the types to be treated as though they are 
incompatible}}
   int x;
 };
+
+// Both structures need to have a tag in order to be compatible within the same
+// translation unit.
+struct     {int i;} nontag;
+struct tag {int i;} tagged; // c17-note 2 {{previous definition is here}}
+
+_Static_assert(1 == _Generic(tagged, struct tag {int i;}:1, default:0)); // 
c17-error {{redefinition of 'tag'}} \
+                                                                            
c17-error {{static assertion failed}}
+_Static_assert(0 == _Generic(tagged, struct     {int i;}:1, default:0));
+_Static_assert(0 == _Generic(nontag, struct tag {int i;}:1, default:0)); // 
c17-error {{redefinition of 'tag'}}
+// That means these two structures are not actually compatible; see GH141724.
+_Static_assert(0 == _Generic(nontag, struct     {int i;}:1, default:0));
+
+struct InnerAnonStruct {
+  struct {
+    int i;
+  } untagged;
+} inner_anon_tagged;
+
+_Static_assert(0 == _Generic(inner_anon_tagged.untagged, struct { int i; } : 
1, default : 0));
----------------
Fznamznon wrote:

The comment says
```
  // ... However, the paragraph
  // after the bulleted list goes on to talk about compatibility of anonymous
  // structure and union members, so this prohibition only applies to top-level
  // declarations, not members.

```
So, shouldn't that assertion give the opposite result because 
`inner_anon_tagged.untagged` is a member?


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

Reply via email to