summaryrefslogtreecommitdiff
path: root/shared/cplusplus/PrettyPrinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'shared/cplusplus/PrettyPrinter.cpp')
-rw-r--r--shared/cplusplus/PrettyPrinter.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/shared/cplusplus/PrettyPrinter.cpp b/shared/cplusplus/PrettyPrinter.cpp
index 620cb0bd2a..2acb98b14e 100644
--- a/shared/cplusplus/PrettyPrinter.cpp
+++ b/shared/cplusplus/PrettyPrinter.cpp
@@ -198,7 +198,24 @@ bool PrettyPrinter::visit(CaseStatementAST *ast)
out << "case ";
accept(ast->expression);
out << ':';
- accept(ast->statement);
+ if (! ast->statement) {
+ newline();
+ return false;
+ }
+
+ if (ast->statement->asCompoundStatement()) {
+ out << ' ';
+ accept(ast->statement);
+ } else if (ast->statement->asCaseStatement() || ast->statement->asLabeledStatement()) {
+ newline();
+ accept(ast->statement);
+ } else {
+ indent();
+ newline();
+ accept(ast->statement);
+ deindent();
+ newline();
+ }
return false;
}