From 309ffab61f6253d61fe16a8d5d0a97a56b055328 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Wed, 3 Nov 1993 20:09:12 +0000 Subject: [PATCH] (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 --- gcc/c-common.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gcc/c-common.c b/gcc/c-common.c index 58c83a6f154..cb6e845c56e 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)",