diff options
author | Richard Stallman <rms@gnu.org> | 1993-11-03 20:09:12 +0000 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 1993-11-03 20:09:12 +0000 |
commit | 309ffab61f6253d61fe16a8d5d0a97a56b055328 (patch) | |
tree | a5ef7cef4e305029c4a9f83c61ad1a099fd46524 /gcc/c-common.c | |
parent | 003be4554876a49978b7ca641107f137a87899d7 (diff) | |
download | gcc-309ffab61f6253d61fe16a8d5d0a97a56b055328.zip gcc-309ffab61f6253d61fe16a8d5d0a97a56b055328.tar.gz gcc-309ffab61f6253d61fe16a8d5d0a97a56b055328.tar.bz2 |
(check_format_info): Make warning nicer for mismatch of int vs long, etc.
Don't warn if field width is an unsigned int.
From-SVN: r5981
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 58c83a6..cb6e845 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -685,8 +685,11 @@ check_format_info (info, params) It will work on most machines, because size_t and int have the same mode. But might as well warn anyway, since it will fail on other machines. */ - if (TYPE_MAIN_VARIANT (TREE_TYPE (cur_param)) - != integer_type_node) + if ((TYPE_MAIN_VARIANT (TREE_TYPE (cur_param)) + != integer_type_node) + && + (TYPE_MAIN_VARIANT (TREE_TYPE (cur_param)) + != unsigned_type_node)) { sprintf (message, "field width is not type int (arg %d)", @@ -935,6 +938,14 @@ check_format_info (info, params) that = "different type"; } + /* Make the warning better in case of mismatch of int vs long. */ + if (TREE_CODE (cur_type) == INTEGER_TYPE + && TREE_CODE (wanted_type) == INTEGER_TYPE + && TYPE_PRECISION (cur_type) == TYPE_PRECISION (wanted_type) + && TYPE_NAME (cur_type) != 0 + && TREE_CODE (TYPE_NAME (cur_type)) == TYPE_DECL) + that = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (cur_type))); + if (strcmp (this, that) != 0) { sprintf (message, "%s format, %s arg (arg %d)", |