mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 10:15:39 +02:00
fix bug 72721: [Parser] new expression Constructor call with expression arg
This commit is contained in:
parent
08f62553a6
commit
5e62215526
2 changed files with 24 additions and 2 deletions
|
@ -390,4 +390,20 @@ public class SelectionParseTest extends SelectionParseBaseTest {
|
||||||
assertTrue( node instanceof IASTVariable );
|
assertTrue( node instanceof IASTVariable );
|
||||||
assertEquals( ((IASTVariable)node).getName(), "FOUND_ME" ); //$NON-NLS-1$
|
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() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1168,7 +1168,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
List parameters = new ArrayList();
|
List parameters = new ArrayList();
|
||||||
while( expressionList != null ){
|
while( expressionList != null ){
|
||||||
parameters.add( expressionList.getResultType().getResult() );
|
parameters.add( expressionList.getResultType().getResult() );
|
||||||
|
if( expressionList.getExpressionKind() == IASTExpression.Kind.EXPRESSIONLIST )
|
||||||
expressionList = (ASTExpression) expressionList.getRHSExpression();
|
expressionList = (ASTExpression) expressionList.getRHSExpression();
|
||||||
|
else
|
||||||
|
expressionList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
IParameterizedSymbol constructor = null;
|
IParameterizedSymbol constructor = null;
|
||||||
|
@ -3610,7 +3613,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
||||||
ASTExpression expressionList = (ASTExpression) newInitializerExpressions.get(i);
|
ASTExpression expressionList = (ASTExpression) newInitializerExpressions.get(i);
|
||||||
while( expressionList != null ){
|
while( expressionList != null ){
|
||||||
parameters.add( expressionList.getResultType().getResult() );
|
parameters.add( expressionList.getResultType().getResult() );
|
||||||
|
if( expressionList.getExpressionKind() == IASTExpression.Kind.EXPRESSIONLIST )
|
||||||
expressionList = (ASTExpression) expressionList.getRHSExpression();
|
expressionList = (ASTExpression) expressionList.getRHSExpression();
|
||||||
|
else
|
||||||
|
expressionList = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue