================
@@ -4026,10 +4026,20 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, 
Scope *UDLScope) {
         // Does it fit in size_t?
         if (ResultVal.isIntN(SizeTSize)) {
           // Does it fit in ssize_t?
-          if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0)
-            Ty = Context.getSignedSizeType();
-          else if (AllowUnsigned)
-            Ty = Context.getSizeType();
+          if (!Literal.isUnsigned && ResultVal[SizeTSize - 1] == 0) {
+            auto SignedSize = Context.getSignedSizeType();
+            if (auto PtrDiff = Context.getCGlobalCXXStdNSTypedef(
+                    getStdNamespace(), "ptrdiff_t");
+                Context.hasSameType(PtrDiff, SignedSize))
+              Ty = PtrDiff;
+            else if (auto SSize = Context.getCGlobalCXXStdNSTypedef(
+                         getStdNamespace(), "ssize_t");
+                     Context.hasSameType(SSize, SignedSize))
+              Ty = SSize;
+          } else if (AllowUnsigned) {
+            Ty = Context.getCGlobalCXXStdNSTypedef(getStdNamespace(), "size_t",
----------------
YexuanXiao wrote:

I'm looking into it.

https://github.com/llvm/llvm-project/pull/136542
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to