From 8ec03e6bcd7d7ed7ee1e22c96bcfb46b86cdc3bf Mon Sep 17 00:00:00 2001
From: Roberto Raggi <qtc-committer@nokia.com>
Date: Wed, 7 Jan 2009 10:49:08 +0100
Subject: [PATCH] Pretty print char ltierals and wide char literals.

---
 shared/cplusplus/PrettyPrinter.cpp  | 13 ++++++++++++-
 tests/manual/cplusplus/tests/t1.cpp |  9 +++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/shared/cplusplus/PrettyPrinter.cpp b/shared/cplusplus/PrettyPrinter.cpp
index 6fcd06de380..620cb0bd2a0 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 0151673c70b..2a64b291846 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 {
-- 
GitLab