aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-08 09:02:38 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-08 09:02:38 +0000
commit916883004c36291b70355d5e73abb05e138804fb (patch)
tree8d63dce1065041c3f5e06fb70515e1c19edb26ed
parentb453ad3214d00acc51c9aa702c76c58354d84b84 (diff)
Ensure we don't print 123ULL_foo when printing a user-defined integer literal.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152303 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/StmtPrinter.cpp7
-rw-r--r--test/SemaCXX/cxx11-ast-print.cpp10
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index b8e68d8574..d2233e094b 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -1237,7 +1237,12 @@ void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) {
}
break;
}
- case UserDefinedLiteral::LOK_Integer:
+ case UserDefinedLiteral::LOK_Integer: {
+ // Print integer literal without suffix.
+ IntegerLiteral *Int = cast<IntegerLiteral>(Node->getCookedLiteral());
+ OS << Int->getValue().toString(10, /*isSigned*/false);
+ break;
+ }
case UserDefinedLiteral::LOK_Floating:
case UserDefinedLiteral::LOK_String:
case UserDefinedLiteral::LOK_Character:
diff --git a/test/SemaCXX/cxx11-ast-print.cpp b/test/SemaCXX/cxx11-ast-print.cpp
index 1f6f947812..33684ceb4c 100644
--- a/test/SemaCXX/cxx11-ast-print.cpp
+++ b/test/SemaCXX/cxx11-ast-print.cpp
@@ -4,9 +4,19 @@
// CHECK: decltype(nullptr) operator "" _foo(const char *p, decltype(sizeof(int)));
auto operator"" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
+// CHECK: decltype(""_foo) operator "" _bar(unsigned long long);
+decltype(""_foo) operator"" _bar(unsigned long long);
+
+// CHECK: decltype(42_bar) operator "" _baz(long double);
+decltype(42_bar) operator"" _baz(long double);
+
// CHECK: const char *p1 = "bar1"_foo;
const char *p1 = "bar1"_foo;
// CHECK: const char *p2 = "bar2"_foo;
const char *p2 = R"x(bar2)x"_foo;
// CHECK: const char *p3 = u8"bar3"_foo;
const char *p3 = u8"bar3"_foo;
+// CHECK: const char *p4 = 297_bar;
+const char *p4 = 0x129_bar;
+// CHECK: const char *p5 = 1.0E+12_baz;
+const char *p5 = 1e12_baz;