1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-11 02:05:39 +02:00

fix bug 72721: [Parser] new expression Constructor call with expression arg

This commit is contained in:
Andrew Niefer 2004-09-23 15:12:02 +00:00
parent 08f62553a6
commit 5e62215526
2 changed files with 24 additions and 2 deletions

View file

@ -390,4 +390,20 @@ public class SelectionParseTest extends SelectionParseBaseTest {
assertTrue( node instanceof IASTVariable );
assertEquals( ((IASTVariable)node).getName(), "FOUND_ME" ); //$NON-NLS-1$
}
public void testBug72721() throws Exception{
Writer writer = new StringWriter();
writer.write(" class ABC { public: ABC(int); }; \n"); //$NON-NLS-1$
writer.write("void f() { \n"); //$NON-NLS-1$
writer.write(" int j = 1; \n"); //$NON-NLS-1$
writer.write(" new ABC( j + 1 ); \n"); //$NON-NLS-1$
writer.write("} \n"); //$NON-NLS-1$
String code = writer.toString();
int startIndex = code.indexOf( "ABC(" ); //$NON-NLS-1$
IASTNode node = parse( code, startIndex, startIndex + 3 );
assertTrue( node instanceof IASTMethod );
assertEquals( ((IASTMethod)node).getName(), "ABC" ); //$NON-NLS-1$
assertTrue( ((IASTMethod)node).isConstructor() );
}
}

View file

@ -1168,7 +1168,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
List parameters = new ArrayList();
while( expressionList != null ){
parameters.add( expressionList.getResultType().getResult() );
expressionList = (ASTExpression) expressionList.getRHSExpression();
if( expressionList.getExpressionKind() == IASTExpression.Kind.EXPRESSIONLIST )
expressionList = (ASTExpression) expressionList.getRHSExpression();
else
expressionList = null;
}
IParameterizedSymbol constructor = null;
@ -3610,7 +3613,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ASTExpression expressionList = (ASTExpression) newInitializerExpressions.get(i);
while( expressionList != null ){
parameters.add( expressionList.getResultType().getResult() );
expressionList = (ASTExpression) expressionList.getRHSExpression();
if( expressionList.getExpressionKind() == IASTExpression.Kind.EXPRESSIONLIST )
expressionList = (ASTExpression) expressionList.getRHSExpression();
else
expressionList = null;
}
}