diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index cc54596627b..0d2b861a6c9 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -4643,4 +4643,19 @@ public class AST2CPPTests extends AST2BaseTest { buffer.append( "int A::B::* b; \n"); //$NON-NLS-1$ IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP ); } + + public void testBug_AIOOBE() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer.append("void f(); \n"); + buffer.append("void f( void ) {} \n"); + + IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP ); + CPPNameCollector col = new CPPNameCollector(); + tu.accept(col); + + IFunction f = (IFunction) col.getName(0).resolveBinding(); + assertSame( f, col.getName(1).resolveBinding() ); + IParameter p = (IParameter) col.getName(2).resolveBinding(); + assertNotNull( p ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java index 7598a1c07cf..1ba6928d5f6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java @@ -380,13 +380,15 @@ public class CPPFunction implements ICPPFunction, ICPPInternalFunction { } if( declarations != null ){ for( int j = 0; j < declarations.length && declarations[j] != null; j++ ){ - temp = declarations[j].getParameters()[i]; - IASTName n = temp.getDeclarator().getName(); - if( n != name ) { - n.setBinding( binding ); - ((CPPParameter)binding).addDeclaration( n ); - } - + IASTParameterDeclaration [] paramDecls = declarations[j].getParameters(); + if( paramDecls.length > i ) { + temp = paramDecls[i]; + IASTName n = temp.getDeclarator().getName(); + if( n != name ) { + n.setBinding( binding ); + ((CPPParameter)binding).addDeclaration( n ); + } + } } } return binding; @@ -397,9 +399,9 @@ public class CPPFunction implements ICPPFunction, ICPPInternalFunction { IASTParameterDeclaration [] ops = orig.getParameters(); IASTParameterDeclaration [] nps = fdtor.getParameters(); CPPParameter temp = null; - for( int i = 0; i < nps.length; i++ ){ + for( int i = 0; i < ops.length; i++ ){ temp = (CPPParameter) ops[i].getDeclarator().getName().getBinding(); - if( temp != null ){ + if( temp != null && nps.length > i ){ //length could be different, ie 0 or 1 with void IASTDeclarator dtor = nps[i].getDeclarator(); while( dtor.getNestedDeclarator() != null ) dtor = dtor.getNestedDeclarator(); 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 4e71e43bcd0..5d2a7117c20 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 @@ -2792,9 +2792,14 @@ public class CPPSemantics { if( exp instanceof IASTLiteralExpression && ((IASTLiteralExpression)exp).getKind() == IASTLiteralExpression.lk_integer_constant ) { - if( Integer.decode( exp.toString() ).intValue() == 0 ){ - cost.rank = Cost.CONVERSION_RANK; - cost.conversion = 1; + try { + String val = exp.toString().toLowerCase().replace('u', '0'); + val.replace( 'l', '0' ); + if( Integer.decode( val ).intValue() == 0 ){ + cost.rank = Cost.CONVERSION_RANK; + cost.conversion = 1; + } + } catch( NumberFormatException e ) { } } } else if( sPrev instanceof IPointerType && s instanceof ICPPClassType ){ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java index 206922c531a..085c8f5a575 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPVisitor.java @@ -685,7 +685,7 @@ public class CPPVisitor { ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) parent; if( dtor.getNestedDeclarator() == null ) { while( parent.getParent() instanceof IASTDeclarator ) - parent = (ICPPASTFunctionDeclarator) parent.getParent(); + parent = (IASTDeclarator) parent.getParent(); ASTNodeProperty prop = parent.getPropertyInParent(); if( prop == IASTSimpleDeclaration.DECLARATOR ) return dtor.getFunctionScope();