From 1346717068fbc6e63994c5c66377a4ab62e3f32e Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Wed, 1 Apr 2015 20:29:18 +0000 Subject: [PATCH] Set the type of ptrdiff_t to signed on NVPTX targets It was unsigned before, which is unlike any other target and also doesn't make much sense. llvm-svn: 233836 --- clang/lib/Basic/Targets.cpp | 10 ++++++---- clang/test/Preprocessor/init.c | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 33dfcca80457..fb2588622c1f 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -1595,20 +1595,22 @@ public: public: NVPTX32TargetInfo(const llvm::Triple &Triple) : NVPTXTargetInfo(Triple) { PointerWidth = PointerAlign = 32; - SizeType = PtrDiffType = TargetInfo::UnsignedInt; + SizeType = TargetInfo::UnsignedInt; + PtrDiffType = TargetInfo::SignedInt; IntPtrType = TargetInfo::SignedInt; DescriptionString = "e-p:32:32-i64:64-v16:16-v32:32-n16:32:64"; - } + } }; class NVPTX64TargetInfo : public NVPTXTargetInfo { public: NVPTX64TargetInfo(const llvm::Triple &Triple) : NVPTXTargetInfo(Triple) { PointerWidth = PointerAlign = 64; - SizeType = PtrDiffType = TargetInfo::UnsignedLong; + SizeType = TargetInfo::UnsignedLong; + PtrDiffType = TargetInfo::SignedLong; IntPtrType = TargetInfo::SignedLong; DescriptionString = "e-i64:64-v16:16-v32:32-n16:32:64"; - } + } }; static const unsigned R600AddrSpaceMap[] = { diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index 4bc46c8f1dc7..9bda63a1cf85 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -E -dM -x assembler-with-cpp < /dev/null | FileCheck -check-prefix ASM %s +/PtrDiffType / RUN: %clang_cc1 -E -dM -x assembler-with-cpp < /dev/null | FileCheck -check-prefix ASM %s // // ASM:#define __ASSEMBLER__ 1 // @@ -4769,7 +4769,7 @@ // NVPTX32:#define __NVPTX__ 1 // NVPTX32:#define __POINTER_WIDTH__ 32 // NVPTX32:#define __PRAGMA_REDEFINE_EXTNAME 1 -// NVPTX32:#define __PTRDIFF_TYPE__ unsigned int +// NVPTX32:#define __PTRDIFF_TYPE__ int // NVPTX32:#define __PTRDIFF_WIDTH__ 32 // NVPTX32:#define __PTX__ 1 // NVPTX32:#define __SCHAR_MAX__ 127 @@ -4956,7 +4956,7 @@ // NVPTX64:#define __NVPTX__ 1 // NVPTX64:#define __POINTER_WIDTH__ 64 // NVPTX64:#define __PRAGMA_REDEFINE_EXTNAME 1 -// NVPTX64:#define __PTRDIFF_TYPE__ long unsigned int +// NVPTX64:#define __PTRDIFF_TYPE__ long int // NVPTX64:#define __PTRDIFF_WIDTH__ 64 // NVPTX64:#define __PTX__ 1 // NVPTX64:#define __SCHAR_MAX__ 127