Commit 75a82978 by Mark Mitchell Committed by Mark Mitchell

re PR c++/27884 (bogus error: invalid use of 'register' in linkage specification)

	PR c++/27884
	* decl.c (have_extern_spec): Remove.
	(start_decl): Do not check have_extern_spec.
	(start_function): Likewise.
	* cp-tree.h (have_extern_spec): Remove.
	* parser.c (cp_parser_linkage_specification): Don't set
	have_extern_spec.
	(cp_parser_init_declarator): Likewise.
	(cp_parser_parameter_declaration): Do not treat parameters as
	within the scope of an unbraced linkage specification.
	PR c++/27884
	* g++.dg/parse/linkage2.C: New test

From-SVN: r114727
parent 04879af3
2006-06-16 Mark Mitchell <mark@codesourcery.com>
PR c++/27884
* decl.c (have_extern_spec): Remove.
(start_decl): Do not check have_extern_spec.
(start_function): Likewise.
* cp-tree.h (have_extern_spec): Remove.
* parser.c (cp_parser_linkage_specification): Don't set
have_extern_spec.
(cp_parser_init_declarator): Likewise.
(cp_parser_parameter_declaration): Do not treat parameters as
within the scope of an unbraced linkage specification.
2006-06-15 Mark Mitchell <mark@codesourcery.com> 2006-06-15 Mark Mitchell <mark@codesourcery.com>
PR c++/27689 PR c++/27689
......
...@@ -3943,8 +3943,6 @@ extern void initialize_artificial_var (tree, tree); ...@@ -3943,8 +3943,6 @@ extern void initialize_artificial_var (tree, tree);
extern tree check_var_type (tree, tree); extern tree check_var_type (tree, tree);
extern tree reshape_init (tree, tree); extern tree reshape_init (tree, tree);
extern bool have_extern_spec;
/* in decl2.c */ /* in decl2.c */
extern bool check_java_method (tree); extern bool check_java_method (tree);
extern tree build_memfn_type (tree, tree, cp_cv_quals); extern tree build_memfn_type (tree, tree, cp_cv_quals);
......
...@@ -240,10 +240,6 @@ enum deprecated_states { ...@@ -240,10 +240,6 @@ enum deprecated_states {
static enum deprecated_states deprecated_state = DEPRECATED_NORMAL; static enum deprecated_states deprecated_state = DEPRECATED_NORMAL;
/* True if a declaration with an `extern' linkage specifier is being
processed. */
bool have_extern_spec;
/* A TREE_LIST of VAR_DECLs. The TREE_PURPOSE is a RECORD_TYPE or /* A TREE_LIST of VAR_DECLs. The TREE_PURPOSE is a RECORD_TYPE or
UNION_TYPE; the TREE_VALUE is a VAR_DECL with that type. At the UNION_TYPE; the TREE_VALUE is a VAR_DECL with that type. At the
...@@ -3814,13 +3810,6 @@ start_decl (const cp_declarator *declarator, ...@@ -3814,13 +3810,6 @@ start_decl (const cp_declarator *declarator,
*pushed_scope_p = NULL_TREE; *pushed_scope_p = NULL_TREE;
/* This should only be done once on the top most decl. */
if (have_extern_spec)
{
declspecs->storage_class = sc_extern;
have_extern_spec = false;
}
/* An object declared as __attribute__((deprecated)) suppresses /* An object declared as __attribute__((deprecated)) suppresses
warnings of uses of other deprecated items. */ warnings of uses of other deprecated items. */
if (lookup_attribute ("deprecated", attributes)) if (lookup_attribute ("deprecated", attributes))
...@@ -10632,13 +10621,6 @@ start_function (cp_decl_specifier_seq *declspecs, ...@@ -10632,13 +10621,6 @@ start_function (cp_decl_specifier_seq *declspecs,
{ {
tree decl1; tree decl1;
if (have_extern_spec)
{
declspecs->storage_class = sc_extern;
/* This should only be done once on the outermost decl. */
have_extern_spec = false;
}
decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs); decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, &attrs);
/* If the declarator is not suitable for a function definition, /* If the declarator is not suitable for a function definition,
cause a syntax error. */ cause a syntax error. */
......
...@@ -7732,9 +7732,7 @@ cp_parser_linkage_specification (cp_parser* parser) ...@@ -7732,9 +7732,7 @@ cp_parser_linkage_specification (cp_parser* parser)
saved_in_unbraced_linkage_specification_p saved_in_unbraced_linkage_specification_p
= parser->in_unbraced_linkage_specification_p; = parser->in_unbraced_linkage_specification_p;
parser->in_unbraced_linkage_specification_p = true; parser->in_unbraced_linkage_specification_p = true;
have_extern_spec = true;
cp_parser_declaration (parser); cp_parser_declaration (parser);
have_extern_spec = false;
parser->in_unbraced_linkage_specification_p parser->in_unbraced_linkage_specification_p
= saved_in_unbraced_linkage_specification_p; = saved_in_unbraced_linkage_specification_p;
} }
...@@ -11063,10 +11061,7 @@ cp_parser_init_declarator (cp_parser* parser, ...@@ -11063,10 +11061,7 @@ cp_parser_init_declarator (cp_parser* parser,
if (!member_p) if (!member_p)
{ {
if (parser->in_unbraced_linkage_specification_p) if (parser->in_unbraced_linkage_specification_p)
{ decl_specifiers->storage_class = sc_extern;
decl_specifiers->storage_class = sc_extern;
have_extern_spec = false;
}
decl = start_decl (declarator, decl_specifiers, decl = start_decl (declarator, decl_specifiers,
is_initialized, attributes, prefix_attributes, is_initialized, attributes, prefix_attributes,
&pushed_scope); &pushed_scope);
...@@ -12119,9 +12114,16 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error) ...@@ -12119,9 +12114,16 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error)
{ {
cp_parameter_declarator *parameters = NULL; cp_parameter_declarator *parameters = NULL;
cp_parameter_declarator **tail = &parameters; cp_parameter_declarator **tail = &parameters;
bool saved_in_unbraced_linkage_specification_p;
/* Assume all will go well. */ /* Assume all will go well. */
*is_error = false; *is_error = false;
/* The special considerations that apply to a function within an
unbraced linkage specifications do not apply to the parameters
to the function. */
saved_in_unbraced_linkage_specification_p
= parser->in_unbraced_linkage_specification_p;
parser->in_unbraced_linkage_specification_p = false;
/* Look for more parameters. */ /* Look for more parameters. */
while (true) while (true)
...@@ -12200,6 +12202,9 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error) ...@@ -12200,6 +12202,9 @@ cp_parser_parameter_declaration_list (cp_parser* parser, bool *is_error)
} }
} }
parser->in_unbraced_linkage_specification_p
= saved_in_unbraced_linkage_specification_p;
return parameters; return parameters;
} }
......
2006-06-16 Mark Mitchell <mark@codesourcery.com>
PR c++/27884
* g++.dg/parse/linkage2.C: New test
2006-06-16 Richard Guenther <rguenther@suse.de> 2006-06-16 Richard Guenther <rguenther@suse.de>
PR middle-end/27116 PR middle-end/27116
// PR c++/27884
extern "C" void foo(register int *my_perl);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment