summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/declspec-6.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-09 01:25:48 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-09 01:25:48 +0000
commit9553111d52cbe9f5dcfcc65e2a251d9e7803e521 (patch)
tree9281b8a84cb7f58197f54b2a640390953626fb55 /gcc/testsuite/gcc.dg/declspec-6.c
parentac206aff0574a7d02a44278c0ab08420efa6fca8 (diff)
downloadgcc-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-6.c')
-rw-r--r--gcc/testsuite/gcc.dg/declspec-6.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/declspec-6.c b/gcc/testsuite/gcc.dg/declspec-6.c
new file mode 100644
index 00000000000..91a5d82b842
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/declspec-6.c
@@ -0,0 +1,41 @@
+/* Test declaration specifiers. Test empty declarations. Test with
+ -pedantic-errors. */
+/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
+/* { dg-do compile } */
+/* { dg-options "-pedantic-errors" } */
+
+/* If a declaration does not declare a declarator, it must declare a
+ tag or the members of an enumeration, and must only contain one
+ type specifier. */
+
+typedef int T;
+
+struct s0;
+union u0;
+enum e0; /* { dg-error "error: ISO C forbids forward references" } */
+enum { E0 };
+enum e1 { E1 };
+
+/* Not declaring anything (pedwarns). */
+struct { int a; }; /* { dg-error "error: unnamed struct/union that defines no instances" } */
+int; /* { dg-error "error: useless type name in empty declaration" } */
+long; /* { dg-warning "warning: useless keyword or type name in empty declaration" } */
+/* { dg-error "error: empty declaration" "long" { target *-*-* } 22 } */
+T; /* { dg-error "error: useless type name in empty declaration" } */
+static const; /* { dg-warning "warning: useless keyword or type name in empty declaration" } */
+/* { dg-error "error: empty declaration" "long" { target *-*-* } 25 } */
+union { long b; }; /* { dg-error "error: unnamed struct/union that defines no instances" } */
+
+/* Multiple type names (errors). */
+struct s1 int; /* { dg-error "error: two or more data types in declaration specifiers" } */
+char union u1; /* { dg-error "error: two or more data types in declaration specifiers" } */
+/* { dg-error "error: useless type name in empty declaration" "char union" { target *-*-* } 31 } */
+double enum { E2 }; /* { dg-error "error: two or more data types in declaration specifiers" } */
+/* { dg-error "error: useless type name in empty declaration" "double enum" { target *-*-* } 33 } */
+T struct s2; /* { dg-error "error: two or more data types in declaration specifiers" } */
+/* { dg-error "error: useless type name in empty declaration" "T struct" { target *-*-* } 35 } */
+long union u2; /* { dg-error "error: long, short, signed, unsigned or complex used invalidly in empty declaration" } */
+struct s3 short; /* { dg-error "error: long, short, signed, unsigned or complex used invalidly in empty declaration" } */
+union u3 signed; /* { dg-error "error: long, short, signed, unsigned or complex used invalidly in empty declaration" } */
+unsigned struct s4; /* { dg-error "error: long, short, signed, unsigned or complex used invalidly in empty declaration" } */
+_Complex enum { E3 }; /* { dg-error "error: long, short, signed, unsigned or complex used invalidly in empty declaration" } */