From 70743bcc784e0df450564f68b15adf07d74b9233 Mon Sep 17 00:00:00 2001
From: Marco Stornelli <marco.stornelli@gmail.com>
Date: Sat, 16 Mar 2019 16:27:50 +0100
Subject: [PATCH] Bug 475349 - Formatting of macro with function style

Change-Id: I58f5670749812202464f17336b273b7d1495209f
Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
---
 .../internal/formatter/CodeFormatterVisitor.java    |  2 +-
 .../cdt/ui/tests/text/CodeFormatterTest.java        | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

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 312340d92ba..aad171e7f8c 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 10c2d040e84..a921e2bff3f 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();
+	}
 }