diff --git a/shared/cplusplus/PrettyPrinter.cpp b/shared/cplusplus/PrettyPrinter.cpp index 6fcd06de380c3d7358fbb97bfde38e98d9e9ca50..620cb0bd2a0f4ec08d7b8e7c4f36d283d476d184 100644 --- a/shared/cplusplus/PrettyPrinter.cpp +++ b/shared/cplusplus/PrettyPrinter.cpp @@ -33,6 +33,7 @@ #include "PrettyPrinter.h" #include "AST.h" +#include "Token.h" #include <iostream> #include <string> #include <cassert> @@ -813,7 +814,17 @@ bool PrettyPrinter::visit(NewTypeIdAST *ast) bool PrettyPrinter::visit(NumericLiteralAST *ast) { - out << spell(ast->token); + switch (tokenKind(ast->token)) { + case T_CHAR_LITERAL: + out << '\'' << spell(ast->token) << '\''; + break; + case T_WIDE_CHAR_LITERAL: + out << "L\'" << spell(ast->token) << '\''; + break; + + default: + out << spell(ast->token); + } return false; } diff --git a/tests/manual/cplusplus/tests/t1.cpp b/tests/manual/cplusplus/tests/t1.cpp index 0151673c70bb0dd9847e6136bcebd0539bea4bdb..2a64b291846ec518d3f29a64809b7a32fa4e9986 100644 --- a/tests/manual/cplusplus/tests/t1.cpp +++ b/tests/manual/cplusplus/tests/t1.cpp @@ -30,6 +30,15 @@ class Class { while (x==2) if(a==1) c(); else if (a==2) c(); else c3(); } + + void test_switch() { + switch (int k) { + case 'a': case 'b': case '\\': + return 1; + default: + return 2; + } + } }; class Derived: public Class {