1
0
Fork 0
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:
Andrew Niefer 2004-07-13 17:55:00 +00:00
parent 452625d56d
commit 11f779dbd9
3 changed files with 33 additions and 3 deletions

View file

@ -347,4 +347,23 @@ public class SelectionParseTest extends SelectionParseBaseTest {
assertTrue( node instanceof IASTField ); assertTrue( node instanceof IASTField );
assertEquals( ((IASTField)node).getName(), "stInt" ); //$NON-NLS-1$ 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$
}
} }

View file

@ -1806,11 +1806,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if(kind == IASTExpression.Kind.EXPRESSIONLIST){ if(kind == IASTExpression.Kind.EXPRESSIONLIST){
result = new ExpressionResultList(); result = new ExpressionResultList();
if(lhs != null){ if(lhs != null){
ITypeInfo leftType = ((ASTExpression)lhs).getResultType().getResult(); ExpressionResult resultType = ((ASTExpression)lhs).getResultType();
result.setResult(leftType); if( resultType instanceof ExpressionResultList )
((ExpressionResultList)result).setResult( (ExpressionResultList) resultType );
else
result.setResult( resultType.getResult() );
} }
if(rhs != null){ if(rhs != null){
ITypeInfo rightType = ((ASTExpression)rhs).getResultType().getResult(); ITypeInfo rightType = ((ASTExpression)rhs).getResultType().getResult();
result.setResult(rightType); result.setResult(rightType);
} }
return result; return result;

View file

@ -40,6 +40,14 @@ public class ExpressionResultList extends ExpressionResult {
resultList.add(info); 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 * @return
*/ */