1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Fixed Bug 87811 - [Parser] NPE found in ASTNode#getNodeLocations() with problematic KnR C

This commit is contained in:
John Camelon 2005-04-05 17:27:56 +00:00
parent 1e8393f7a2
commit e2e1f585eb
4 changed files with 8 additions and 5 deletions

View file

@ -142,7 +142,9 @@ public class ASTSignatureUtil {
for(int i=0; i<names.length; i++) { for(int i=0; i<names.length; i++) {
if (names[i] != null) { if (names[i] != null) {
result[i] = getSignature(((ICASTKnRFunctionDeclarator)decltor).getDeclaratorForParameterName(names[i])); final IASTDeclarator declaratorForParameterName = ((ICASTKnRFunctionDeclarator)decltor).getDeclaratorForParameterName(names[i]);
if( declaratorForParameterName != null )
result[i] = getSignature(declaratorForParameterName);
} }
} }
} }

View file

@ -220,6 +220,7 @@ public class CFunction implements IFunction, ICInternalBinding {
break; break;
} }
knrParamDtor = CVisitor.getKnRParameterDeclarator( fKnRDtor, paramName ); knrParamDtor = CVisitor.getKnRParameterDeclarator( fKnRDtor, paramName );
if( knrParamDtor != null )
paramName = knrParamDtor.getName(); paramName = knrParamDtor.getName();
} }

View file

@ -1601,6 +1601,7 @@ public class CVisitor {
for( int i = 0; i < parms.length; i++ ){ for( int i = 0; i < parms.length; i++ ){
IASTDeclarator dtor = getKnRParameterDeclarator( (ICASTKnRFunctionDeclarator) decltor, parms[i] ); IASTDeclarator dtor = getKnRParameterDeclarator( (ICASTKnRFunctionDeclarator) decltor, parms[i] );
if( dtor != null )
parmTypes[i] = createType( dtor ); parmTypes[i] = createType( dtor );
} }
return parmTypes; return parmTypes;

View file

@ -1910,8 +1910,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
ICASTKnRFunctionDeclarator functionDecltor = createKnRFunctionDeclarator(); ICASTKnRFunctionDeclarator functionDecltor = createKnRFunctionDeclarator();
parmDeclarations = removeNullDeclarations(parmDeclarations); parmDeclarations = removeNullDeclarations(parmDeclarations);
for (int i = 0; i < parmDeclarations.length; ++i) { for (int i = 0; i < parmDeclarations.length; ++i) {
if (parmDeclarations[i] != null if (parmDeclarations[i] != null) {
&& !(parmDeclarations[i] instanceof IASTProblemDeclaration)) {
parmDeclarations[i].setParent(functionDecltor); parmDeclarations[i].setParent(functionDecltor);
parmDeclarations[i] parmDeclarations[i]
.setPropertyInParent(ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER); .setPropertyInParent(ICASTKnRFunctionDeclarator.FUNCTION_PARAMETER);