diff options
author | Joseph Myers <joseph@codesourcery.com> | 2010-05-15 20:07:01 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2010-05-15 20:07:01 +0100 |
commit | 4bdd0a60b27aa25d23cc19e4ab23163edf1a363b (patch) | |
tree | 58437182e5b92c32014bc05c7c720abea38f88b9 /gcc/testsuite/gcc.dg/c1x-anon-struct-1.c | |
parent | d025732d199d5fda6718e4e52661ae027421a5b4 (diff) | |
download | gcc-4bdd0a60b27aa25d23cc19e4ab23163edf1a363b.zip gcc-4bdd0a60b27aa25d23cc19e4ab23163edf1a363b.tar.gz gcc-4bdd0a60b27aa25d23cc19e4ab23163edf1a363b.tar.bz2 |
c-decl.c (grokfield): Allow typedefs for anonymous structs and unions by default if...
* c-decl.c (grokfield): Allow typedefs for anonymous structs and
unions by default if those structs and unions have no tags. Do
not condition anonymous struct and unions handling on flag_iso.
Allow anonymous structs and unions for C1X.
(finish_struct): Do not diagnose lack of named fields when
anonymous structs and unions present for C1X. Accept flexible
array members in structure with anonymous structs or unions but no
directly named fields.
* doc/extend.texi (Unnamed Fields): Update.
testsuite:
* gcc.dg/c1x-anon-struct-1.c, gcc.dg/c1x-anon-struct-2.c,
gcc.dg/c90-anon-struct-1.c, gcc.dg/c99-anon-struct-1.c: New tests.
* gcc.dg/20080820.c, gcc.dg/anon-struct-1.c: Update expected
diagnostics and type sizes.
From-SVN: r159439
Diffstat (limited to 'gcc/testsuite/gcc.dg/c1x-anon-struct-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/c1x-anon-struct-1.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/c1x-anon-struct-1.c b/gcc/testsuite/gcc.dg/c1x-anon-struct-1.c new file mode 100644 index 0000000..711fe65 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c1x-anon-struct-1.c @@ -0,0 +1,73 @@ +/* Test for anonymous structures and unions in C1X. */ +/* { dg-do compile } */ +/* { dg-options "-std=c1x -pedantic-errors" } */ + +#include <stddef.h> + +typedef struct +{ + int i; +} s0; + +typedef union +{ + int i; +} u0; + +struct s1 +{ + int a; + u0; + struct + { + int b; + }; +}; + +union u1 +{ + int b; + s0; + union + { + int c; + }; +}; + +struct s2 +{ + struct + { + int a; + }; +}; + +struct s3 +{ + u0; +}; + +struct s4 +{ + struct + { + int i; + }; + int a[]; +}; + +struct s1 x = + { + .b = 1, + .i = 2, + .a = 3 + }; + +int o = offsetof (struct s1, i); + +void +f (void) +{ + x.i = 3; + (&x)->i = 4; +} |