#include "cp-tree.h"
#include "name-lookup.h"
#include "timevar.h"
-#include "toplev.h"
#include "diagnostic-core.h"
+#include "intl.h"
#include "debug.h"
#include "c-family/c-pragma.h"
+#include "params.h"
/* The bindings for a particular name in a particular scope. */
inlining. */
&& (!TYPE_NAME (type)
|| TYPE_NAME (type) != DECL_ABSTRACT_ORIGIN (x))))
- cp_set_underlying_type (x);
+ set_underlying_type (x);
if (type != error_mark_node
&& TYPE_NAME (type)
/* OK */;
else
{
- warning (0, "extern declaration of %q#D doesn't match", x);
+ warning (0, "extern declaration of %q#D doesn%'t match", x);
warning (0, "global declaration %q+#D", oldglobal);
}
}
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;
tree name = TREE_PURPOSE (d);
tree args = TREE_VALUE (d);
-#ifdef HANDLE_PRAGMA_VISIBILITY
if (is_attribute_p ("visibility", name))
{
tree x = args ? TREE_VALUE (args) : NULL_TREE;
saw_vis = true;
}
else
-#endif
{
warning (OPT_Wattributes, "%qD attribute directive ignored",
name);
return fns;
}
+/* Suggest alternatives for NAME, an IDENTIFIER_NODE for which name
+ lookup failed. Search through all available namespaces and print out
+ possible candidates. */
+
+void
+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;
+ tree t;
+ unsigned ix;
+
+ VEC_safe_push (tree, heap, namespaces_to_search, global_namespace);
+
+ while (!VEC_empty (tree, namespaces_to_search)
+ && n_searched < max_to_search)
+ {
+ tree scope = VEC_pop (tree, namespaces_to_search);
+ struct scope_binding binding = EMPTY_SCOPE_BINDING;
+ struct cp_binding_level *level = NAMESPACE_LEVEL (scope);
+
+ /* Look in this namespace. */
+ qualified_lookup_using_namespace (name, scope, &binding, 0);
+
+ n_searched++;
+
+ if (binding.value)
+ VEC_safe_push (tree, heap, candidates, binding.value);
+
+ /* Add child namespaces. */
+ for (t = level->namespaces; t; t = DECL_CHAIN (t))
+ VEC_safe_push (tree, heap, namespaces_to_search, t);
+ }
+
+ /* If we stopped before we could examine all namespaces, inform the
+ 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
+ && !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;
+
+ inform_n (location, VEC_length (tree, candidates),
+ "suggested alternative:",
+ "suggested alternatives:");
+
+ FOR_EACH_VEC_ELT (tree, candidates, ix, t)
+ inform (location_of (t), " %qE", t);
+
+ VEC_free (tree, heap, candidates);
+}
+
/* Unscoped lookup of a global: iterate over current namespaces,
considering using-directives. */
}
/* 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))));
else if (fn == k->functions)
;
else
- k->functions = build_overload (fn, k->functions);
+ {
+ k->functions = build_overload (fn, k->functions);
+ if (TREE_CODE (k->functions) == OVERLOAD)
+ OVL_ARG_DEPENDENT (k->functions) = true;
+ }
return false;
}
}
else if (TREE_CODE (n) == OVERLOAD)
{
- for (; n; n = OVL_CHAIN (n))
- if (arg_assoc_type (k, TREE_TYPE (OVL_FUNCTION (n))))
+ for (; n; n = OVL_NEXT (n))
+ if (arg_assoc_type (k, TREE_TYPE (OVL_CURRENT (n))))
return true;
}