diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-09 01:25:48 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-09 01:25:48 +0000 |
commit | 9553111d52cbe9f5dcfcc65e2a251d9e7803e521 (patch) | |
tree | 9281b8a84cb7f58197f54b2a640390953626fb55 /gcc/testsuite/gcc.dg/declspec-3.c | |
parent | ac206aff0574a7d02a44278c0ab08420efa6fca8 (diff) | |
download | gcc-9553111d52cbe9f5dcfcc65e2a251d9e7803e521.tar.gz |
PR c/8420
* c-tree.h (struct c_declspecs): New.
(struct c_declarator, struct c_type_name, struct c_parm): Update
element types.
(build_array_declarator, grokfield, shadow_tag, shadow_tag_warned,
start_function, start_decl, build_c_parm,
make_pointer_declarator): Update prototypes.
(build_null_declspecs, declspecs_add_qual, declspecs_add_type,
declspecs_add_scspec, declspecs_add_attrs): New.
(split_specs_attrs): Remove.
* c-parse.in (%union): Add dsptype.
(declspecs_nosc_nots_nosa_noea, declspecs_nosc_nots_nosa_ea,
declspecs_nosc_nots_sa_noea, declspecs_nosc_nots_sa_ea,
declspecs_nosc_ts_nosa_noea, declspecs_nosc_ts_nosa_ea,
declspecs_nosc_ts_sa_noea, declspecs_nosc_ts_sa_ea,
declspecs_sc_nots_nosa_noea, declspecs_sc_nots_nosa_ea,
declspecs_sc_nots_sa_noea, declspecs_sc_nots_sa_ea,
declspecs_sc_ts_nosa_noea, declspecs_sc_ts_nosa_ea,
declspecs_sc_ts_sa_noea, declspecs_sc_ts_sa_ea, declspecs_ts,
declspecs_nots, declspecs_ts_nosa, declspecs_nots_nosa,
declspecs_nosc_ts, declspecs_nosc_nots, declspecs_nosc, declspecs,
maybe_type_quals_attrs): Change to dsptype.
(struct c_declspec_stack): New.
(current_declspecs, declspec_stack): Change type.
(PUSH_DECLSPEC_STACK, POP_DECLSPEC_STACK): Update to new
structures.
(extdefs): Likewise.
(setspecs): Likewise.
(fndef): Use current_declspecs for empty declspecs list.
(declspecs_nosc_nots_nosa_noea, declspecs_nosc_nots_nosa_ea,
declspecs_nosc_nots_sa_noea, declspecs_nosc_nots_sa_ea,
declspecs_nosc_ts_nosa_noea, declspecs_nosc_ts_nosa_ea,
declspecs_nosc_ts_sa_noea, declspecs_nosc_ts_sa_ea,
declspecs_sc_nots_nosa_noea, declspecs_sc_nots_nosa_ea,
declspecs_sc_nots_sa_noea, declspecs_sc_nots_sa_ea,
declspecs_sc_ts_nosa_noea, declspecs_sc_ts_nosa_ea,
declspecs_sc_ts_sa_noea, declspecs_sc_ts_sa_ea): Update to new
structures and helper functions. Update comments.
(typespec_nonattr): Correct comment.
(maybe_type_quals_attrs, typename): Update to new structures.
* c-decl.c (grokdeclarator, build_array_declarator, grokfield,
shadow_tag, shadow_tag_warned, start_function, start_decl,
build_c_parm, make_pointer_declarator,
set_array_declarator_inner, groktypename): Update to new
structures.
(build_null_declspecs, declspecs_add_qual, declspecs_add_type,
declspecs_add_scspec, declspecs_add_attrs): New.
(split_specs_attrs): Remove.
(shadow_tag_warned): Make warning for useless type names a
pedwarn. Give hard error for long, short, signed, unsigned or
_Complex used with struct, union or enum in empty declaration.
Make found_tag a bool.
(grokdeclarator): Remove checks now done at parse time.
testsuite:
* gcc.dg/anon-struct-4.c, gcc.dg/declspec-1.c,
gcc.dg/declspec-2.c, gcc.dg/declspec-3.c, gcc.dg/declspec-4.c,
gcc.dg/declspec-5.c, gcc.dg/declspec-6.c,
gcc.dg/long-long-typespec-1.c: New tests.
* gcc.dg/tls/diag-2.c: Update expected diagnostics
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87218 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/declspec-3.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/declspec-3.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/declspec-3.c b/gcc/testsuite/gcc.dg/declspec-3.c new file mode 100644 index 00000000000..19b1fa257c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/declspec-3.c @@ -0,0 +1,34 @@ +/* Test declaration specifiers. Test diagnosis of storage class + specifiers not at start. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-W" } */ + +static int x0; +int static x1; /* { dg-warning "not at beginning" } */ + +extern int x2; +int extern x3; /* { dg-warning "not at beginning" } */ + +typedef int x4; +int typedef x5; /* { dg-warning "not at beginning" } */ + +void g (int); + +void +f (void) +{ + auto int x6 = 0; + int auto x7 = 0; /* { dg-warning "not at beginning" } */ + register int x8 = 0; + int register x9 = 0; /* { dg-warning "not at beginning" } */ + g (x6 + x7 + x8 + x9); +} + +const static int x10; /* { dg-warning "not at beginning" } */ + +/* Attributes are OK before storage class specifiers, since some + attributes are like such specifiers themselves. */ + +__attribute__((format(printf, 1, 2))) static void h (const char *, ...); +__attribute__((format(printf, 1, 2))) void static i (const char *, ...); /* { dg-warning "not at beginning" } */ |