diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IndexCBindingResolutionBugs.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IndexCBindingResolutionBugs.java new file mode 100644 index 00000000000..f05c4f57bf1 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IndexCBindingResolutionBugs.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2006, 2007 Wind River Systems, 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + *******************************************************************************/ +package org.eclipse.cdt.internal.pdom.tests; + +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IBasicType; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IFunction; +import org.eclipse.cdt.core.dom.ast.IParameter; +import org.eclipse.cdt.core.dom.ast.IType; + +/** + * For testing PDOM binding resolution + */ +public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase { + + public static class SingleProject extends IndexCBindingResolutionBugs { + public SingleProject() {setStrategy(new SinglePDOMTestStrategy(false));} + } + public static class ProjectWithDepProj extends IndexCBindingResolutionBugs { + public ProjectWithDepProj() {setStrategy(new ReferencedProject(false));} + } + + public static void addTests(TestSuite suite) { + suite.addTest(suite(SingleProject.class)); + suite.addTest(suite(ProjectWithDepProj.class)); + } + + + // #include + // void func1(void) + // { + // int i = 0; + // for (i=0; i<10;i++) + // { + // printf("%i", i); + // } + // + // } + + // #include "header.h" + // + // int main(void) + // { + // while (1) + // { + // func1(); + // } + // return 0; + // } + public void testBug175267() throws DOMException { + IBinding b0 = getBindingFromASTName("func1()", 5); + assertTrue(b0 instanceof IFunction); + IFunction f0 = (IFunction) b0; + IParameter[] params= f0.getParameters(); + assertEquals(1, params.length); + IType param= params[0].getType(); + assertTrue(param instanceof IBasicType); + } +} diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java index a02ea95d703..52894f0cdde 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMTests.java @@ -41,6 +41,7 @@ public class PDOMTests extends TestSuite { IndexCBindingResolutionTest.addTests(suite); IndexCPPBindingResolutionTest.addTests(suite); + IndexCBindingResolutionBugs.addTests(suite); suite.addTest(IndexBindingResolutionBugs.suite()); suite.addTest(CFunctionTests.suite()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java index cfccb034f14..c3a7d98e12d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.index.IIndexBinding; -import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; class CompositeCFunction extends CompositeCBinding implements IIndexBinding, IFunction { @@ -33,7 +32,7 @@ class CompositeCFunction extends CompositeCBinding implements IIndexBinding, IFu IParameter[] preResult = ((IFunction)rbinding).getParameters(); IParameter[] result = new IParameter[preResult.length]; for(int i=0; i