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 cd502b3f7ef..2129e9d44f1 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 @@ -3556,7 +3556,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, } for (ICPPASTNameSpecifier nameSpec : node.getQualifier()) { nameSpec.accept(this); - scribe.printNextToken(Token.tCOLONCOLON); + if (peekNextToken() == Token.tCOLONCOLON) + scribe.printNextToken(Token.tCOLONCOLON); } if (peekNextToken() == Token.tCOMPL) { // destructor 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 ec166d5bfa2..8f133335978 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 @@ -3781,4 +3781,34 @@ public class CodeFormatterTest extends BaseUITestCase { public void testTemplateInstantiationOperatorLesser_Bug540252() throws Exception { assertFormatterResult(); } + + //#define WW(x) std::ostringstream(x) + //namespace some_namespace + //{ + // void func() + // { + // try + // { + // WW("1") << "2"; + // } + // catch (const std::exception& e) + // { + // std::cout << "blah...." << std::endl; + // } + // } + //} + + //#define WW(x) std::ostringstream(x) + //namespace some_namespace { + //void func() { + // try { + // WW("1") << "2"; + // } catch (const std::exception& e) { + // std::cout << "blah...." << std::endl; + // } + //} + //} + public void testFormmatterWithMacro_Bug543947() throws Exception { + assertFormatterResult(); + } }