#include "cp-tree.h"
#include "name-lookup.h"
#include "timevar.h"
-#include "toplev.h"
#include "diagnostic-core.h"
#include "intl.h"
#include "debug.h"
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;
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;
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,
}
/* 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,
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))));