Hi all,
the attached patch ensures that __INTPTR_TYPE__ and __UINTPTR_TYPE__ are
consistent as the existing logic would pick e.g. long and unsigned int
on ARM. One issue I found during this is that the NVPTX backend is
using unsigned types here, which doesn't make sense to me.
Joerg
Index: include/clang/Basic/TargetInfo.h
===================================================================
--- include/clang/Basic/TargetInfo.h (revision 212907)
+++ include/clang/Basic/TargetInfo.h (working copy)
@@ -212,7 +212,7 @@
}
IntType getIntPtrType() const { return IntPtrType; }
IntType getUIntPtrType() const {
- return getIntTypeByWidth(getTypeWidth(IntPtrType), false);
+ return getCorrespondingUnsignedType(IntPtrType);
}
IntType getWCharType() const { return WCharType; }
IntType getWIntType() const { return WIntType; }
@@ -222,6 +222,23 @@
IntType getSigAtomicType() const { return SigAtomicType; }
IntType getProcessIDType() const { return ProcessIDType; }
+ static IntType getCorrespondingUnsignedType(IntType T) {
+ switch (T) {
+ case SignedChar:
+ return UnsignedChar;
+ case SignedShort:
+ return UnsignedShort;
+ case SignedInt:
+ return UnsignedInt;
+ case SignedLong:
+ return UnsignedLong;
+ case SignedLongLong:
+ return UnsignedLongLong;
+ default:
+ llvm_unreachable("Unexpected signed integer type");
+ }
+ }
+
/// \brief Return the width (in bits) of the specified integer type enum.
///
/// For example, SignedInt -> getIntWidth().
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp (revision 212907)
+++ lib/Basic/Targets.cpp (working copy)
@@ -1430,7 +1430,8 @@
public:
NVPTX32TargetInfo(const llvm::Triple &Triple) : NVPTXTargetInfo(Triple) {
PointerWidth = PointerAlign = 32;
- SizeType = PtrDiffType = IntPtrType = TargetInfo::UnsignedInt;
+ SizeType = PtrDiffType = TargetInfo::UnsignedInt;
+ IntPtrType = TargetInfo::SignedInt;
DescriptionString = "e-p:32:32-i64:64-v16:16-v32:32-n16:32:64";
}
};
@@ -1439,7 +1440,8 @@
public:
NVPTX64TargetInfo(const llvm::Triple &Triple) : NVPTXTargetInfo(Triple) {
PointerWidth = PointerAlign = 64;
- SizeType = PtrDiffType = IntPtrType = TargetInfo::UnsignedLongLong;
+ SizeType = PtrDiffType = TargetInfo::UnsignedLongLong;
+ IntPtrType = TargetInfo::SignedLongLong;
DescriptionString = "e-i64:64-v16:16-v32:32-n16:32:64";
}
};
Index: lib/Sema/SemaOverload.cpp
===================================================================
--- lib/Sema/SemaOverload.cpp (revision 212907)
+++ lib/Sema/SemaOverload.cpp (working copy)
@@ -2088,6 +2088,11 @@
return true;
}
+ if (FromType->isVoidPointerType()) {
+ ConvertedType = ToType;
+ return true;
+ }
+
// MSVC allows implicit function to void* type conversion.
if (getLangOpts().MicrosoftExt && FromPointeeType->isFunctionType() &&
ToPointeeType->isVoidType()) {
Index: test/Preprocessor/init.c
===================================================================
--- test/Preprocessor/init.c (revision 212907)
+++ test/Preprocessor/init.c (working copy)
@@ -830,7 +830,7 @@
// ARM:#define __UINTMAX_TYPE__ long long unsigned int
// ARM:#define __UINTMAX_WIDTH__ 64
// ARM:#define __UINTPTR_MAX__ 4294967295U
-// ARM:#define __UINTPTR_TYPE__ unsigned int
+// ARM:#define __UINTPTR_TYPE__ long unsigned int
// ARM:#define __UINTPTR_WIDTH__ 32
// ARM:#define __UINT_FAST16_MAX__ 65535U
// ARM:#define __UINT_FAST16_TYPE__ unsigned short
@@ -986,7 +986,7 @@
// ARM-BE:#define __UINTMAX_TYPE__ long long unsigned int
// ARM-BE:#define __UINTMAX_WIDTH__ 64
// ARM-BE:#define __UINTPTR_MAX__ 4294967295U
-// ARM-BE:#define __UINTPTR_TYPE__ unsigned int
+// ARM-BE:#define __UINTPTR_TYPE__ long unsigned int
// ARM-BE:#define __UINTPTR_WIDTH__ 32
// ARM-BE:#define __UINT_FAST16_MAX__ 65535U
// ARM-BE:#define __UINT_FAST16_TYPE__ unsigned short
@@ -1147,7 +1147,7 @@
// ARMEABISOFTFP:#define __UINTMAX_TYPE__ long long unsigned int
// ARMEABISOFTFP:#define __UINTMAX_WIDTH__ 64
// ARMEABISOFTFP:#define __UINTPTR_MAX__ 4294967295U
-// ARMEABISOFTFP:#define __UINTPTR_TYPE__ unsigned int
+// ARMEABISOFTFP:#define __UINTPTR_TYPE__ long unsigned int
// ARMEABISOFTFP:#define __UINTPTR_WIDTH__ 32
// ARMEABISOFTFP:#define __UINT_FAST16_MAX__ 65535U
// ARMEABISOFTFP:#define __UINT_FAST16_TYPE__ unsigned short
@@ -1308,7 +1308,7 @@
// ARMEABIHARDFP:#define __UINTMAX_TYPE__ long long unsigned int
// ARMEABIHARDFP:#define __UINTMAX_WIDTH__ 64
// ARMEABIHARDFP:#define __UINTPTR_MAX__ 4294967295U
-// ARMEABIHARDFP:#define __UINTPTR_TYPE__ unsigned int
+// ARMEABIHARDFP:#define __UINTPTR_TYPE__ long unsigned int
// ARMEABIHARDFP:#define __UINTPTR_WIDTH__ 32
// ARMEABIHARDFP:#define __UINT_FAST16_MAX__ 65535U
// ARMEABIHARDFP:#define __UINT_FAST16_TYPE__ unsigned short
@@ -1466,7 +1466,7 @@
// ARM-NETBSD:#define __UINTMAX_TYPE__ long long unsigned int
// ARM-NETBSD:#define __UINTMAX_WIDTH__ 64
// ARM-NETBSD:#define __UINTPTR_MAX__ 4294967295U
-// ARM-NETBSD:#define __UINTPTR_TYPE__ unsigned int
+// ARM-NETBSD:#define __UINTPTR_TYPE__ long unsigned int
// ARM-NETBSD:#define __UINTPTR_WIDTH__ 32
// ARM-NETBSD:#define __UINT_FAST16_MAX__ 65535U
// ARM-NETBSD:#define __UINT_FAST16_TYPE__ unsigned short
@@ -2157,7 +2157,7 @@
// MIPS32BE:#define __UINTMAX_TYPE__ long long unsigned int
// MIPS32BE:#define __UINTMAX_WIDTH__ 64
// MIPS32BE:#define __UINTPTR_MAX__ 4294967295U
-// MIPS32BE:#define __UINTPTR_TYPE__ unsigned int
+// MIPS32BE:#define __UINTPTR_TYPE__ long unsigned int
// MIPS32BE:#define __UINTPTR_WIDTH__ 32
// MIPS32BE:#define __UINT_FAST16_MAX__ 65535U
// MIPS32BE:#define __UINT_FAST16_TYPE__ unsigned short
@@ -2328,7 +2328,7 @@
// MIPS32EL:#define __UINTMAX_TYPE__ long long unsigned int
// MIPS32EL:#define __UINTMAX_WIDTH__ 64
// MIPS32EL:#define __UINTPTR_MAX__ 4294967295U
-// MIPS32EL:#define __UINTPTR_TYPE__ unsigned int
+// MIPS32EL:#define __UINTPTR_TYPE__ long unsigned int
// MIPS32EL:#define __UINTPTR_WIDTH__ 32
// MIPS32EL:#define __UINT_FAST16_MAX__ 65535U
// MIPS32EL:#define __UINT_FAST16_TYPE__ unsigned short
@@ -2999,7 +2999,7 @@
// MSP430:#define __UINTMAX_TYPE__ long long unsigned int
// MSP430:#define __UINTMAX_WIDTH__ 64
// MSP430:#define __UINTPTR_MAX__ 65535U
-// MSP430:#define __UINTPTR_TYPE__ unsigned short
+// MSP430:#define __UINTPTR_TYPE__ unsigned int
// MSP430:#define __UINTPTR_WIDTH__ 16
// MSP430:#define __UINT_FAST16_MAX__ 65535U
// MSP430:#define __UINT_FAST16_TYPE__ unsigned short
@@ -3075,8 +3075,8 @@
// NVPTX32:#define __INTMAX_MAX__ 9223372036854775807LL
// NVPTX32:#define __INTMAX_TYPE__ long long int
// NVPTX32:#define __INTMAX_WIDTH__ 64
-// NVPTX32:#define __INTPTR_MAX__ 4294967295U
-// NVPTX32:#define __INTPTR_TYPE__ unsigned int
+// NVPTX32:#define __INTPTR_MAX__ 2147483647
+// NVPTX32:#define __INTPTR_TYPE__ int
// NVPTX32:#define __INTPTR_WIDTH__ 32
// NVPTX32:#define __INT_FAST16_MAX__ 32767
// NVPTX32:#define __INT_FAST16_TYPE__ short
@@ -3227,8 +3227,8 @@
// NVPTX64:#define __INTMAX_MAX__ 9223372036854775807LL
// NVPTX64:#define __INTMAX_TYPE__ long long int
// NVPTX64:#define __INTMAX_WIDTH__ 64
-// NVPTX64:#define __INTPTR_MAX__ 18446744073709551615ULL
-// NVPTX64:#define __INTPTR_TYPE__ long long unsigned int
+// NVPTX64:#define __INTPTR_MAX__ 9223372036854775807LL
+// NVPTX64:#define __INTPTR_TYPE__ long long int
// NVPTX64:#define __INTPTR_WIDTH__ 64
// NVPTX64:#define __INT_FAST16_MAX__ 32767
// NVPTX64:#define __INT_FAST16_TYPE__ short
@@ -3303,8 +3303,8 @@
// NVPTX64:#define __UINTMAX_MAX__ 18446744073709551615ULL
// NVPTX64:#define __UINTMAX_TYPE__ long long unsigned int
// NVPTX64:#define __UINTMAX_WIDTH__ 64
-// NVPTX64:#define __UINTPTR_MAX__ 18446744073709551615UL
-// NVPTX64:#define __UINTPTR_TYPE__ long unsigned int
+// NVPTX64:#define __UINTPTR_MAX__ 18446744073709551615ULL
+// NVPTX64:#define __UINTPTR_TYPE__ long long unsigned int
// NVPTX64:#define __UINTPTR_WIDTH__ 64
// NVPTX64:#define __UINT_FAST16_MAX__ 65535U
// NVPTX64:#define __UINT_FAST16_TYPE__ unsigned short
@@ -3461,7 +3461,7 @@
// PPC603E:#define __UINTMAX_TYPE__ long long unsigned int
// PPC603E:#define __UINTMAX_WIDTH__ 64
// PPC603E:#define __UINTPTR_MAX__ 4294967295U
-// PPC603E:#define __UINTPTR_TYPE__ unsigned int
+// PPC603E:#define __UINTPTR_TYPE__ long unsigned int
// PPC603E:#define __UINTPTR_WIDTH__ 32
// PPC603E:#define __UINT_FAST16_MAX__ 65535U
// PPC603E:#define __UINT_FAST16_TYPE__ unsigned short
@@ -4301,7 +4301,7 @@
// PPC:#define __UINTMAX_TYPE__ long long unsigned int
// PPC:#define __UINTMAX_WIDTH__ 64
// PPC:#define __UINTPTR_MAX__ 4294967295U
-// PPC:#define __UINTPTR_TYPE__ unsigned int
+// PPC:#define __UINTPTR_TYPE__ long unsigned int
// PPC:#define __UINTPTR_WIDTH__ 32
// PPC:#define __UINT_FAST16_MAX__ 65535U
// PPC:#define __UINT_FAST16_TYPE__ unsigned short
@@ -4619,7 +4619,7 @@
// PPC-DARWIN:#define __UINTMAX_TYPE__ long long unsigned int
// PPC-DARWIN:#define __UINTMAX_WIDTH__ 64
// PPC-DARWIN:#define __UINTPTR_MAX__ 4294967295U
-// PPC-DARWIN:#define __UINTPTR_TYPE__ unsigned int
+// PPC-DARWIN:#define __UINTPTR_TYPE__ long unsigned int
// PPC-DARWIN:#define __UINTPTR_WIDTH__ 32
// PPC-DARWIN:#define __UINT_FAST16_MAX__ 65535U
// PPC-DARWIN:#define __UINT_FAST16_TYPE__ unsigned short
@@ -4915,7 +4915,7 @@
// SPARC:#define __UINTMAX_TYPE__ long long unsigned int
// SPARC:#define __UINTMAX_WIDTH__ 64
// SPARC:#define __UINTPTR_MAX__ 4294967295U
-// SPARC:#define __UINTPTR_TYPE__ unsigned int
+// SPARC:#define __UINTPTR_TYPE__ long unsigned int
// SPARC:#define __UINTPTR_WIDTH__ 32
// SPARC:#define __UINT_FAST16_MAX__ 65535U
// SPARC:#define __UINT_FAST16_TYPE__ unsigned short
@@ -5571,6 +5571,7 @@
// SPARCV9:#define __LP64__ 1
// SPARCV9:#define __SIZEOF_LONG__ 8
// SPARCV9:#define __SIZEOF_POINTER__ 8
+// SPARCV9:#define __UINTPTR_TYPE__ long unsigned int
//
// RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-openbsd < /dev/null | FileCheck -check-prefix SPARC64-OBSD %s
// SPARC64-OBSD:#define __INT64_TYPE__ long long int
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits