mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 15:05:36 +02:00
Bug 518937 - Apply declaredBefore() filtering to index bindings found in a namespace scope
Previously, such filtering was only done in resolveAmbiguities(), which was too late for name lookup for proceed to an enclosing scope if it did not find valid candidates in the namespace scope. Change-Id: I435d7be1aff5344985c1bbb201bf5d383d43fe8d
This commit is contained in:
parent
9dbf2af399
commit
bb9d1db323
2 changed files with 25 additions and 9 deletions
|
@ -10,14 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
|
@ -351,4 +343,23 @@ public class IndexMultiFileTest extends IndexBindingResolutionTestBase {
|
|||
public void testStackOverflow_514459() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
|
||||
//test.hpp *
|
||||
// template <typename> class A {};
|
||||
//
|
||||
// struct C {
|
||||
// C();
|
||||
// };
|
||||
//
|
||||
// namespace Ptr2 {
|
||||
// using C = A<C>;
|
||||
// }
|
||||
|
||||
//test.cpp
|
||||
// #include "test.hpp"
|
||||
// C::C() {}
|
||||
public void testAliasTemplateReferencingSameName_518937() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,12 @@ abstract public class CPPScope implements ICPPASTInternalScope {
|
|||
if (binding instanceof ICPPNamespace) {
|
||||
ICPPNamespaceScope indexNs = ((ICPPNamespace) binding).getNamespaceScope();
|
||||
IBinding[] bindings = indexNs.getBindings(lookup);
|
||||
result = ArrayUtil.addAll(IBinding.class, result, bindings);
|
||||
for (IBinding candidate : bindings) {
|
||||
if (lookup.isPrefixLookup() ||
|
||||
CPPSemantics.declaredBefore(candidate, lookup.getLookupPoint(), true)) {
|
||||
result = ArrayUtil.append(result, candidate);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
|
Loading…
Add table
Reference in a new issue