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

Bug 298593 - Formatter breaks the code when #defining a placement new

This commit is contained in:
Anton Leherbauer 2010-01-14 13:26:23 +00:00
parent 88e259d1f8
commit a05892cd10
2 changed files with 15 additions and 14 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -2928,18 +2928,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
break; break;
} }
else if (currentOffset == endOffset && i == locations.length - 1) { else if (currentOffset == endOffset && i == locations.length - 1) {
if (node instanceof IASTExpressionList) { scribe.skipRange(startOffset, endOffset);
IASTNode parent= node.getParent();
if (parent != null) {
IASTFileLocation parentLocation= parent.getFileLocation();
int parentEndOffset= parentLocation.getNodeOffset() + parentLocation.getNodeLength();
if (parentEndOffset == endOffset) {
scribe.skipRange(startOffset, endOffset);
}
}
} else {
scribe.skipRange(startOffset, endOffset);
}
break; break;
} }
} }

View file

@ -1307,7 +1307,19 @@ public class CodeFormatterTest extends BaseUITestCase {
// //
// return 0; // return 0;
//} //}
public void testControlStatementsAsMacro_Bug290630() throws Exception { public void testControlStatementsAsMacro_Bug290630() throws Exception {
assertFormatterResult(); assertFormatterResult();
} }
//#define new new(__FILE__, __LINE__)
//void func() {char* a = new char[10];}
//#define new new(__FILE__, __LINE__)
//void func() {
// char* a = new char[10];
//}
public void testPlacementNewAsMacro_Bug298593() throws Exception {
assertFormatterResult();
}
} }