summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2015-10-23 17:56:30 -0200
committerAlexandre Oliva <aoliva@redhat.com>2016-02-19 19:55:09 -0200
commit497a978102fe126b505a746d1f3889c32d0b3eba (patch)
tree28529eb6c73ef7a2578996ac5d89959f5d916dfd
parent1b1299847473b8ea99240612c08c0743804c2ce6 (diff)
downloadgcc-497a978102fe126b505a746d1f3889c32d0b3eba.tar.gz
factor out query_oracle and use it for NS-qualified lookups
-rw-r--r--gcc/cp/name-lookup.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index b07d3ad4dd6..4b30736c904 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -85,10 +85,27 @@ get_anonymous_namespace_name (void)
static GTY((deletable)) binding_entry free_binding_entry = NULL;
-/* The bindin oracle; see cp-tree.h. */
+/* The binding oracle; see cp-tree.h. */
cp_binding_oracle_function *cp_binding_oracle;
+/* If we have a binding oracle, ask it for all namespace-scoped
+ definitions of NAME. */
+
+static inline void
+query_oracle (tree name)
+{
+ // FIXME: we need a more space-efficient representation for
+ // oracle_looked_up.
+ if (cp_binding_oracle && !LANG_IDENTIFIER_CAST (name)->oracle_looked_up)
+ {
+ LANG_IDENTIFIER_CAST (name)->oracle_looked_up = true;
+ // FIXME: unify CP_ORACLE_SYMBOL and CP_ORACLE_TAG for C++.
+ cp_binding_oracle (CP_ORACLE_SYMBOL, name);
+ cp_binding_oracle (CP_ORACLE_TAG, name);
+ }
+}
+
/* Create a binding_entry object for (NAME, TYPE). */
static inline binding_entry
@@ -4622,6 +4639,8 @@ qualified_lookup_using_namespace (tree name, tree scope,
/* Look through namespace aliases. */
scope = ORIGINAL_NAMESPACE (scope);
+ query_oracle (name);
+
/* Algorithm: Starting with SCOPE, walk through the set of used
namespaces. For each used namespace, look through its inline
namespace set for any bindings and usings. If no bindings are
@@ -4829,14 +4848,7 @@ lookup_name_real_1 (tree name, int prefer_type, int nonclass, bool block_p,
cxx_binding *iter;
tree val = NULL_TREE;
- // FIXME: we need a more space-efficient representation for
- // oracle_looked_up.
- if (cp_binding_oracle && !LANG_IDENTIFIER_CAST (name)->oracle_looked_up)
- {
- LANG_IDENTIFIER_CAST (name)->oracle_looked_up = true;
- cp_binding_oracle (CP_ORACLE_SYMBOL, name);
- cp_binding_oracle (CP_ORACLE_TAG, name);
- }
+ query_oracle (name);
/* Conversion operators are handled specially because ordinary
unqualified name lookup will not find template conversion