From e2b34142c369fba25aa85082e442e2bc7eb62ae4 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Wed, 20 Feb 2013 01:56:21 +0000 Subject: [PATCH] intmax_t is long long on Darwin, not long. llvm-svn: 175588 --- clang/lib/Basic/Targets.cpp | 2 ++ clang/test/FixIt/format-darwin.m | 23 +++++++++++++++++++++++ clang/test/Sema/format-strings-size_t.c | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index eaf2e7d0..4e66fe5 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -3119,6 +3119,8 @@ class DarwinX86_64TargetInfo : public DarwinTargetInfo { public: DarwinX86_64TargetInfo(const std::string& triple) : DarwinTargetInfo(triple) { + IntMaxType = SignedLongLong; + UIntMaxType = UnsignedLongLong; Int64Type = SignedLongLong; MaxVectorAlign = 256; } diff --git a/clang/test/FixIt/format-darwin.m b/clang/test/FixIt/format-darwin.m index cfaac29..0724e57 100644 --- a/clang/test/FixIt/format-darwin.m +++ b/clang/test/FixIt/format-darwin.m @@ -21,6 +21,7 @@ typedef int NSInteger; typedef unsigned int NSUInteger; typedef long SInt32; typedef unsigned long UInt32; + #endif NSInteger getNSInteger(); @@ -210,3 +211,25 @@ void testCapitals() { // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:13-[[@LINE-3]]:14}:"d" // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:14}:"%D" } + + +// The OS X headers do not always use __INTMAX_TYPE__ and friends. +typedef long long intmax_t; +typedef unsigned long long uintmax_t; +#define INTMAX_C(X) (X ## LL) +#define UINTMAX_C(X) (X ## ULL) + +void testIntMax(intmax_t i, uintmax_t u) { + printf("%d", i); // expected-warning{{format specifies type 'int' but the argument has type 'intmax_t' (aka 'long long')}} + printf("%d", u); // expected-warning{{format specifies type 'int' but the argument has type 'uintmax_t' (aka 'unsigned long long')}} + + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:13}:"%jd" + // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:11-[[@LINE-3]]:13}:"%ju" + + printf("%jd", i); // no-warning + printf("%ju", u); // no-warning + + printf("%jd", INTMAX_C(5)); // no-warning + printf("%ju", INTMAX_C(5)); // no-warning +} + diff --git a/clang/test/Sema/format-strings-size_t.c b/clang/test/Sema/format-strings-size_t.c index 5058a76..5751f88 100644 --- a/clang/test/Sema/format-strings-size_t.c +++ b/clang/test/Sema/format-strings-size_t.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s int printf(char const *, ...); -- 2.7.4