--- /dev/null
+/* Test initialization of anonymous structures and unions (clarified in C2y by
+ N3451). */
+/* { dg-do run } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+struct s { struct { int a, b; }; union { int c; }; } x = { 1, 2, 3 };
+union u { struct { int x, y; }; };
+
+struct s a = { 1, 2, 3 };
+union u b = { 4, 5 };
+
+extern void abort ();
+extern void exit (int);
+
+int
+main ()
+{
+ if (a.a != 1 || a.b != 2 || a.c != 3)
+ abort ();
+ if (b.x != 4 || b.y != 5)
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* Test member access to incomplete structures and unions (explicit constraint
+ violation in C2y). */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+struct s1;
+extern struct s1 vs1;
+struct s1 { int a; int b : sizeof (vs1.a); }; /* { dg-error "invalid use of undefined type" } */
+/* { dg-error "width not an integer constant" "constant" { target *-*-* } .-1 } */
+
+union u1;
+extern union u1 vu1;
+union u1 { int a; int b : sizeof (vu1.a); }; /* { dg-error "invalid use of undefined type" } */
+/* { dg-error "width not an integer constant" "constant" { target *-*-* } .-1 } */
+
+struct s2;
+extern struct s2 *ps2;
+struct s2 { int a; int b : sizeof (ps2->a); }; /* { dg-error "invalid use of undefined type" } */
+/* { dg-error "width not an integer constant" "constant" { target *-*-* } .-1 } */
+
+union u2;
+extern union u2 *pu2;
+union u2 { int a; int b : sizeof (pu2->a); }; /* { dg-error "invalid use of undefined type" } */
+/* { dg-error "width not an integer constant" "constant" { target *-*-* } .-1 } */
--- /dev/null
+/* Test mixing internal and external linker for the same identifier (a
+ constraint violation in C2y). */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+static int x;
+
+void
+f ()
+{
+ long x;
+ {
+ extern int x; /* { dg-error "variable previously declared 'static' redeclared 'extern'" } */
+ }
+}
--- /dev/null
+/* Test mixing internal and external linker for the same identifier (a
+ constraint violation in C2y). */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+void
+f ()
+{
+ extern int x; /* { dg-message "previous declaration" } */
+}
+
+static int x; /* { dg-error "static declaration of 'x' follows non-static declaration" } */
--- /dev/null
+/* Test mixing internal and external linker for the same identifier (a
+ constraint violation in C2y). */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+static int x ();
+
+void
+f ()
+{
+ long x;
+ {
+ extern int x (); /* { dg-error "function previously declared 'static' redeclared 'extern'" } */
+ }
+}
--- /dev/null
+/* Test mixing internal and external linker for the same identifier (a
+ constraint violation in C2y). */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+void
+f ()
+{
+ extern int x (); /* { dg-message "previous declaration" } */
+}
+
+static int x (); /* { dg-error "static declaration of 'x' follows non-static declaration" } */
--- /dev/null
+/* Test C2y static assertions with expressions that are not integer constant
+ expressions (taken from c11-static-assert-3.c; in C2y these are constraint
+ violations, whereas in C11 we diagnose them but they are undefined behavior
+ because the requirement to be an integer constant expression is in Semantics
+ not Constraints). */
+/* { dg-do compile } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+_Static_assert (__INT_MAX__ * 2, "overflow"); /* { dg-warning "integer overflow in expression" } */
+/* { dg-error "overflow in constant expression" "error" { target *-*-* } .-1 } */
+
+_Static_assert ((void *)(__SIZE_TYPE__)16, "non-integer"); /* { dg-error "not an integer" } */
+
+_Static_assert (1.0, "non-integer"); /* { dg-error "not an integer" } */
+
+_Static_assert ((int)(1.0 + 1.0), "non-constant-expression"); /* { dg-error "not an integer constant expression" } */
+
+int i;
+
+_Static_assert (i, "non-constant"); /* { dg-error "not constant" } */