Commit 15c7fb9c by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (unqualified_name_lookup_error): Declare it.

	* cp-tree.h (unqualified_name_lookup_error): Declare it.
	(begin_function_definition): Adjust prototype.
	* lex.c (unqualified_name_lookup_error): New function, split out
	from ...
	(do_identifier): ... here.
	* parse.y (parse_begin_function_definition): New function.
	(fn.def1): Use it.
	* semantics.c (begin_function_definition): Accept decl-specifiers
	and attributes as separate parameters.

From-SVN: r55372
parent ae3aa00d
2002-07-10 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (unqualified_name_lookup_error): Declare it.
(begin_function_definition): Adjust prototype.
* lex.c (unqualified_name_lookup_error): New function, split out
from ...
(do_identifier): ... here.
* parse.y (parse_begin_function_definition): New function.
(fn.def1): Use it.
* semantics.c (begin_function_definition): Accept decl-specifiers
and attributes as separate parameters.
2002-07-10 Jason Merrill <jason@redhat.com> 2002-07-10 Jason Merrill <jason@redhat.com>
PR c++/6255 PR c++/6255
......
...@@ -4062,6 +4062,7 @@ extern void note_got_semicolon PARAMS ((tree)); ...@@ -4062,6 +4062,7 @@ extern void note_got_semicolon PARAMS ((tree));
extern void note_list_got_semicolon PARAMS ((tree)); extern void note_list_got_semicolon PARAMS ((tree));
extern void do_pending_lang_change PARAMS ((void)); extern void do_pending_lang_change PARAMS ((void));
extern void see_typename PARAMS ((void)); extern void see_typename PARAMS ((void));
extern void unqualified_name_lookup_error PARAMS ((tree));
extern tree do_identifier PARAMS ((tree, int, tree)); extern tree do_identifier PARAMS ((tree, int, tree));
extern tree do_scoped_id PARAMS ((tree, tree)); extern tree do_scoped_id PARAMS ((tree, tree));
extern tree identifier_typedecl_value PARAMS ((tree)); extern tree identifier_typedecl_value PARAMS ((tree));
...@@ -4285,7 +4286,7 @@ extern tree finish_fname (tree); ...@@ -4285,7 +4286,7 @@ extern tree finish_fname (tree);
extern void save_type_access_control PARAMS ((tree)); extern void save_type_access_control PARAMS ((tree));
extern void reset_type_access_control PARAMS ((void)); extern void reset_type_access_control PARAMS ((void));
extern void decl_type_access_control PARAMS ((tree)); extern void decl_type_access_control PARAMS ((tree));
extern int begin_function_definition PARAMS ((tree, tree)); extern int begin_function_definition (tree, tree, tree);
extern tree begin_constructor_declarator PARAMS ((tree, tree)); extern tree begin_constructor_declarator PARAMS ((tree, tree));
extern tree finish_declarator PARAMS ((tree, tree, tree, tree, int)); extern tree finish_declarator PARAMS ((tree, tree, tree, tree, int));
extern void finish_translation_unit PARAMS ((void)); extern void finish_translation_unit PARAMS ((void));
......
...@@ -1125,6 +1125,40 @@ is_global (d) ...@@ -1125,6 +1125,40 @@ is_global (d)
} }
} }
/* Issue an error message indicating that the lookup of NAME (an
IDENTIFIER_NODE) failed. */
void
unqualified_name_lookup_error (tree name)
{
if (IDENTIFIER_OPNAME_P (name))
{
if (name != ansi_opname (ERROR_MARK))
error ("`%D' not defined", name);
}
else if (current_function_decl == 0)
error ("`%D' was not declared in this scope", name);
else
{
if (IDENTIFIER_NAMESPACE_VALUE (name) != error_mark_node
|| IDENTIFIER_ERROR_LOCUS (name) != current_function_decl)
{
static int undeclared_variable_notice;
error ("`%D' undeclared (first use this function)", name);
if (! undeclared_variable_notice)
{
error ("(Each undeclared identifier is reported only once for each function it appears in.)");
undeclared_variable_notice = 1;
}
}
/* Prevent repeated error messages. */
SET_IDENTIFIER_NAMESPACE_VALUE (name, error_mark_node);
SET_IDENTIFIER_ERROR_LOCUS (name, current_function_decl);
}
}
tree tree
do_identifier (token, parsing, args) do_identifier (token, parsing, args)
register tree token; register tree token;
...@@ -1175,36 +1209,10 @@ do_identifier (token, parsing, args) ...@@ -1175,36 +1209,10 @@ do_identifier (token, parsing, args)
else if (IDENTIFIER_TYPENAME_P (token)) else if (IDENTIFIER_TYPENAME_P (token))
/* A templated conversion operator might exist. */ /* A templated conversion operator might exist. */
return token; return token;
else if (IDENTIFIER_OPNAME_P (token))
{
if (token != ansi_opname (ERROR_MARK))
error ("`%D' not defined", token);
id = error_mark_node;
}
else if (current_function_decl == 0)
{
error ("`%D' was not declared in this scope", token);
id = error_mark_node;
}
else else
{ {
if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node unqualified_name_lookup_error (token);
|| IDENTIFIER_ERROR_LOCUS (token) != current_function_decl) return error_mark_node;
{
static int undeclared_variable_notice;
error ("`%D' undeclared (first use this function)", token);
if (! undeclared_variable_notice)
{
error ("(Each undeclared identifier is reported only once for each function it appears in.)");
undeclared_variable_notice = 1;
}
}
id = error_mark_node;
/* Prevent repeated error messages. */
SET_IDENTIFIER_NAMESPACE_VALUE (token, error_mark_node);
SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
} }
} }
......
...@@ -130,6 +130,7 @@ static tree parse_scoped_id PARAMS ((tree)); ...@@ -130,6 +130,7 @@ static tree parse_scoped_id PARAMS ((tree));
static tree parse_xref_tag (tree, tree, int); static tree parse_xref_tag (tree, tree, int);
static tree parse_handle_class_head (tree, tree, tree, int, int *); static tree parse_handle_class_head (tree, tree, tree, int, int *);
static void parse_decl_instantiation (tree, tree, tree); static void parse_decl_instantiation (tree, tree, tree);
static int parse_begin_function_definition (tree, tree);
/* Cons up an empty parameter list. */ /* Cons up an empty parameter list. */
static inline tree static inline tree
...@@ -856,19 +857,19 @@ constructor_declarator: ...@@ -856,19 +857,19 @@ constructor_declarator:
fn.def1: fn.def1:
typed_declspecs declarator typed_declspecs declarator
{ check_for_new_type ("return type", $1); { check_for_new_type ("return type", $1);
if (!begin_function_definition ($1.t, $2)) if (!parse_begin_function_definition ($1.t, $2))
YYERROR1; } YYERROR1; }
| declmods notype_declarator | declmods notype_declarator
{ if (!begin_function_definition ($1.t, $2)) { if (!parse_begin_function_definition ($1.t, $2))
YYERROR1; } YYERROR1; }
| notype_declarator | notype_declarator
{ if (!begin_function_definition (NULL_TREE, $1)) { if (!parse_begin_function_definition (NULL_TREE, $1))
YYERROR1; } YYERROR1; }
| declmods constructor_declarator | declmods constructor_declarator
{ if (!begin_function_definition ($1.t, $2)) { if (!parse_begin_function_definition ($1.t, $2))
YYERROR1; } YYERROR1; }
| constructor_declarator | constructor_declarator
{ if (!begin_function_definition (NULL_TREE, $1)) { if (!parse_begin_function_definition (NULL_TREE, $1))
YYERROR1; } YYERROR1; }
; ;
...@@ -4085,4 +4086,17 @@ parse_decl_instantiation (tree declspecs, tree declarator, tree storage) ...@@ -4085,4 +4086,17 @@ parse_decl_instantiation (tree declspecs, tree declarator, tree storage)
do_decl_instantiation (decl, storage); do_decl_instantiation (decl, storage);
} }
/* Like begin_function_definition, but SPECS_ATTRS is a combined list
containing both a decl-specifier-seq and attributes. */
static int
parse_begin_function_definition (tree specs_attrs, tree declarator)
{
tree specs;
tree attrs;
split_specs_attrs (specs_attrs, &specs, &attrs);
return begin_function_definition (specs, attrs, declarator);
}
#include "gt-cp-parse.h" #include "gt-cp-parse.h"
...@@ -1517,20 +1517,17 @@ reset_type_access_control () ...@@ -1517,20 +1517,17 @@ reset_type_access_control ()
current_type_lookups = NULL_TREE; current_type_lookups = NULL_TREE;
} }
/* Begin a function definition declared with DECL_SPECS and /* Begin a function definition declared with DECL_SPECS, ATTRIBUTES,
DECLARATOR. Returns non-zero if the function-declaration is and DECLARATOR. Returns non-zero if the function-declaration is
legal. */ legal. */
int int
begin_function_definition (decl_specs, declarator) begin_function_definition (decl_specs, attributes, declarator)
tree decl_specs; tree decl_specs;
tree attributes;
tree declarator; tree declarator;
{ {
tree specs; if (!start_function (decl_specs, declarator, attributes, SF_DEFAULT))
tree attrs;
split_specs_attrs (decl_specs, &specs, &attrs);
if (!start_function (specs, declarator, attrs, SF_DEFAULT))
return 0; return 0;
deferred_type_access_control (); deferred_type_access_control ();
......
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