From: Eli Bendersky Date: Wed, 1 Apr 2015 20:29:18 +0000 (+0000) Subject: Set the type of ptrdiff_t to signed on NVPTX targets X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7ce861f25762f2a55965e9afbc8f4edefec14de4;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233836 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 33dfcca804..fb2588622c 100644 --- a/lib/Basic/Targets.cpp +++ b/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/test/Preprocessor/init.c b/test/Preprocessor/init.c index 4bc46c8f1d..9bda63a1cf 100644 --- a/test/Preprocessor/init.c +++ b/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