]> granicus.if.org Git - clang/commitdiff
Ensure we don't print 123ULL_foo when printing a user-defined integer literal.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 8 Mar 2012 09:02:38 +0000 (09:02 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 8 Mar 2012 09:02:38 +0000 (09:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152303 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/StmtPrinter.cpp
test/SemaCXX/cxx11-ast-print.cpp

index b8e68d8574a74f4978e67e20006d47275a3bd43a..d2233e094bb51320b4ecbc68cca6b0e45f08ff66 100644 (file)
@@ -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:
index 1f6f94781251a06b4761ee8f52814889e31c1394..33684ceb4c5f8bf3cb766a0763bb3b39325ad16c 100644 (file)
@@ -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;