OSDN Git Service

* cp-tree.h (unqualified_name_lookup_error): Declare it.
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Jul 2002 18:16:24 +0000 (18:16 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Jul 2002 18:16:24 +0000 (18:16 +0000)
(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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@55372 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/lex.c
gcc/cp/parse.y
gcc/cp/semantics.c

index 70066d1..dee8747 100644 (file)
@@ -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
index 6b7522f..15a5aff 100644 (file)
@@ -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));
index feadd69..412b3c5 100644 (file)
@@ -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;
        }
     }
 
index e41ffc0..386c808 100644 (file)
@@ -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"
index 8766d6f..bedd979 100644 (file)
@@ -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 ();