aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2002-07-10 18:16:24 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2002-07-10 18:16:24 +0000
commit15c7fb9cfd93a55e8140cb70434a1c9fce2539d4 (patch)
treeca3ba05dd6a078be579c03889eb6b43527252475 /gcc/cp
parentae3aa00d40c09b01569a4b94e2c89e5d5e7cc1dc (diff)
downloadgcc-15c7fb9cfd93a55e8140cb70434a1c9fce2539d4.zip
gcc-15c7fb9cfd93a55e8140cb70434a1c9fce2539d4.tar.gz
gcc-15c7fb9cfd93a55e8140cb70434a1c9fce2539d4.tar.bz2
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
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog12
-rw-r--r--gcc/cp/cp-tree.h3
-rw-r--r--gcc/cp/lex.c64
-rw-r--r--gcc/cp/parse.y24
-rw-r--r--gcc/cp/semantics.c13
5 files changed, 74 insertions, 42 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 70066d1..dee8747 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,15 @@
+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
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6b7522f..15a5aff 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4062,6 +4062,7 @@ extern void note_got_semicolon PARAMS ((tree));
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));
@@ -4285,7 +4286,7 @@ extern tree finish_fname (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));
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index feadd69..412b3c5 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -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
do_identifier (token, parsing, args)
register tree token;
@@ -1175,36 +1209,10 @@ do_identifier (token, parsing, args)
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;
}
}
diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y
index e41ffc0..386c808 100644
--- a/gcc/cp/parse.y
+++ b/gcc/cp/parse.y
@@ -130,6 +130,7 @@ static tree parse_scoped_id PARAMS ((tree));
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
@@ -856,19 +857,19 @@ constructor_declarator:
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; }
;
@@ -4085,4 +4086,17 @@ parse_decl_instantiation (tree declspecs, tree declarator, tree 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"
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 8766d6f..bedd979 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -1517,20 +1517,17 @@ reset_type_access_control ()
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 ();