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 1e402ba02bd..cd502b3f7ef 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 @@ -3570,8 +3570,12 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, IASTName name = node.getTemplateName(); name.accept(this); if (peekNextToken() == Token.tLT) { - scribe.printNextToken(Token.tLT, - preferences.insert_space_before_opening_angle_bracket_in_template_arguments); + char[] simpleId = name.getSimpleID(); + if (simpleId[simpleId.length - 1] == '<') + scribe.printNextToken(Token.tLT, true); + else + scribe.printNextToken(Token.tLT, + preferences.insert_space_before_opening_angle_bracket_in_template_arguments); if (preferences.insert_space_after_opening_angle_bracket_in_template_arguments) { scribe.space(); } 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 d17b169fa64..ec166d5bfa2 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 @@ -3758,4 +3758,27 @@ public class CodeFormatterTest extends BaseUITestCase { public void testTemplateIdWithMacro4_Bug406231() throws Exception { assertFormatterResult(); } + + //class data + //{ + //public: + // template bool operator< (x const &n) const + // { + // return n < 0; + // } + //}; + ////explicit instantiation + //template bool data::operator< (int const &) const; + + //class data { + //public: + // template bool operator<(x const &n) const { + // return n < 0; + // } + //}; + ////explicit instantiation + //template bool data::operator< (int const &) const; + public void testTemplateInstantiationOperatorLesser_Bug540252() throws Exception { + assertFormatterResult(); + } }