mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +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 ){
|
||||
CParameter temp = null;
|
||||
IParameter [] params = getParameters();
|
||||
if( fdtor instanceof IASTStandardFunctionDeclarator ){
|
||||
IASTParameterDeclaration [] nps = ((IASTStandardFunctionDeclarator)fdtor).getParameters();
|
||||
|
@ -263,9 +262,9 @@ public class CFunction implements IFunction, ICInternalFunction {
|
|||
return;
|
||||
for( int i = 0; i < nps.length; i++ ){
|
||||
IASTName name = nps[i].getDeclarator().getName();
|
||||
temp = (CParameter) params[i];
|
||||
name.setBinding( temp );
|
||||
temp.addDeclaration( name );
|
||||
name.setBinding( params[i] );
|
||||
if( params[i] instanceof CParameter )
|
||||
((CParameter)params[i]).addDeclaration( name );
|
||||
}
|
||||
} else {
|
||||
IASTName [] ns = ((ICASTKnRFunctionDeclarator)fdtor).getParameterNames();
|
||||
|
@ -274,12 +273,12 @@ public class CFunction implements IFunction, ICInternalFunction {
|
|||
|
||||
for( int i = 0; i < params.length; i++ ){
|
||||
IASTName name = ns[i];
|
||||
temp = (CParameter) params[i];
|
||||
name.setBinding( temp );
|
||||
name.setBinding( params[i] );
|
||||
IASTDeclarator dtor = CVisitor.getKnRParameterDeclarator( (ICASTKnRFunctionDeclarator) fdtor, name );
|
||||
if( dtor != null ){
|
||||
dtor.getName().setBinding( temp );
|
||||
temp.addDeclaration( dtor.getName() );
|
||||
dtor.getName().setBinding( params[i] );
|
||||
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 ){
|
||||
IASTFunctionDeclarator fdtor = (IASTFunctionDeclarator) parent.getParent();
|
||||
IBinding temp = fdtor.getName().resolveBinding();
|
||||
if( temp != null && temp instanceof IFunction ){
|
||||
if( temp != null && temp instanceof CFunction ){
|
||||
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 {
|
||||
if( scope != null && scope.getPhysicalNode() instanceof IASTTranslationUnit ){
|
||||
|
|
|
@ -2384,8 +2384,11 @@ public class CPPSemantics {
|
|||
return CPPVisitor.createType( dtor );
|
||||
} else if( prop == IASTInitializerExpression.INITIALIZER_EXPRESSION ){
|
||||
IASTInitializerExpression initExp = (IASTInitializerExpression) node.getParent();
|
||||
IASTDeclarator dtor = (IASTDeclarator) initExp.getParent();
|
||||
return CPPVisitor.createType( dtor );
|
||||
if( initExp.getParent() instanceof IASTDeclarator ){
|
||||
IASTDeclarator dtor = (IASTDeclarator) initExp.getParent();
|
||||
return CPPVisitor.createType( dtor );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//target is the left side of an assignment
|
||||
else if( prop == IASTBinaryExpression.OPERAND_TWO &&
|
||||
|
|
Loading…
Add table
Reference in a new issue