aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-07-14 14:15:49 -0400
committerJason Merrill <jason@gcc.gnu.org>2009-07-14 14:15:49 -0400
commit3deeb3ff03b0df2812a00d6713d4d026f0f2ea7e (patch)
treee3968f63e2c63207ce51e4af6d21f6a9ac4b5833 /gcc
parent4e6a97250c769588c57079976c4299b2814d6310 (diff)
downloadgcc-3deeb3ff03b0df2812a00d6713d4d026f0f2ea7e.zip
gcc-3deeb3ff03b0df2812a00d6713d4d026f0f2ea7e.tar.gz
gcc-3deeb3ff03b0df2812a00d6713d4d026f0f2ea7e.tar.bz2
name-lookup.c (qualified_lookup_using_namespace): Don't stop looking in used namespaces just because we found something on...
* name-lookup.c (qualified_lookup_using_namespace): Don't stop looking in used namespaces just because we found something on another branch. From-SVN: r149637
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/name-lookup.c12
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/lookup/using20.C18
4 files changed, 32 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 67bbc74..d43341b8 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2009-07-14 Jason Merrill <jason@redhat.com>
+ PR c++/40746
+ * name-lookup.c (qualified_lookup_using_namespace): Don't stop
+ looking in used namespaces just because we found something on
+ another branch.
+
PR c++/40740
* semantics.c (perform_koenig_lookup): Handle empty template args.
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index c1032e3..7a8016f 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3929,6 +3929,7 @@ qualified_lookup_using_namespace (tree name, tree scope,
/* ... and a list of namespace yet to see. */
tree todo = NULL_TREE;
tree todo_maybe = NULL_TREE;
+ tree *todo_weak = &todo_maybe;
tree usings;
timevar_push (TV_NAME_LOOKUP);
/* Look through namespace aliases. */
@@ -3942,9 +3943,7 @@ qualified_lookup_using_namespace (tree name, tree scope,
ambiguous_decl (result, binding, flags);
/* Consider strong using directives always, and non-strong ones
- if we haven't found a binding yet. ??? Shouldn't we consider
- non-strong ones if the initial RESULT is non-NULL, but the
- binding in the given namespace is? */
+ if we haven't found a binding yet. */
for (usings = DECL_NAMESPACE_USING (scope); usings;
usings = TREE_CHAIN (usings))
/* If this was a real directive, and we have not seen it. */
@@ -3959,12 +3958,12 @@ qualified_lookup_using_namespace (tree name, tree scope,
&& !purpose_member (TREE_PURPOSE (usings), seen)
&& !purpose_member (TREE_PURPOSE (usings), todo))
todo = tree_cons (TREE_PURPOSE (usings), NULL_TREE, todo);
- else if ((!result->value && !result->type)
+ else if (!binding
&& !purpose_member (TREE_PURPOSE (usings), seen)
&& !purpose_member (TREE_PURPOSE (usings), todo)
&& !purpose_member (TREE_PURPOSE (usings), todo_maybe))
- todo_maybe = tree_cons (TREE_PURPOSE (usings), NULL_TREE,
- todo_maybe);
+ *todo_weak = tree_cons (TREE_PURPOSE (usings), NULL_TREE,
+ *todo_weak);
}
if (todo)
{
@@ -3977,6 +3976,7 @@ qualified_lookup_using_namespace (tree name, tree scope,
scope = TREE_PURPOSE (todo_maybe);
todo = TREE_CHAIN (todo_maybe);
todo_maybe = NULL_TREE;
+ todo_weak = &todo;
}
else
scope = NULL_TREE; /* If there never was a todo list. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 58ce71c..1fa70ed 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2009-07-14 Jason Merrill <jason@redhat.com>
+ PR c++/40746
+ * g++.dg/lookup/using20.C: New.
+
PR c++/40740
* g++.dg/template/koenig8.C: New.
diff --git a/gcc/testsuite/g++.dg/lookup/using20.C b/gcc/testsuite/g++.dg/lookup/using20.C
new file mode 100644
index 0000000..dc1d293
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/using20.C
@@ -0,0 +1,18 @@
+// PR c++/40476
+
+namespace A
+{
+ int i; // { dg-error "i" }
+}
+using namespace A;
+namespace B
+{
+ namespace B2
+ {
+ int i; // { dg-error "i" }
+ }
+ using namespace B2;
+}
+using namespace B;
+
+int j = ::i; // { dg-error "ambiguous" }