================
@@ -359,3 +359,35 @@ 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));
+
+// Also test the behavior within a function (so the declaration context is not
+// at the translation unit level).
+void nontag_func_test(void) {
----------------
erichkeane wrote:

Actually, can we get one in a parameter list as well?  
```
void func(struct {int i; } Arg1, struct {int i; } Arg2) {
  _Static_assert(0 == _Generic(typeof(Arg1), typeof(Arg2) : 1, default : 0);
}
```

I THINK that should be zero as well?

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