summaryrefslogtreecommitdiffstats
path: root/test/Headers
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2017-04-27 21:49:45 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2017-04-27 21:49:45 +0000
commit7af3afd004e82e9303f02c2713d8cacd8215f1bd (patch)
treed733ae012ce128d589eb7907d088aa7d39ef6562 /test/Headers
parentfc4c78381af3a65eb64567c94bac097b6b0246e4 (diff)
Headers: Make the type of SIZE_MAX the same as size_t
size_t is usually defined as unsigned long, but on 64-bit platforms, stdint.h currently defines SIZE_MAX using "ull" (unsigned long long). Although this is the same width, it doesn't necessarily have the same alignment or calling convention. It also triggers printf warnings when using the format flag "%zu" to print SIZE_MAX. This changes SIZE_MAX to reuse the compiler-provided __SIZE_MAX__, and provides similar fixes for the other integers: - INTPTR_MIN - INTPTR_MAX - UINTPTR_MAX - PTRDIFF_MIN - PTRDIFF_MAX - INTMAX_MIN - INTMAX_MAX - UINTMAX_MAX - INTMAX_C() - UINTMAX_C() ... and fixes the typedefs for intptr_t and uintptr_t to use __INTPTR_TYPE__ and __UINTPTR_TYPE__ instead of int32_t, effectively reverting r89224, r89226, and r89237 (r89221 already having been effectively reverted). We can probably also kill __INTPTR_WIDTH__, __INTMAX_WIDTH__, and __UINTMAX_WIDTH__ in a follow-up, but I was hesitant to delete all the per-target CHECK lines in this commit since those might serve their own purpose. rdar://problem/11811377 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@301593 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Headers')
-rw-r--r--test/Headers/stdint-typeof-MINMAX.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/Headers/stdint-typeof-MINMAX.cpp b/test/Headers/stdint-typeof-MINMAX.cpp
new file mode 100644
index 0000000000..7014259c59
--- /dev/null
+++ b/test/Headers/stdint-typeof-MINMAX.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=aarch64-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=arm-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=i386-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=mips-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=mips64-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=msp430-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=powerpc64-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=powerpc64-none-netbsd
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=powerpc-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=s390x-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=sparc-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=tce-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=x86_64-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=x86_64-pc-linux-gnu
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=i386-mingw32
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only -triple=xcore-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only
+
+#include <stdint.h>
+#include <stddef.h>
+
+static_assert(__is_same(__typeof__(INTPTR_MIN), intptr_t));
+static_assert(__is_same(__typeof__(INTPTR_MAX), intptr_t));
+static_assert(__is_same(__typeof__(UINTPTR_MAX), uintptr_t));
+static_assert(__is_same(__typeof__(PTRDIFF_MIN), ptrdiff_t));
+static_assert(__is_same(__typeof__(PTRDIFF_MAX), ptrdiff_t));
+static_assert(__is_same(__typeof__(SIZE_MAX), size_t));
+static_assert(__is_same(__typeof__(INTMAX_MIN), intmax_t));
+static_assert(__is_same(__typeof__(INTMAX_MAX), intmax_t));
+static_assert(__is_same(__typeof__(UINTMAX_MAX), uintmax_t));
+static_assert(__is_same(__typeof__(INTMAX_C(5)), intmax_t));
+static_assert(__is_same(__typeof__(UINTMAX_C(5)), uintmax_t));