diff --git a/shared/cplusplus/PrettyPrinter.cpp b/shared/cplusplus/PrettyPrinter.cpp index 8a8b43bb37b0bacd64e693735c7980166e27749f..4adc69e78c3158b1495b51166fdcd2f249cb6f7f 100644 --- a/shared/cplusplus/PrettyPrinter.cpp +++ b/shared/cplusplus/PrettyPrinter.cpp @@ -453,11 +453,20 @@ bool PrettyPrinter::visit(EnumSpecifierAST *ast) out << ' '; accept(ast->name); } + out << ' '; out << '{'; - for (EnumeratorAST *it = ast->enumerators; it; it = it->next) { - accept(it); - if (it->next) - out << ", "; + if (ast->enumerators) { + indent(); + newline(); + for (EnumeratorAST *it = ast->enumerators; it; it = it->next) { + accept(it); + if (it->next) { + out << ", "; + newline(); + } + } + deindent(); + newline(); } out << '}'; return false; @@ -599,9 +608,10 @@ bool PrettyPrinter::visit(IfStatementAST *ast) out << '('; accept(ast->condition); out << ')'; - if (ast->statement->asCompoundStatement()) + if (ast->statement->asCompoundStatement()) { + out << ' '; accept(ast->statement); - else { + } else { indent(); newline(); accept(ast->statement); diff --git a/tests/manual/cplusplus/tests/t1.cpp b/tests/manual/cplusplus/tests/t1.cpp index 362146fc19b3e18e9811a42c1e9b798107971950..75c4666d55b3c1a75d22c957ee409009151471e2 100644 --- a/tests/manual/cplusplus/tests/t1.cpp +++ b/tests/manual/cplusplus/tests/t1.cpp @@ -2,7 +2,9 @@ class Class { int a, b; - enum zoo { a, b }; + enum zoo { a = 1, b = a + 2 + x::y<10>::value }; + + enum {}; typedef enum { k }; @@ -12,5 +14,11 @@ class Class { void another_foo() { int a = static_cast<int>(1+2/3*4-5%6+(7&8)); } + + void test_if() { + if (a == 10) return 1; + else if (b == 20) return 2; + else if (c == 30) { x = 1; } + } };