Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Paul Eggert
Sat, 01 Aug 1992 04:00
GCC 2.2.2 doesn't warn about obsolescent use of storage class
Author: Paul Eggert
Date: Sat, 01 Aug 1992 04:00
Date: Sat, 01 Aug 1992 04:00
119 lines
4174 bytes
4174 bytes
GCC 2.2.2 doesn't warn about declarations like
enum { false, true } typedef boolean;
where a storage class specifier appears somewhere other than at the beginning
of a declaration. Not only is this usage error-prone, the C Standard (section
3.9.3) says it's obsolescent. Here's a patch.
Sat Aug 1 03:24:17 1992 Paul Eggert (eggert@twinsun.com)
* c-parse.y (reserved_declspecs, declmods): Warn about storage-class
specifiers not at the start of declarations.
* (declmods_with_qual, scspecs): New grammar rules.
* invoke.texi: Document warning.
===================================================================
RCS file: RCS/invoke.texi,v
retrieving revision 2.2
diff -c -r2.2 invoke.texi
*** invoke.texi 1992/05/31 11:27:28 2.2
--- invoke.texi 1992/08/01 03:24:17
***************
*** 613,618 ****
--- 613,623 ----
@item
An unsigned value is compared against zero with @samp{>} or @samp{<=}.
+
+ @item
+ A storage-class specifier like @code{static} appears other than
+ at the beginning of a declaration. According to the C Standard,
+ this usage is obsolescent.
@end itemize
@item -Wimplicit
===================================================================
RCS file: c-parse.y,v
retrieving revision 2.2.2.1
diff -c -r2.2.2.1 c-parse.y
*** c-parse.y 1992/07/25 00:04:28 2.2.2.1
--- c-parse.y 1992/08/01 03:17:55
***************
*** 145,150 ****
--- 145,151 ----
%type <ttype> typed_declspecs reserved_declspecs
%type <ttype> typed_typespecs reserved_typespecquals
%type <ttype> declmods typespec typespecqual_reserved
+ %type <ttype> declmods_with_qual scspecs
%type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
%type <ttype> initdecls notype_initdecls initdcl notype_initdcl
%type <ttype> init initlist maybeasm
***************
*** 654,660 ****
| reserved_declspecs typespecqual_reserved
{ $$ = tree_cons (NULL_TREE, $2, $1); }
| reserved_declspecs SCSPEC
! { $$ = tree_cons (NULL_TREE, $2, $1); }
;
/* List of just storage classes and type modifiers.
--- 655,664 ----
| reserved_declspecs typespecqual_reserved
{ $$ = tree_cons (NULL_TREE, $2, $1); }
| reserved_declspecs SCSPEC
! { if (extra_warnings)
! warning ("`%s' is not at beginning of declaration",
! IDENTIFIER_POINTER ($2));
! $$ = tree_cons (NULL_TREE, $2, $1); }
;
/* List of just storage classes and type modifiers.
***************
*** 662,677 ****
to redeclare a typedef-name. */
declmods:
TYPE_QUAL
{ $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
- | SCSPEC
- { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
| declmods TYPE_QUAL
{ $$ = tree_cons (NULL_TREE, $2, $1); }
! | declmods SCSPEC
! { $$ = tree_cons (NULL_TREE, $2, $1); }
;
/* Used instead of declspecs where storage classes are not allowed
(that is, for typenames and structure components).
--- 666,693 ----
to redeclare a typedef-name. */
declmods:
+ declmods_with_qual
+ | scspecs
+ ;
+
+ declmods_with_qual:
TYPE_QUAL
{ $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
| declmods TYPE_QUAL
{ $$ = tree_cons (NULL_TREE, $2, $1); }
! | declmods_with_qual SCSPEC
! { if (extra_warnings)
! warning ("`%s' is not at beginning of declaration",
! IDENTIFIER_POINTER ($2));
! $$ = tree_cons (NULL_TREE, $2, $1); }
;
+ scspecs:
+ SCSPEC
+ { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
+ | scspecs SCSPEC
+ { $$ = tree_cons (NULL_TREE, $2, $1); }
+ ;
/* Used instead of declspecs where storage classes are not allowed
(that is, for typenames and structure components).
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads