diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java index 70a1f6d537f..1faae43b576 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiFileTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013, 2014 Google, Inc and others. + * Copyright (c) 2013, 2015 Google, Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -100,4 +100,28 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase { public void testNamespaceAlias_442117() throws Exception { checkBindings(); } + + // confuser.cpp + // namespace ns1 { + // namespace waldo {} + // namespace ns2 { + // namespace waldo {} + // } + // } + + // test.cpp * + // namespace waldo { + // class A {}; + // } + // + // namespace ns1 { + // namespace ns2 { + // + // waldo::A* x; + // + // } + // } + public void testNamespace_481161() throws Exception { + checkBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 2ba3db190be..8806d9ca681 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -2013,6 +2013,7 @@ public class CPPSemantics { ObjectSet fns= ObjectSet.emptySet(); IBinding type = null; IBinding obj = null; + boolean ambiguous = false; IBinding temp = null; final CPPASTTranslationUnit tu = data.getTranslationUnit(); @@ -2083,25 +2084,28 @@ public class CPPSemantics { if (type == null) { type = temp; + ambiguous = false; } else if (!type.equals(temp)) { int c = compareByRelevance(tu, type, temp); if (c < 0) { type= temp; + ambiguous = false; } else if (c == 0) { if (((IType) type).isSameType((IType) temp)) { if (type instanceof ITypedef && !(temp instanceof ITypedef)) { // Between same types prefer non-typedef. type= temp; + ambiguous = false; } } else { - return new ProblemBinding(lookupName, lookupPoint, - IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getFoundBindings()); + ambiguous = true; } } } } else { if (obj == null) { obj = temp; + ambiguous = false; } else if (!obj.equals(temp)) { if (obj instanceof ICPPNamespace && temp instanceof ICPPNamespace && SemanticUtil.isSameNamespace((ICPPNamespace) obj, (ICPPNamespace) temp)) { @@ -2110,13 +2114,18 @@ public class CPPSemantics { int c = compareByRelevance(tu, obj, temp); if (c < 0) { obj= temp; + ambiguous = false; } else if (c == 0) { - return new ProblemBinding(lookupName, lookupPoint, - IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getFoundBindings()); + ambiguous = true; } } } } + if (ambiguous) { + return new ProblemBinding(lookupName, lookupPoint, + IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.getFoundBindings()); + } + if (data.forUsingDeclaration) { int cmp= -1; if (obj != null) {