re PR c++/29024 (storage class specifier accepted for typedef (clause 7.1.1 ; 1))

PR c++/29024
        * cp-tree (struct cp_decl_specifier_seq): Rename to 
        conflicting_specifiers_p
        * parser.c (cp_parser_set_storage_class): Set
        conflicting_specifiers_p for the input decl specifier 
        if a typedef specifier is present. Rename uses of
        multiple_specifiers_p to conflicting_specifiers_p.
        (cp_parser_decl_specifier_seq) <RID_TYPEDEF>: If a storage 
        class specifier has already been set for this declaration, 
        set conflicting_specifiers_p to true on the decl_specs.
        * decl.c (grokdeclarator): Rename uses of
        multiple_specifiers_p to conflicting_specifiers_p.

        * g++.dg/parse/typedef8.C: New test.
        * g++.dg/other/mult-stor1.C: Adjust error markers.

From-SVN: r117641
This commit is contained in:
Lee Millward 2006-10-11 19:31:33 +00:00 committed by Lee Millward
parent 377d569bdb
commit 2610654299
7 changed files with 44 additions and 6 deletions

View File

@ -1,3 +1,18 @@
2006-10-11 Lee Millward <lee.millward@codesourcery.com>
PR c++/29024
* cp-tree (struct cp_decl_specifier_seq): Rename to
conflicting_specifiers_p
* parser.c (cp_parser_set_storage_class): Set
conflicting_specifiers_p for the input decl specifier
if a typedef specifier is present. Rename uses of
multiple_specifiers_p to conflicting_specifiers_p.
(cp_parser_decl_specifier_seq) <RID_TYPEDEF>: If a storage
class specifier has already been set for this declaration,
set conflicting_specifiers_p to true on the decl_specs.
* decl.c (grokdeclarator): Rename uses of
multiple_specifiers_p to conflicting_specifiers_p.
2006-10-10 Brooks Moses <bmoses@stanford.edu>
* Make-lang.in: Added "c++.pdf" target support.

View File

@ -3655,8 +3655,9 @@ typedef struct cp_decl_specifier_seq {
decl-specifier-seq. */
BOOL_BITFIELD multiple_types_p : 1;
/* True iff multiple storage classes were (erroneously) specified
for this decl-specifier-seq. */
BOOL_BITFIELD multiple_storage_classes_p : 1;
for this decl-specifier-seq or a combination of a storage class
with a typedef specifier. */
BOOL_BITFIELD conflicting_specifiers_p : 1;
/* True iff at least one decl-specifier was found. */
BOOL_BITFIELD any_specifiers_p : 1;
/* True iff "int" was explicitly provided. */

View File

@ -7402,9 +7402,9 @@ grokdeclarator (const cp_declarator *declarator,
/* Warn about storage classes that are invalid for certain
kinds of declarations (parameters, typenames, etc.). */
if (declspecs->multiple_storage_classes_p)
if (declspecs->conflicting_specifiers_p)
{
error ("multiple storage classes in declaration of %qs", name);
error ("conflicting specifiers in declaration of %qs", name);
storage_class = sc_none;
}
else if (thread_p

View File

@ -7493,6 +7493,9 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
/* The "typedef" keyword can only occur in a declaration; we
may as well commit at this point. */
cp_parser_commit_to_tentative_parse (parser);
if (decl_specs->storage_class != sc_none)
decl_specs->conflicting_specifiers_p = true;
break;
/* storage-class-specifier:
@ -16193,7 +16196,7 @@ cp_parser_set_storage_class (cp_parser *parser,
}
else if (decl_specs->storage_class != sc_none)
{
decl_specs->multiple_storage_classes_p = true;
decl_specs->conflicting_specifiers_p = true;
return;
}
@ -16225,6 +16228,13 @@ cp_parser_set_storage_class (cp_parser *parser,
gcc_unreachable ();
}
decl_specs->storage_class = storage_class;
/* A storage class specifier cannot be applied alongside a typedef
specifier. If there is a typedef specifier present then set
conflicting_specifiers_p which will trigger an error later
on in grokdeclarator. */
if (decl_specs->specs[(int)ds_typedef])
decl_specs->conflicting_specifiers_p = true;
}
/* Update the DECL_SPECS to reflect the TYPE_SPEC. If USER_DEFINED_P

View File

@ -1,3 +1,9 @@
2006-10-11 Lee Millward <lee.millward@codesourcery.com>
PR c++/29024
* g++.dg/parse/typedef8.C: New test.
* g++.dg/other/mult-stor1.C: Adjust error markers.
2006-10-11 Richard Guenther <rguenther@suse.de>
PR tree-optimization/28230

View File

@ -4,5 +4,5 @@
struct A
{
extern static int i; // { dg-error "multiple storage classes" }
extern static int i; // { dg-error "conflicting specifiers" }
};

View File

@ -0,0 +1,6 @@
//PR c++ 29024
typedef static int a; // { dg-error "conflicting" }
typedef register int b; // { dg-error "conflicting" }
typedef extern int c; // { dg-error "conflicting" }
static typedef int a; // { dg-error "conflicting" }