diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index 3bb46f31da8..f5947591368 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -3615,6 +3615,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, private int visit(IASTCaseStatement node) { IASTExpression constant = node.getExpression(); + formatLeadingAttributes(node); if (constant == null) { scribe.printNextToken(Token.t_default); scribe.printNextToken(Token.tCOLON, preferences.insert_space_before_colon_in_default); @@ -3628,6 +3629,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } private int visit(IASTDefaultStatement node) { + formatLeadingAttributes(node); scribe.printNextToken(Token.t_default); scribe.printNextToken(Token.tCOLON, preferences.insert_space_before_colon_in_default); return PROCESS_SKIP; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java index 30e51cc960e..f98eecadcda 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java @@ -3384,4 +3384,25 @@ public class CodeFormatterTest extends BaseUITestCase { public void testInlineNamespace_Bug532849() throws Exception { assertFormatterResult(); } + + //void f() { + // switch (1) { + // [[foo]] case 1: + // break; + // [[foo]] default: + // break; + // } + //} + + //void f() { + // switch (1) { + // [[foo]] case 1: + // break; + // [[foo]] default: + // break; + // } + //} + public void testFormatAttributedLabelStatements_Bug535266() throws Exception { + assertFormatterResult(); + } }