OSDN Git Service

fix pr marker
[pf3gnuchains/gcc-fork.git] / gcc / cp / name-lookup.c
index 0ee80e4..18e3441 100644 (file)
@@ -28,7 +28,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "cp-tree.h"
 #include "name-lookup.h"
 #include "timevar.h"
-#include "toplev.h"
 #include "diagnostic-core.h"
 #include "intl.h"
 #include "debug.h"
@@ -1636,6 +1635,22 @@ getdecls (void)
   return current_binding_level->names;
 }
 
+/* Return how many function prototypes we are currently nested inside.  */
+
+int
+function_parm_depth (void)
+{
+  int level = 0;
+  struct cp_binding_level *b;
+
+  for (b = current_binding_level;
+       b->kind == sk_function_parms;
+       b = b->level_chain)
+    ++level;
+
+  return level;
+}
+
 /* For debugging.  */
 static int no_print_functions = 0;
 static int no_print_builtins = 0;
@@ -3924,14 +3939,12 @@ remove_hidden_names (tree fns)
    possible candidates.  */
 
 void
-suggest_alternatives_for (tree name)
+suggest_alternatives_for (location_t location, tree name)
 {
   VEC(tree,heap) *candidates = NULL;
   VEC(tree,heap) *namespaces_to_search = NULL;
   int max_to_search = PARAM_VALUE (CXX_MAX_NAMESPACES_FOR_DIAGNOSTIC_HELP);
   int n_searched = 0;
-  char *spaces;
-  const char *str;
   tree t;
   unsigned ix;
 
@@ -3961,29 +3974,26 @@ suggest_alternatives_for (tree name)
      user.  Do this even if we don't have any candidates, since there
      might be more candidates further down that we weren't able to
      find.  */
-  if (n_searched >= max_to_search)
-    inform (input_location,
+  if (n_searched >= max_to_search
+      && !VEC_empty (tree, namespaces_to_search))
+    inform (location,
            "maximum limit of %d namespaces searched for %qE",
            max_to_search, name);
 
+  VEC_free (tree, heap, namespaces_to_search);
+
   /* Nothing useful to report.  */
   if (VEC_empty (tree, candidates))
     return;
 
-  str = (VEC_length(tree, candidates) > 1
-        ? _("suggested alternatives:")
-        : _("suggested alternative:"));
-  spaces = NULL;
+  inform_n (location, VEC_length (tree, candidates),
+           "suggested alternative:",
+           "suggested alternatives:");
 
   FOR_EACH_VEC_ELT (tree, candidates, ix, t)
-    {
-      inform (input_location, "%s %qE", (spaces ? spaces : str), t);
-      spaces = spaces ? spaces : get_spaces (str);
-    }
+    inform (location_of (t), "  %qE", t);
 
   VEC_free (tree, heap, candidates);
-  VEC_free (tree, heap, namespaces_to_search);
-  free (spaces);
 }
 
 /* Unscoped lookup of a global: iterate over current namespaces,
@@ -4195,8 +4205,13 @@ qualified_lookup_using_namespace (tree name, tree scope,
 }
 
 /* Subroutine of outer_binding.
-   Returns TRUE if BINDING is a binding to a template parameter of SCOPE,
-   FALSE otherwise.  */
+
+   Returns TRUE if BINDING is a binding to a template parameter of
+   SCOPE.  In that case SCOPE is the scope of a primary template
+   parameter -- in the sense of G++, i.e, a template that has its own
+   template header.
+
+   Returns FALSE otherwise.  */
 
 static bool
 binding_to_template_parms_of_scope_p (cxx_binding *binding,
@@ -4212,6 +4227,8 @@ binding_to_template_parms_of_scope_p (cxx_binding *binding,
   return (scope
          && scope->this_entity
          && get_template_info (scope->this_entity)
+         && PRIMARY_TEMPLATE_P (TI_TEMPLATE
+                                (get_template_info (scope->this_entity)))
          && parameter_of_template_p (binding_value,
                                      TI_TEMPLATE (get_template_info \
                                                    (scope->this_entity))));