OSDN Git Service

* cp-tree.h (unqualified_name_lookup_error): Declare it.
[pf3gnuchains/gcc-fork.git] / gcc / cp / lex.c
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;
        }
     }