]> granicus.if.org Git - clang/commitdiff
PR9772: Fix the definition of WINT_MIN and WINT_MAX on Linux -ffreestanding.
authorEli Friedman <eli.friedman@gmail.com>
Thu, 21 Apr 2011 05:45:45 +0000 (05:45 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 21 Apr 2011 05:45:45 +0000 (05:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129907 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/InitPreprocessor.cpp
lib/Headers/stdint.h
test/Preprocessor/stdint.c

index 928e84b18567964670efe8da2f4e06e2d2568718..ff3cf4b9cdb52255fe2e78706f77294e2daa36a7 100644 (file)
@@ -419,6 +419,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
   if (!LangOpts.CharIsSigned)
     Builder.defineMacro("__CHAR_UNSIGNED__");
 
+  if (!TargetInfo::isTypeSigned(TI.getWIntType()))
+    Builder.defineMacro("__WINT_UNSIGNED__");
+
   // Define exact-width integer types for stdint.h
   Builder.defineMacro("__INT" + llvm::Twine(TI.getCharWidth()) + "_TYPE__",
                       "char");
index d2ba8de13556e375763ee26bfcecf1f136e39bc5..ed3240abc9a8ff5f85e8b09fab7b76ef2c92849c 100644 (file)
@@ -630,8 +630,13 @@ typedef __UINTMAX_TYPE__ uintmax_t;
 /* C99 7.18.3 Limits of other integer types. */
 #define SIG_ATOMIC_MIN __INTN_MIN(__SIG_ATOMIC_WIDTH__)
 #define SIG_ATOMIC_MAX __INTN_MAX(__SIG_ATOMIC_WIDTH__)
-#define WINT_MIN       __INTN_MIN(__WINT_WIDTH__)
-#define WINT_MAX       __INTN_MAX(__WINT_WIDTH__)
+#ifdef __WINT_UNSIGNED__
+# define WINT_MIN       0
+# define WINT_MAX       __UINTN_MAX(__WINT_WIDTH__)
+#else
+# define WINT_MIN       __INTN_MIN(__WINT_WIDTH__)
+# define WINT_MAX       __INTN_MAX(__WINT_WIDTH__)
+#endif
 
 /* FIXME: if we ever support a target with unsigned wchar_t, this should be
  * 0 .. Max.
index b3ae8438033c185eb1dbcd63cac02bfc4490eeed..4821cf423f4ca63412ffd3f9408a4768c662aaca 100644 (file)
 // X86_64:UINTMAX_C_(0) 0UL
 //
 //
+// RUN: %clang_cc1 -E -ffreestanding -triple=x86_64-pc-linux-gnu %s | FileCheck -check-prefix X86_64_LINUX %s
+//
+// X86_64_LINUX:WINT_MIN_ 0
+// X86_64_LINUX:WINT_MAX_ 4294967295U
+//
+//
 // stdint.h forms several macro definitions by pasting together identifiers
 // to form names (eg. int32_t is formed from int ## 32 ## _t). The following 
 // case tests that these joining operations are performed correctly even if