mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
fix bug 68739 - open declaration on fprintf
This commit is contained in:
parent
452625d56d
commit
11f779dbd9
3 changed files with 33 additions and 3 deletions
|
@ -347,4 +347,23 @@ public class SelectionParseTest extends SelectionParseBaseTest {
|
|||
assertTrue( node instanceof IASTField );
|
||||
assertEquals( ((IASTField)node).getName(), "stInt" ); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void testBug68739() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "int fprintf( int *, const char *, ... ); \n" ); //$NON-NLS-1$
|
||||
writer.write( "void boo( int * lcd ) { \n" ); //$NON-NLS-1$
|
||||
writer.write( " /**/fprintf( lcd, \"%c%s 0x%x\", ' ', \"bbb\", 2 ); \n" ); //$NON-NLS-1$
|
||||
writer.write( "} \n" ); //$NON-NLS-1$
|
||||
|
||||
String code = writer.toString();
|
||||
int startIndex = code.indexOf( "/**/fprintf") + 4; //$NON-NLS-1$
|
||||
|
||||
IASTNode node = parse( code, startIndex, startIndex+ 7 );
|
||||
|
||||
assertTrue( node instanceof IASTFunction );
|
||||
assertEquals( ((IASTFunction)node).getName(), "fprintf" ); //$NON-NLS-1$
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1806,11 +1806,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
if(kind == IASTExpression.Kind.EXPRESSIONLIST){
|
||||
result = new ExpressionResultList();
|
||||
if(lhs != null){
|
||||
ITypeInfo leftType = ((ASTExpression)lhs).getResultType().getResult();
|
||||
result.setResult(leftType);
|
||||
ExpressionResult resultType = ((ASTExpression)lhs).getResultType();
|
||||
if( resultType instanceof ExpressionResultList )
|
||||
((ExpressionResultList)result).setResult( (ExpressionResultList) resultType );
|
||||
else
|
||||
result.setResult( resultType.getResult() );
|
||||
}
|
||||
if(rhs != null){
|
||||
ITypeInfo rightType = ((ASTExpression)rhs).getResultType().getResult();
|
||||
ITypeInfo rightType = ((ASTExpression)rhs).getResultType().getResult();
|
||||
result.setResult(rightType);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -40,6 +40,14 @@ public class ExpressionResultList extends ExpressionResult {
|
|||
resultList.add(info);
|
||||
}
|
||||
|
||||
public void setResult( ExpressionResultList result ){
|
||||
List list = result.getResultList();
|
||||
int size = list.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
resultList.add( list.get( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue