1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 475349 - Formatting of macro with function style

Change-Id: I58f5670749812202464f17336b273b7d1495209f
Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
Marco Stornelli 2019-03-16 16:27:50 +01:00 committed by Jeff Johnston
parent eff560c583
commit 70743bcc78
2 changed files with 14 additions and 1 deletions

View file

@ -581,7 +581,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
private boolean isFunctionStyleMacroExpansion(IASTPreprocessorMacroExpansion macroExpansion) { private boolean isFunctionStyleMacroExpansion(IASTPreprocessorMacroExpansion macroExpansion) {
IASTName name = macroExpansion.getMacroReference(); IASTName name = macroExpansion.getMacroReference();
IMacroBinding binding = (IMacroBinding) name.resolveBinding(); IMacroBinding binding = (IMacroBinding) name.resolveBinding();
return binding.isFunctionStyle() && binding.getParameterList().length > 0; return binding.isFunctionStyle() && binding.getParameterList().length >= 0;
} }
private void formatFunctionStyleMacroExpansion(IASTPreprocessorMacroExpansion macroExpansion) { private void formatFunctionStyleMacroExpansion(IASTPreprocessorMacroExpansion macroExpansion) {

View file

@ -3890,4 +3890,17 @@ public class CodeFormatterTest extends BaseUITestCase {
DefaultCodeFormatterConstants.NEXT_LINE); DefaultCodeFormatterConstants.NEXT_LINE);
assertFormatterResult(); 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();
}
} }