* 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
+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>
PR c++/6255
extern void note_list_got_semicolon PARAMS ((tree));
extern void do_pending_lang_change 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_scoped_id PARAMS ((tree, tree));
extern tree identifier_typedecl_value PARAMS ((tree));
extern void save_type_access_control PARAMS ((tree));
extern void reset_type_access_control PARAMS ((void));
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 finish_declarator PARAMS ((tree, tree, tree, tree, int));
extern void finish_translation_unit PARAMS ((void));
}
}
+/* 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
do_identifier (token, parsing, args)
register tree token;
else if (IDENTIFIER_TYPENAME_P (token))
/* A templated conversion operator might exist. */
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
{
- if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node
- || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
- {
- 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);
+ unqualified_name_lookup_error (token);
+ return error_mark_node;
}
}
static tree parse_xref_tag (tree, tree, int);
static tree parse_handle_class_head (tree, tree, tree, int, int *);
static void parse_decl_instantiation (tree, tree, tree);
+static int parse_begin_function_definition (tree, tree);
/* Cons up an empty parameter list. */
static inline tree
fn.def1:
typed_declspecs declarator
{ check_for_new_type ("return type", $1);
- if (!begin_function_definition ($1.t, $2))
+ if (!parse_begin_function_definition ($1.t, $2))
YYERROR1; }
| declmods notype_declarator
- { if (!begin_function_definition ($1.t, $2))
+ { if (!parse_begin_function_definition ($1.t, $2))
YYERROR1; }
| notype_declarator
- { if (!begin_function_definition (NULL_TREE, $1))
+ { if (!parse_begin_function_definition (NULL_TREE, $1))
YYERROR1; }
| declmods constructor_declarator
- { if (!begin_function_definition ($1.t, $2))
+ { if (!parse_begin_function_definition ($1.t, $2))
YYERROR1; }
| constructor_declarator
- { if (!begin_function_definition (NULL_TREE, $1))
+ { if (!parse_begin_function_definition (NULL_TREE, $1))
YYERROR1; }
;
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"
current_type_lookups = NULL_TREE;
}
-/* Begin a function definition declared with DECL_SPECS and
- DECLARATOR. Returns non-zero if the function-declaration is
+/* Begin a function definition declared with DECL_SPECS, ATTRIBUTES,
+ and DECLARATOR. Returns non-zero if the function-declaration is
legal. */
int
-begin_function_definition (decl_specs, declarator)
+begin_function_definition (decl_specs, attributes, declarator)
tree decl_specs;
+ tree attributes;
tree declarator;
{
- tree specs;
- tree attrs;
-
- split_specs_attrs (decl_specs, &specs, &attrs);
- if (!start_function (specs, declarator, attrs, SF_DEFAULT))
+ if (!start_function (decl_specs, declarator, attributes, SF_DEFAULT))
return 0;
deferred_type_access_control ();