diff options
author | Markus Schorn | 2008-03-07 08:47:40 +0000 |
---|---|---|
committer | Markus Schorn | 2008-03-07 08:47:40 +0000 |
commit | 9f0a5237c3b9dcbaa108ee440c8f8893ed2e5bb9 (patch) | |
tree | 0cc48063e02e403e4bf82f6da8c8c7bba9d00ef5 | |
parent | 853bc59800b002cff35b522fc350573699669ab0 (diff) | |
download | org.eclipse.cdt-9f0a5237c3b9dcbaa108ee440c8f8893ed2e5bb9.tar.gz org.eclipse.cdt-9f0a5237c3b9dcbaa108ee440c8f8893ed2e5bb9.tar.xz org.eclipse.cdt-9f0a5237c3b9dcbaa108ee440c8f8893ed2e5bb9.zip |
Fix for a NPE, bug 221796.
3 files changed, 12 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java index cc562fcb7aa..0277db93e26 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -122,7 +123,7 @@ public class CPPImplicitFunction extends CPPFunction implements ICPPFunction, IC ((CPPParameter)binding).addDeclaration( n ); } if( declarations != null ){ - for( int j = 0; j < declarations.length; j++ ){ + for( int j = 0; j < declarations.length && declarations[j] != null; j++ ){ temp = declarations[j].getParameters()[i]; IASTName n = temp.getDeclarator().getName(); n.setBinding( binding ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java index 344451afde3..756acef6466 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -78,6 +78,9 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod //first check if we already know it if( declarations != null ){ for( int i = 0; i < declarations.length; i++ ){ + if (declarations[i] == null) { + break; + } IASTDeclaration decl = (IASTDeclaration) declarations[i].getParent(); if( decl.getParent() instanceof ICPPASTCompositeTypeSpecifier ) return decl; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java index 0d5f10757c0..1095cbd70b9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,9 +9,6 @@ * IBM Corporation - initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ -/* - * Created on Dec 1, 2004 - */ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.DOMException; @@ -116,6 +113,9 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { if( declarations != null ){ for( int i = 0; i < declarations.length; i++ ){ IASTDeclarator dtor = declarations[i]; + if (dtor == null) { + break; + } while( dtor.getParent() instanceof IASTDeclarator ) dtor = (IASTDeclarator) dtor.getParent(); IASTDeclaration decl = (IASTDeclaration) dtor.getParent(); |