mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +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.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
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.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
@ -72,4 +74,14 @@ public class CFunctionTests extends PDOMTestBase {
|
||||||
assertTrue(((IFunction) bindings[0]).takesVarArgs());
|
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();
|
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.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
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.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
@ -52,12 +53,14 @@ class PDOMCParameter extends PDOMNamedNode implements IParameter {
|
||||||
|
|
||||||
db.putInt(record + NEXT_PARAM, 0);
|
db.putInt(record + NEXT_PARAM, 0);
|
||||||
try {
|
try {
|
||||||
IType type = param.getType();
|
if(!(param instanceof IProblemBinding)) {
|
||||||
while(type instanceof ITypedef)
|
IType type = param.getType();
|
||||||
type = ((ITypedef)type).getType();
|
while(type instanceof ITypedef)
|
||||||
if (type != null) {
|
type = ((ITypedef)type).getType();
|
||||||
PDOMNode typeNode = getLinkageImpl().addType(this, type);
|
if (type != null) {
|
||||||
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
|
PDOMNode typeNode = getLinkageImpl().addType(this, type);
|
||||||
|
db.putInt(record + TYPE, typeNode != null ? typeNode.getRecord() : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch(DOMException e) {
|
} catch(DOMException e) {
|
||||||
throw new CoreException(Util.createStatus(e));
|
throw new CoreException(Util.createStatus(e));
|
||||||
|
|
Loading…
Add table
Reference in a new issue