From 0a7fe8bcd953efbd22d05ec750927de0feaa96da Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Fri, 22 Feb 2019 23:08:23 +0000 Subject: [PATCH] builtin-sprintf-10.c: Cast wchar_t to wint_t to avoid a bogus -Wformat warning in ILP32 (bug 77970). gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/builtin-sprintf-10.c: Cast wchar_t to wint_t to avoid a bogus -Wformat warning in ILP32 (bug 77970). From-SVN: r269137 --- gcc/testsuite/ChangeLog | 5 ++++ .../gcc.dg/tree-ssa/builtin-sprintf-10.c | 29 ++++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dd0437780c8..8d19215db76 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-22 Martin Sebor + + * gcc.dg/tree-ssa/builtin-sprintf-10.c: Cast wchar_t to wint_t + to avoid a bogus -Wformat warning in ILP32 (bug 77970). + 2019-02-22 Harald Anlauf PR fortran/83057 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-10.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-10.c index 837b6f40c99..b64a5e0116e 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-10.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-10.c @@ -5,6 +5,7 @@ typedef __SIZE_TYPE__ size_t; typedef __WCHAR_TYPE__ wchar_t; +typedef __WINT_TYPE__ wint_t; extern int snprintf (char*, size_t, const char*, ...); @@ -50,23 +51,23 @@ void elim_wide_char_call (void) ELIM (snprintf (0, 0, "%lc", L'\0')); ELIM (snprintf (0, 0, "%lc", L'1')); ELIM (snprintf (0, 0, "%lc", L'a')); - ELIM (snprintf (0, 0, "%lc", ws3[0])); - ELIM (snprintf (0, 0, "%lc", ws3[1])); - ELIM (snprintf (0, 0, "%lc", ws3[3])); + ELIM (snprintf (0, 0, "%lc", (wint_t)ws3[0])); + ELIM (snprintf (0, 0, "%lc", (wint_t)ws3[1])); + ELIM (snprintf (0, 0, "%lc", (wint_t)ws3[3])); ELIM (snprintf (0, 0, "%C", L'\0')); ELIM (snprintf (0, 0, "%C", L'9')); ELIM (snprintf (0, 0, "%C", L'z')); - ELIM (snprintf (0, 0, "%C", ws3[0])); - ELIM (snprintf (0, 0, "%C", ws3[1])); - ELIM (snprintf (0, 0, "%C", ws3[3])); + ELIM (snprintf (0, 0, "%C", (wint_t)ws3[0])); + ELIM (snprintf (0, 0, "%C", (wint_t)ws3[1])); + ELIM (snprintf (0, 0, "%C", (wint_t)ws3[3])); /* Verify an unknown character value within the ASCII range. */ if (wc < 1 || 127 < wc) wc = 0; - ELIM (snprintf (0, 0, "%C", wc)); - ELIM (snprintf (0, 0, "%C", wc)); + ELIM (snprintf (0, 0, "%C", (wint_t)wc)); + ELIM (snprintf (0, 0, "%C", (wint_t)wc)); } void elim_wide_string_call (void) @@ -83,21 +84,21 @@ void keep_wide_char_call (void) { KEEP (snprintf (0, 0, "%lc", L'\xff')); KEEP (snprintf (0, 0, "%lc", L'\xffff')); - KEEP (snprintf (0, 0, "%lc", wc)); - KEEP (snprintf (0, 0, "%lc", ws3[2])); + KEEP (snprintf (0, 0, "%lc", (wint_t)wc)); + KEEP (snprintf (0, 0, "%lc", (wint_t)ws3[2])); KEEP (snprintf (0, 0, "%C", L'\xff')); KEEP (snprintf (0, 0, "%C", L'\xffff')); - KEEP (snprintf (0, 0, "%C", wc)); - KEEP (snprintf (0, 0, "%C", ws3[2])); + KEEP (snprintf (0, 0, "%C", (wint_t)wc)); + KEEP (snprintf (0, 0, "%C", (wint_t)ws3[2])); /* Verify an unknown character value outside the ASCII range (with 128 being the only one). */ if (wc < 32 || 128 < wc) wc = 32; - KEEP (snprintf (0, 0, "%lc", wc)); - KEEP (snprintf (0, 0, "%C", wc)); + KEEP (snprintf (0, 0, "%lc", (wint_t)wc)); + KEEP (snprintf (0, 0, "%C", (wint_t)wc)); } void keep_wide_string_call (void) -- 2.30.2