diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java index 39de8357978..6fa543f19c0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java @@ -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() ); } } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index 8f5f17cb01b..93d73162529 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -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 ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java index 94c315192b5..efd5680d14b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java @@ -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 &&