From: Hans Wennborg Date: Fri, 2 Dec 2011 20:32:01 +0000 (+0000) Subject: Make r145697 actually work. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=377cc6e3e8a6d9d0c90a315d29ce84836383d059;p=clang Make r145697 actually work. Use the canonical type of the typedef to compare with the underlying type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145702 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp index b37b23f3b1..e3d76507cd 100644 --- a/lib/Analysis/PrintfFormatString.cpp +++ b/lib/Analysis/PrintfFormatString.cpp @@ -290,7 +290,7 @@ static QualType FindTypedef(Sema &S, const char *Name, QualType Underlying) { if (TypedefDecl *TD = dyn_cast_or_null(D)) { QualType TypedefType = Ctx.getTypedefType(TD, QualType()); - if (TD->getUnderlyingType() == Underlying) + if (Ctx.getCanonicalType(TypedefType) == Underlying) return TypedefType; } diff --git a/test/Sema/format-strings-int-typedefs.c b/test/Sema/format-strings-int-typedefs.c index 931449ccc3..2cac9a875d 100644 --- a/test/Sema/format-strings-int-typedefs.c +++ b/test/Sema/format-strings-int-typedefs.c @@ -10,7 +10,7 @@ void test(void) { printf("%zu", 42.0); // expected-warning {{conversion specifies type 'unsigned long'}} printf("%td", 42.0); // expected-warning {{conversion specifies type 'int'}} - typedef __SIZE_TYPE__ size_t; + typedef __typeof(sizeof(int)) size_t; typedef __INTMAX_TYPE__ intmax_t; typedef __UINTMAX_TYPE__ uintmax_t; typedef __PTRDIFF_TYPE__ ptrdiff_t;