summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c11-anon-struct-3.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/c11-anon-struct-3.c')
-rw-r--r--gcc/testsuite/gcc.dg/c11-anon-struct-3.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/c11-anon-struct-3.c b/gcc/testsuite/gcc.dg/c11-anon-struct-3.c
new file mode 100644
index 00000000000..05cc3660cb8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c11-anon-struct-3.c
@@ -0,0 +1,34 @@
+/* Test for anonymous structures and unions in C11. Test for invalid
+ cases: typedefs disallowed by N1549. */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -pedantic-errors" } */
+
+typedef struct
+{
+ int i;
+} s0;
+
+typedef union
+{
+ int i;
+} u0;
+
+struct s1
+{
+ int a;
+ u0; /* { dg-error "declaration does not declare anything" } */
+ struct
+ {
+ int b;
+ };
+};
+
+union u1
+{
+ int b;
+ s0; /* { dg-error "declaration does not declare anything" } */
+ union
+ {
+ int c;
+ };
+};