1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 11:25:35 +02:00

175267: apply fix

This commit is contained in:
Andrew Ferguson 2007-02-23 16:50:58 +00:00
parent 96edd98a49
commit e6c6d81bdd
4 changed files with 74 additions and 4 deletions

View file

@ -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 <stdio.h>
// 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);
}
}

View file

@ -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());

View file

@ -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<preResult.length; i++) {
result[i] = (IParameter) cf.getCompositeBinding((IIndexFragmentBinding) preResult[i]);
result[i] = (IParameter) cf.getCompositeBinding(preResult[i]);
}
return result;
}

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.index.composite.c;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IEnumerator;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.index.IIndexBinding;
@ -25,7 +24,7 @@ class CompositeCParameter extends CompositeCBinding implements IIndexBinding, IP
}
public IType getType() throws DOMException {
IType rtype = ((IEnumerator)rbinding).getType();
IType rtype = ((IParameter)rbinding).getType();
return cf.getCompositeType(rtype);
}