mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
Bug 390324 - Fix cast operator containing func declarator
Change-Id: I935fe1daabd18372062916e5a896896f5cab604f Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
parent
db0cc1f9a4
commit
5b869afec3
2 changed files with 44 additions and 3 deletions
|
@ -2504,13 +2504,19 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
}
|
||||
|
||||
private int visit(IASTCastExpression node) {
|
||||
Runnable tailFormatter = null;
|
||||
switch (node.getOperator()) {
|
||||
case IASTCastExpression.op_cast:
|
||||
scribe.printNextToken(Token.tLPAREN, false);
|
||||
if (preferences.insert_space_after_opening_paren_in_cast) {
|
||||
scribe.space();
|
||||
}
|
||||
node.getTypeId().accept(this);
|
||||
tailFormatter = scribe.takeTailFormatter();
|
||||
try {
|
||||
node.getTypeId().accept(this);
|
||||
} finally {
|
||||
scribe.setTailFormatter(tailFormatter);
|
||||
}
|
||||
try {
|
||||
if (node.getTypeId().getTrailingSyntax().getType() == IToken.tRPAREN) {
|
||||
scribe.printNextToken(Token.tRPAREN, preferences.insert_space_before_closing_paren_in_cast);
|
||||
|
@ -2535,7 +2541,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
if (preferences.insert_space_after_opening_angle_bracket_in_template_arguments) {
|
||||
scribe.space();
|
||||
}
|
||||
node.getTypeId().accept(this);
|
||||
tailFormatter = scribe.takeTailFormatter();
|
||||
try {
|
||||
node.getTypeId().accept(this);
|
||||
} finally {
|
||||
scribe.setTailFormatter(tailFormatter);
|
||||
}
|
||||
scribe.printNextToken(Token.tGT,
|
||||
preferences.insert_space_before_closing_angle_bracket_in_template_arguments);
|
||||
if (preferences.insert_space_before_opening_paren_in_method_invocation) {
|
||||
|
@ -2546,7 +2557,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
if (preferences.insert_space_after_opening_paren_in_method_invocation) {
|
||||
scribe.space();
|
||||
}
|
||||
Runnable tailFormatter = scribe.takeTailFormatter();
|
||||
tailFormatter = scribe.takeTailFormatter();
|
||||
try {
|
||||
node.getOperand().accept(this);
|
||||
} finally {
|
||||
|
|
|
@ -4093,4 +4093,34 @@ public class CodeFormatterTest extends BaseUITestCase {
|
|||
public void testNestedNamespace_Bug546221() throws Exception {
|
||||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//void someAction(int i) {
|
||||
//}
|
||||
//int foo() {
|
||||
// auto f = static_cast<void (*)(int)>(&someAction);
|
||||
//}
|
||||
|
||||
//void someAction(int i) {
|
||||
//}
|
||||
//int foo() {
|
||||
// auto f = static_cast<void (*)(int)>(&someAction);
|
||||
//}
|
||||
public void testCastFuncDeclarator1_Bug390324() throws Exception {
|
||||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//void someAction(int i) {
|
||||
//}
|
||||
//int foo() {
|
||||
// auto f = (void (*)(int)) (&someAction);
|
||||
//}
|
||||
|
||||
//void someAction(int i) {
|
||||
//}
|
||||
//int foo() {
|
||||
// auto f = (void (*)(int)) (&someAction);
|
||||
//}
|
||||
public void testCastFuncDeclarator2_Bug390324() throws Exception {
|
||||
assertFormatterResult();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue