mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 10:05:24 +02:00
Bug 481161 - Namespace resolution problem with index
Change-Id: I2adaa53647bcd67f0a1058de4d44dbc808ff84a9
This commit is contained in:
parent
ef148a9ec5
commit
dc9dfa517b
2 changed files with 38 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2013,6 +2013,7 @@ public class CPPSemantics {
|
|||
ObjectSet<ICPPFunction> 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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue