mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
fix handling of particular type of problem binding in KnR style function declarations
This commit is contained in:
parent
ff9b1c4616
commit
00ebcad325
3 changed files with 31 additions and 7 deletions
|
@ -15,6 +15,8 @@ import junit.framework.Test;
|
|||
|
||||
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.c.ICBasicType;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
|
@ -72,4 +74,14 @@ public class CFunctionTests extends PDOMTestBase {
|
|||
assertTrue(((IFunction) bindings[0]).takesVarArgs());
|
||||
}
|
||||
|
||||
public void testKnRStyleFunctionWithProblemParameters() throws Exception {
|
||||
IBinding[] bindings = findQualifiedName(pdom, "KnRfunctionWithProblemParameters");
|
||||
assertEquals(1, bindings.length);
|
||||
IFunction f= (IFunction) bindings[0];
|
||||
IParameter[] params= f.getParameters();
|
||||
assertEquals(3, params.length);
|
||||
assertNull(params[0].getType()); // its a problem binding in the DOM
|
||||
assertTrue(params[1].getType() instanceof ICBasicType);
|
||||
assertTrue(params[2].getType() instanceof ICBasicType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,3 +19,12 @@ void spin() {
|
|||
forwardCDeclaration();
|
||||
}
|
||||
|
||||
// p1 is a particular type of problem binding as it
|
||||
// has no corresponding declarator
|
||||
void KnRfunctionWithProblemParameters(p1,p2,c)
|
||||
long p2;
|
||||
int c;
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
|
@ -52,6 +53,7 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter {
|
|||
|
||||
db.putInt(record + NEXT_PARAM, 0);
|
||||
try {
|
||||
if(!(param instanceof IProblemBinding)) {
|
||||
IType type = param.getType();
|
||||
while(type instanceof ITypedef)
|
||||
type = ((ITypedef)type).getType();
|
||||
|
@ -59,6 +61,7 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter {
|
|||
PDOMNode typeNode = getLinkageImpl().addType(this, type);
|
||||
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
|
||||
}
|
||||
}
|
||||
} catch(DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue