aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2011-03-18 21:16:31 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2011-03-18 21:16:31 +0000
commitff8e21599213bbea6ccacecf2522ad19836c8fd1 (patch)
tree080d7b0817fada736ec3b580f8573b09cf4c52d1 /gcc/testsuite
parent16cc44407fe40e3411e206eeec60a14d20769ade (diff)
downloadgcc-ff8e21599213bbea6ccacecf2522ad19836c8fd1.zip
gcc-ff8e21599213bbea6ccacecf2522ad19836c8fd1.tar.gz
gcc-ff8e21599213bbea6ccacecf2522ad19836c8fd1.tar.bz2
c-decl.c (grokfield): Don't allow typedefs for structures or unions with no tag by default.
* c-decl.c (grokfield): Don't allow typedefs for structures or unions with no tag by default. * doc/extend.texi (Unnamed Fields): Update. testsuite: * gcc.dg/c1x-anon-struct-1.c: Don't test use of typedefs. * gcc.dg/c1x-anon-struct-3.c: New test. * gcc.dg/anon-struct-11.c: Update. From-SVN: r171170
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/anon-struct-11.c4
-rw-r--r--gcc/testsuite/gcc.dg/c1x-anon-struct-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/c1x-anon-struct-3.c34
4 files changed, 54 insertions, 15 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5c39684..3cda22b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-18 Joseph Myers <joseph@codesourcery.com>
+
+ * gcc.dg/c1x-anon-struct-1.c: Don't test use of typedefs.
+ * gcc.dg/c1x-anon-struct-3.c: New test.
+ * gcc.dg/anon-struct-11.c: Update.
+
2011-03-18 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/vect/slp-multitypes-2.c: Replace dg-do run with
diff --git a/gcc/testsuite/gcc.dg/anon-struct-11.c b/gcc/testsuite/gcc.dg/anon-struct-11.c
index 1084e5b..c2f85fc 100644
--- a/gcc/testsuite/gcc.dg/anon-struct-11.c
+++ b/gcc/testsuite/gcc.dg/anon-struct-11.c
@@ -50,7 +50,7 @@ struct E {
struct F { char f; }; /* { dg-warning "does not declare anything" } */
char c;
union {
- D;
+ D; /* { dg-warning "does not declare anything" } */
};
char e;
};
@@ -85,7 +85,7 @@ test2 (void)
e.e = 5;
f2 (&e); /* { dg-warning "incompatible pointer type" } */
f3 (&e); /* { dg-warning "incompatible pointer type" } */
- if (e.d != 4)
+ if (e.d != 4) /* { dg-error "no member" } */
abort ();
if (e.f != 6) /* { dg-error "no member" } */
abort ();
diff --git a/gcc/testsuite/gcc.dg/c1x-anon-struct-1.c b/gcc/testsuite/gcc.dg/c1x-anon-struct-1.c
index 711fe65..6d4b433 100644
--- a/gcc/testsuite/gcc.dg/c1x-anon-struct-1.c
+++ b/gcc/testsuite/gcc.dg/c1x-anon-struct-1.c
@@ -4,20 +4,13 @@
#include <stddef.h>
-typedef struct
-{
- int i;
-} s0;
-
-typedef union
-{
- int i;
-} u0;
-
struct s1
{
int a;
- u0;
+ union
+ {
+ int i;
+ };
struct
{
int b;
@@ -27,7 +20,10 @@ struct s1
union u1
{
int b;
- s0;
+ struct
+ {
+ int i;
+ };
union
{
int c;
@@ -44,7 +40,10 @@ struct s2
struct s3
{
- u0;
+ union
+ {
+ int i;
+ };
};
struct s4
diff --git a/gcc/testsuite/gcc.dg/c1x-anon-struct-3.c b/gcc/testsuite/gcc.dg/c1x-anon-struct-3.c
new file mode 100644
index 0000000..1841edd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c1x-anon-struct-3.c
@@ -0,0 +1,34 @@
+/* Test for anonymous structures and unions in C1X. Test for invalid
+ cases: typedefs disallowed by N1549. */
+/* { dg-do compile } */
+/* { dg-options "-std=c1x -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;
+ };
+};