Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarco Stornelli2019-03-16 11:27:50 -0400
committerJeff Johnston2019-04-05 17:28:11 -0400
commit70743bcc784e0df450564f68b15adf07d74b9233 (patch)
tree6ae59b790695287f214e79b2c8f9a0769f458cdc /core
parenteff560c583f419d393c3c6d3d8ea2a0c28bd551e (diff)
downloadorg.eclipse.cdt-70743bcc784e0df450564f68b15adf07d74b9233.tar.gz
org.eclipse.cdt-70743bcc784e0df450564f68b15adf07d74b9233.tar.xz
org.eclipse.cdt-70743bcc784e0df450564f68b15adf07d74b9233.zip
Bug 475349 - Formatting of macro with function style
Change-Id: I58f5670749812202464f17336b273b7d1495209f Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java2
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java13
2 files changed, 14 insertions, 1 deletions
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 312340d92b..aad171e7f8 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
@@ -581,7 +581,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
private boolean isFunctionStyleMacroExpansion(IASTPreprocessorMacroExpansion macroExpansion) {
IASTName name = macroExpansion.getMacroReference();
IMacroBinding binding = (IMacroBinding) name.resolveBinding();
- return binding.isFunctionStyle() && binding.getParameterList().length > 0;
+ return binding.isFunctionStyle() && binding.getParameterList().length >= 0;
}
private void formatFunctionStyleMacroExpansion(IASTPreprocessorMacroExpansion macroExpansion) {
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 10c2d040e8..a921e2bff3 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
@@ -3890,4 +3890,17 @@ public class CodeFormatterTest extends BaseUITestCase {
DefaultCodeFormatterConstants.NEXT_LINE);
assertFormatterResult();
}
+
+ //#define START_SECTION() do { int a = 0; } while (0)
+ //void code() {
+ // START_SECTION();
+ //}
+
+ //#define START_SECTION() do { int a = 0; } while (0)
+ //void code() {
+ // START_SECTION();
+ //}
+ public void testFormmatterWithMacroFuncStyle_Bug475349() throws Exception {
+ assertFormatterResult();
+ }
}

Back to the top