mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-26 02:15:31 +02:00
fix ClassCastExceptions (bug 101872)
This commit is contained in:
parent
82427c42a6
commit
d2dce4a297
3 changed files with 16 additions and 11 deletions
|
@ -255,7 +255,6 @@ public class CFunction implements IFunction, ICInternalFunction {
|
||||||
|
|
||||||
|
|
||||||
protected void updateParameterBindings( IASTFunctionDeclarator fdtor ){
|
protected void updateParameterBindings( IASTFunctionDeclarator fdtor ){
|
||||||
CParameter temp = null;
|
|
||||||
IParameter [] params = getParameters();
|
IParameter [] params = getParameters();
|
||||||
if( fdtor instanceof IASTStandardFunctionDeclarator ){
|
if( fdtor instanceof IASTStandardFunctionDeclarator ){
|
||||||
IASTParameterDeclaration [] nps = ((IASTStandardFunctionDeclarator)fdtor).getParameters();
|
IASTParameterDeclaration [] nps = ((IASTStandardFunctionDeclarator)fdtor).getParameters();
|
||||||
|
@ -263,9 +262,9 @@ public class CFunction implements IFunction, ICInternalFunction {
|
||||||
return;
|
return;
|
||||||
for( int i = 0; i < nps.length; i++ ){
|
for( int i = 0; i < nps.length; i++ ){
|
||||||
IASTName name = nps[i].getDeclarator().getName();
|
IASTName name = nps[i].getDeclarator().getName();
|
||||||
temp = (CParameter) params[i];
|
name.setBinding( params[i] );
|
||||||
name.setBinding( temp );
|
if( params[i] instanceof CParameter )
|
||||||
temp.addDeclaration( name );
|
((CParameter)params[i]).addDeclaration( name );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IASTName [] ns = ((ICASTKnRFunctionDeclarator)fdtor).getParameterNames();
|
IASTName [] ns = ((ICASTKnRFunctionDeclarator)fdtor).getParameterNames();
|
||||||
|
@ -274,12 +273,12 @@ public class CFunction implements IFunction, ICInternalFunction {
|
||||||
|
|
||||||
for( int i = 0; i < params.length; i++ ){
|
for( int i = 0; i < params.length; i++ ){
|
||||||
IASTName name = ns[i];
|
IASTName name = ns[i];
|
||||||
temp = (CParameter) params[i];
|
name.setBinding( params[i] );
|
||||||
name.setBinding( temp );
|
|
||||||
IASTDeclarator dtor = CVisitor.getKnRParameterDeclarator( (ICASTKnRFunctionDeclarator) fdtor, name );
|
IASTDeclarator dtor = CVisitor.getKnRParameterDeclarator( (ICASTKnRFunctionDeclarator) fdtor, name );
|
||||||
if( dtor != null ){
|
if( dtor != null ){
|
||||||
dtor.getName().setBinding( temp );
|
dtor.getName().setBinding( params[i] );
|
||||||
temp.addDeclaration( dtor.getName() );
|
if( params[i] instanceof CParameter )
|
||||||
|
((CParameter)params[i]).addDeclaration( dtor.getName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -839,8 +839,11 @@ public class CVisitor {
|
||||||
if( parent instanceof IASTParameterDeclaration || parent.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER ){
|
if( parent instanceof IASTParameterDeclaration || parent.getPropertyInParent() == ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER ){
|
||||||
IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) parent.getParent();
|
IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) parent.getParent();
|
||||||
IBinding temp = fdtor.getName().resolveBinding();
|
IBinding temp = fdtor.getName().resolveBinding();
|
||||||
if( temp != null && temp instanceof IFunction ){
|
if( temp != null && temp instanceof CFunction ){
|
||||||
binding = ((CFunction) temp).resolveParameter( name );
|
binding = ((CFunction) temp).resolveParameter( name );
|
||||||
|
} else if( temp instanceof IFunction ){
|
||||||
|
//problems with the function, still create binding for the parameter
|
||||||
|
binding = new CParameter( name );
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if( scope != null && scope.getPhysicalNode() instanceof IASTTranslationUnit ){
|
if( scope != null && scope.getPhysicalNode() instanceof IASTTranslationUnit ){
|
||||||
|
|
|
@ -2384,8 +2384,11 @@ public class CPPSemantics {
|
||||||
return CPPVisitor.createType( dtor );
|
return CPPVisitor.createType( dtor );
|
||||||
} else if( prop == IASTInitializerExpression.INITIALIZER_EXPRESSION ){
|
} else if( prop == IASTInitializerExpression.INITIALIZER_EXPRESSION ){
|
||||||
IASTInitializerExpression initExp = (IASTInitializerExpression) node.getParent();
|
IASTInitializerExpression initExp = (IASTInitializerExpression) node.getParent();
|
||||||
IASTDeclarator dtor = (IASTDeclarator) initExp.getParent();
|
if( initExp.getParent() instanceof IASTDeclarator ){
|
||||||
return CPPVisitor.createType( dtor );
|
IASTDeclarator dtor = (IASTDeclarator) initExp.getParent();
|
||||||
|
return CPPVisitor.createType( dtor );
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
//target is the left side of an assignment
|
//target is the left side of an assignment
|
||||||
else if( prop == IASTBinaryExpression.OPERAND_TWO &&
|
else if( prop == IASTBinaryExpression.OPERAND_TWO &&
|
||||||
|
|
Loading…
Add table
Reference in a new issue