diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java index 70a6cc6ecb5..43062a9da00 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/NamespaceTests.java @@ -209,6 +209,6 @@ public class NamespaceTests extends PDOMTestBase { assertEquals(0, decls.length); IName[] refs = pdom.findNames(variable1, IIndex.FIND_REFERENCES); - assertEquals(2, refs.length); + assertEquals(3, refs.length); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java index 6b167bfa2da..157266fcb71 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java @@ -18,6 +18,8 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexLocationFactory; @@ -77,6 +79,17 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation { break; case IS_DECLARATION: binding.addDeclaration(this); + + // The name of a using-declaration is, in addition to the declaration of + // the using-declaration binding, a reference to its delegate bindings. + if (binding instanceof ICPPUsingDeclaration) { + for (IBinding delegate : ((ICPPUsingDeclaration) binding).getDelegates()) { + if (delegate instanceof PDOMBinding) { + ((PDOMBinding) delegate).addReference(this); + } + } + } + break; case IS_REFERENCE: binding.addReference(this); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/FindReferencesTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/FindReferencesTest.java index 491f2c043b6..6844efb2a7b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/FindReferencesTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/search/FindReferencesTest.java @@ -95,4 +95,16 @@ public class FindReferencesTest extends SearchTestBase { assertEquals(1, matches.length); assertNotNull(matches[0].getEnclosingElement()); } + + // namespace N { + // void foo(); + // } + // using N::foo; + + // // empty file + public void testUsingDeclaration_399147() throws Exception { + int offset = fHeaderContents.indexOf("void foo") + 5; + CSearchQuery query = makeProjectQuery(offset, 3); + assertOccurrences(query, 1); + } }