This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] Warning during GCC bootstrap on i686-pc-mingw32
On Thu, Apr 17, 2008 at 11:07 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Thu, 17 Apr 2008, Danny Smith wrote:
>
> > On Thu, Apr 17, 2008 at 12:03 AM, Joseph S. Myers
> > <joseph@codesourcery.com> wrote:
> > > On Wed, 16 Apr 2008, Danny Smith wrote:
> > >
> > > > 2008-04-16 Danny Smith <dannysmith@users.net>
> > > >
> > > > * c-format.c (check_format_info_main): Use strncmp rather than a magic prefix
> > > > to handle multichar length specs.
> > >
> > > This C front-end change is OK, but you need to add a testcase that
> > > verifies the correct diagnostic in this case (passes with and fails
> > > without the patch).
> > >
> > Is attached testcase suitable?
>
> Since the bug was saying "''" instead of "'I64'" in the diagnostic text,
> testing for "C" doesn't suffice; "C" is in both old and new diagnostic
> strings. I'd suggest testing for a longer string, "'I64' ms_printf length
> modifier" or similar.
As committed.
The new testcase uses the "'I64' ms_printf length
modifier" string suggested by Joseph Myers.
gcc
* c-format.c (check_format_info_main): Use strncmp rather than a magic prefix
to handle multichar length specs.
* config/i386/msformat-c.c (format_length_info ms_printf_length_specs):
Don't prefix "I64" and "I32" with '\0'.
testsuite
* gcc.dg/format/ms-warnI64-1.c: New file.
Danny
Index: c-format.c
===================================================================
--- c-format.c (revision 134622)
+++ c-format.c (working copy)
@@ -1779,26 +1779,12 @@
length_chars_std = STD_C89;
if (fli)
{
- while (fli->name != 0 && fli->name[0] != *format_chars)
- {
- if (fli->name[0] == '\0')
- {
- int si = strlen (fli->name + 1) + 1;
- int i = 1;
- while (fli->name[i] != 0 && fli->name[i] == format_chars [i - 1])
- ++i;
- if (si == i)
- {
- if (si > 2)
- format_chars += si - 2;
- break;
- }
- }
+ while (fli->name != 0
+ && strncmp (fli->name, format_chars, strlen (fli->name)))
fli++;
- }
if (fli->name != 0)
{
- format_chars++;
+ format_chars += strlen (fli->name);
if (fli->double_name != 0 && fli->name[0] == *format_chars)
{
format_chars++;
Index: config/i386/msformat-c.c
===================================================================
--- config/i386/msformat-c.c (revision 134622)
+++ config/i386/msformat-c.c (working copy)
@@ -38,8 +38,8 @@
{
{ "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
{ "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
- { "\0I32", FMT_LEN_l, STD_EXT, NULL, 0, 0 },
- { "\0I64", FMT_LEN_ll, STD_EXT, NULL, 0, 0 },
+ { "I32", FMT_LEN_l, STD_EXT, NULL, 0, 0 },
+ { "I64", FMT_LEN_ll, STD_EXT, NULL, 0, 0 },
{ "I", FMT_LEN_L, STD_EXT, NULL, 0, 0 },
{ NULL, 0, 0, NULL, 0, 0 }
};
Index: testsuite/gcc.dg/format/ms-warnI64-1.c
===================================================================
--- testsuite/gcc.dg/format/ms-warnI64-1.c (revision 0)
+++ testsuite/gcc.dg/format/ms-warnI64-1.c (revision 0)
@@ -0,0 +1,28 @@
+/* Test for printf formats. Test for ISO C warnings with MS "I64"
+ extension.*/
+
+/* { dg-do compile { target { *-*-mingw* } } } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat -Wno-long-long" } */
+
+#define USE_SYSTEM_FORMATS
+#include "format.h"
+
+void
+foo (long long ll, unsigned long long ull, long long *lln,
+ long long *llp, unsigned long long *ullp)
+{
+ printf ("%I64d", ll); /* { dg-warning "'I64' ms_printf length modifier" "printf %I64d" } */
+ printf ("%I64i", ll); /* { dg-warning "'I64' ms_printf length modifier" "printf %I64i" } */
+ printf ("%I64o", ull); /* { dg-warning "'I64' ms_printf length modifier" "printf %I64o" } */
+ printf ("%I64u", ull); /* { dg-warning "'I64' ms_printf length modifier" "printf %I64u" } */
+ printf ("%I64x", ull); /* { dg-warning "'I64' ms_printf length modifier" "printf %I64x" } */
+ printf ("%I64X", ull); /* { dg-warning "'I64' ms_printf length modifier" "printf %I64X" } */
+ printf ("%I64n", lln); /* { dg-warning "'I64' ms_printf length modifier" "printf %I64n" } */
+ scanf ("%I64d", llp); /* { dg-warning "'I64' ms_scanf length modifier" "scanf %I64d" } */
+ scanf ("%I64i", llp); /* { dg-warning "'I64' ms_scanf length modifier" "scanf %I64i" } */
+ scanf ("%I64o", ullp); /* { dg-warning "'I64' ms_scanf length modifier" "scanf %I64o" } */
+ scanf ("%I64u", ullp); /* { dg-warning "'I64' ms_scanf length modifier" "scanf %I64u" } */
+ scanf ("%I64x", ullp); /* { dg-warning "'I64' ms_scanf length modifier" "scanf %I64x" } */
+ scanf ("%I64X", ullp); /* { dg-warning "'I64' ms_scanf length modifier" "scanf %I64X" } */
+ scanf ("%I64n", llp); /* { dg-warning "'I64' ms_scanf length modifier" "scanf %I64n" } */
+}