Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/gcc.dg/c2x-attr-syntax-3.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/gcc.dg/c2x-attr-syntax-3.c Thu Feb 13 11:34:05 2020 +0900 @@ -0,0 +1,56 @@ +/* Test C2x attribute syntax. Invalid uses of attributes. */ +/* { dg-do compile } */ +/* { dg-options "-std=c2x -pedantic-errors" } */ + +/* Prefix attributes not allowed on declarations without declarators. */ + +[[]] struct s { int a; }; /* { dg-error "empty declaration" } */ + +[[]] union u { int a; }; /* { dg-error "empty declaration" } */ + +void +f1 (void) +{ + [[]] struct t { int a; }; /* { dg-error "empty declaration" } */ +} + +/* Prefix attributes not allowed on _Static_assert. */ + +[[]] _Static_assert (1); /* { dg-error "expected" } */ + +void +f2 (void) +{ + [[]] _Static_assert (1); /* { dg-error "expected" } */ +} + +/* Declarations, including attribute declarations, cannot appear after + labels. */ + +void +f3 (void) +{ + x: [[]];; /* { dg-error "can only be part of a statement" } */ +} + +/* Prefix attributes cannot appear on type names. */ + +int z = sizeof ([[]] int); /* { dg-error "expected" } */ + +/* Attributes are not allowed after struct, union or enum, except when + the type contents are being defined or the declaration is just + "struct-or-union atribute-specifier-sequence identifier;". */ + +const struct [[]] s2; /* { dg-warning "useless type qualifier" } */ +/* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */ + +const union [[]] u2; /* { dg-warning "useless type qualifier" } */ +/* { dg-error "invalid use of attributes in empty declaration" "invalid" { target *-*-* } .-1 } */ + +struct [[]] s3 *sv; /* { dg-error "expected" } */ + +union [[]] u3 *uv; /* { dg-error "expected" } */ + +enum e { E1 }; + +enum [[]] e *ev; /* { dg-error "expected" } */