1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 201330: code formater fooled by sizeof()

This commit is contained in:
Anton Leherbauer 2007-08-28 09:55:26 +00:00
parent c288c84fc8
commit c6c6199a06
2 changed files with 12 additions and 4 deletions

View file

@ -1295,9 +1295,6 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
private int visit(IASTIdExpression node) { private int visit(IASTIdExpression node) {
node.getName().accept(this); node.getName().accept(this);
if (scribe.printComment()) {
scribe.space();
}
return PROCESS_SKIP; return PROCESS_SKIP;
} }
@ -1453,6 +1450,9 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
break; break;
case IASTUnaryExpression.op_sizeof: case IASTUnaryExpression.op_sizeof:
scribe.printNextToken(Token.t_sizeof, scribe.printComment()); scribe.printNextToken(Token.t_sizeof, scribe.printComment());
if (peekNextToken() != Token.tLPAREN) {
scribe.space();
}
operand.accept(this); operand.accept(this);
break; break;
default: default:
@ -1487,7 +1487,6 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
// operand 2 // operand 2
final IASTExpression op2= node.getOperand2(); final IASTExpression op2= node.getOperand2();
op2.accept(this); op2.accept(this);
scribe.printTrailingComment();
ok = true; ok = true;
} catch (AlignmentException e) { } catch (AlignmentException e) {

View file

@ -141,6 +141,15 @@ public class CodeFormatterTest extends BaseUITestCase {
assertFormatterResult(); assertFormatterResult();
} }
//int x;
//int a = sizeof x ;
//int x;
//int a = sizeof x;
public void testSizeofExpression_Bug201330() throws Exception {
assertFormatterResult();
}
//void foo(){ //void foo(){
//for(;;){ //for(;;){
//int a=0; //int a=0;