Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make conversion specifier warning refer to typedef if possible.
For example, the warning for printf("%zu", 42.0); changes from "conversion specifies type 'unsigned long'" to "conversion specifies type 'size_t' (aka 'unsigned long')" git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145697 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
5 changed files
with
74 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// RUN: %clang_cc1 -triple i386-apple-darwin9 -fsyntax-only -verify %s | ||
|
||
int printf(char const *, ...); | ||
|
||
void test(void) { | ||
// size_t, et al. have not been declared yet, | ||
// so the warning should refer to the builtin types. | ||
printf("%jd", 42.0); // expected-warning {{conversion specifies type 'long long'}} | ||
printf("%ju", 42.0); // expected-warning {{conversion specifies type 'unsigned long long'}} | ||
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 __INTMAX_TYPE__ intmax_t; | ||
typedef __UINTMAX_TYPE__ uintmax_t; | ||
typedef __PTRDIFF_TYPE__ ptrdiff_t; | ||
|
||
printf("%jd", 42.0); // expected-warning {{conversion specifies type 'intmax_t' (aka 'long long')}} | ||
printf("%ju", 42.0); // expected-warning {{conversion specifies type 'uintmax_t' (aka 'unsigned long long')}} | ||
printf("%zu", 42.0); // expected-warning {{conversion specifies type 'size_t' (aka 'unsigned long')}} | ||
printf("%td", 42.0); // expected-warning {{conversion specifies type 'ptrdiff_t' (aka 'int')}} | ||
} | ||
|
||
void test2(void) { | ||
typedef void *size_t; | ||
|
||
// The typedef for size_t does not match the builtin type, | ||
// so the warning should not refer to it. | ||
printf("%zu", 42.0); // expected-warning {{conversion specifies type 'unsigned long'}} | ||
} |