Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/gcc.dg/c11-anon-struct-1.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/gcc.dg/c11-anon-struct-1.c Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,72 @@ +/* Test for anonymous structures and unions in C11. */ +/* { dg-do compile } */ +/* { dg-options "-std=c11 -pedantic-errors" } */ + +#include <stddef.h> + +struct s1 +{ + int a; + union + { + int i; + }; + struct + { + int b; + }; +}; + +union u1 +{ + int b; + struct + { + int i; + }; + union + { + int c; + }; +}; + +struct s2 +{ + struct + { + int a; + }; +}; + +struct s3 +{ + union + { + int i; + }; +}; + +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; +}