[PATCH] D82880: Fix PR35677: UB on __int128_t or __uint128_t template parameters.

David Stone via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 30 08:06:42 PDT 2020


davidstone created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82880

Files:
  clang/lib/AST/StmtPrinter.cpp
  clang/test/AST/ast-print-int128.cpp


Index: clang/test/AST/ast-print-int128.cpp
===================================================================
--- /dev/null
+++ clang/test/AST/ast-print-int128.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -ast-print -std=c++20 %s -o - | FileCheck %s
+
+template <bool>
+struct enable_if {
+};
+
+template <__uint128_t x, typename = typename enable_if<x != 0>::type>
+void f();
+
+template <__int128_t>
+void f();
+
+using T = decltype(f<0>());
+
+// CHECK: using T = decltype(f<0>());
Index: clang/lib/AST/StmtPrinter.cpp
===================================================================
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -1152,6 +1152,12 @@
   case BuiltinType::ULong:     OS << "UL"; break;
   case BuiltinType::LongLong:  OS << "LL"; break;
   case BuiltinType::ULongLong: OS << "ULL"; break;
+  case BuiltinType::Int128:
+    OS << "i128";
+    break;
+  case BuiltinType::UInt128:
+    OS << "Ui128";
+    break;
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82880.274479.patch
Type: text/x-patch
Size: 964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200630/4c508f7b/attachment-0001.bin>


More information about the cfe-commits mailing list