public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
       [not found] <OFB5BC0CC2.0ADC574F-ONC12574E1.0039EBC2-C12574E1.0039FBF6@LocalDomain>
@ 2008-11-21 14:09 ` Kai Tietz
  0 siblings, 0 replies; 25+ messages in thread
From: Kai Tietz @ 2008-11-21 14:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: Danny Smith, NightStrike

Kai Tietz/Onevision wrote on 13.10.2008 12:33:20:

> "Danny Smith" <dansmister@gmail.com> wrote on 12.10.2008 07:58:00:
> 
> > >        Fix PR/25502
> > >        * c-format.c (convert_format_name_to_system_name): Use
> > >        TARGET_OVERRIDES_FORMAT_INIT.
> > >        * config.gcc (extra_options): Add for mingw targets 
mingw.opt.
> > >        * config/i386/mingw.opt: New.
> > >        * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
> > >        * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): 
New.
> > >        (ms_printf_length_specs): Removed const specifier.
> > >        * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.
> > >
> > > Is this patch ok for apply?
> > >
> > 
> > OK
> > Thanks
> > Danny

> Committed revision 141087.
> 
> Thanks,
> Kai

While checking my repository I found an uncommitted change.
I missed to check in changes to /config/mh-mingw. It is part of the patch 
2008/10/13 by myself, reviewed and approved by Danny Smith.

Committed revision 142089.

2008-11-21  Kai Tietz  <kai.tietz@onevision.com>

        Fix PR/25502
        * mh-mingw (BOOT_CFLAGS): Add -Wno-pedantic-ms-format switch.


Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-10-12  9:48                           ` Danny Smith
@ 2008-10-13 11:36                             ` Kai Tietz
  0 siblings, 0 replies; 25+ messages in thread
From: Kai Tietz @ 2008-10-13 11:36 UTC (permalink / raw)
  To: Danny Smith; +Cc: gcc-patches, Joseph S. Myers, Kai Tietz, NightStrike

"Danny Smith" <dansmister@gmail.com> wrote on 12.10.2008 07:58:00:

> >        Fix PR/25502
> >        * c-format.c (convert_format_name_to_system_name): Use
> >        TARGET_OVERRIDES_FORMAT_INIT.
> >        * config.gcc (extra_options): Add for mingw targets mingw.opt.
> >        * config/i386/mingw.opt: New.
> >        * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
> >        * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
> >        (ms_printf_length_specs): Removed const specifier.
> >        * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.
> >
> > Is this patch ok for apply?
> >
> 
> OK
> Thanks
> Danny

Committed revision 141087.

Thanks,
Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-10-10 12:14                         ` Kai Tietz
  2008-10-11 10:27                           ` Danny Smith
@ 2008-10-12  9:48                           ` Danny Smith
  2008-10-13 11:36                             ` Kai Tietz
  1 sibling, 1 reply; 25+ messages in thread
From: Danny Smith @ 2008-10-12  9:48 UTC (permalink / raw)
  To: Kai Tietz; +Cc: gcc-patches, Joseph S. Myers, Kai Tietz, NightStrike

>        Fix PR/25502
>        * c-format.c (convert_format_name_to_system_name): Use
>        TARGET_OVERRIDES_FORMAT_INIT.
>        * config.gcc (extra_options): Add for mingw targets mingw.opt.
>        * config/i386/mingw.opt: New.
>        * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
>        * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
>        (ms_printf_length_specs): Removed const specifier.
>        * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.
>
> Is this patch ok for apply?
>

OK
Thanks
Danny

> Kai
>
>
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-10-11 10:27                           ` Danny Smith
@ 2008-10-11 15:34                             ` Kai Tietz
  0 siblings, 0 replies; 25+ messages in thread
From: Kai Tietz @ 2008-10-11 15:34 UTC (permalink / raw)
  To: Danny Smith; +Cc: gcc-patches, Joseph S. Myers, Kai Tietz, NightStrike

Hello Danny,

"Danny Smith" <dansmister@gmail.com> wrote on 11.10.2008 02:56:55:

> On Fri, Oct 10, 2008 at 11:37 PM, Kai Tietz <Kai.Tietz@onevision.com> 
wrote:
> > Hello Dany,
> >
> > I updated the patch to prevent the none-prototyped warning, that Aaron
> > detected.
> > As we talked, I tested this patch for 32-bit and 64-bit mingw. I saw 
no
> > new failure or regressions reasoned by this patch.
> >
> > ChangeLog
> >
> > 2008-10-10  Kai Tietz  <kai.tietz@onevision.com>
> >
> >        Fix PR/25502
> >        * c-format.c (convert_format_name_to_system_name): Use
> >        TARGET_OVERRIDES_FORMAT_INIT.
> >        * config.gcc (extra_options): Add for mingw targets mingw.opt.
> >        * config/i386/mingw.opt: New.
> >        * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
> >        * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
> >        (ms_printf_length_specs): Removed const specifier.
> >        * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.
> >
> > Is this patch ok for apply?
> 
> How did you bootstrap mingw32.  Since IRA merge, I have been unable to
> bootstrap mingw32 because of miscompilation of cp/pt.c.  Did you use
> -fno-ira in CFLAGS?
> 
> I realize that the bootstrap problem has nothing to do with your
> patch, but I am curious as to how you tested.

For w64 the bootstrap is still working. You are right, that for w32 I used 
the -fno-ira flag, because otherwise bootstrap fails for it.

Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-10-10 12:14                         ` Kai Tietz
@ 2008-10-11 10:27                           ` Danny Smith
  2008-10-11 15:34                             ` Kai Tietz
  2008-10-12  9:48                           ` Danny Smith
  1 sibling, 1 reply; 25+ messages in thread
From: Danny Smith @ 2008-10-11 10:27 UTC (permalink / raw)
  To: Kai Tietz; +Cc: gcc-patches, Joseph S. Myers, Kai Tietz, NightStrike

On Fri, Oct 10, 2008 at 11:37 PM, Kai Tietz <Kai.Tietz@onevision.com> wrote:
> Hello Dany,
>
> I updated the patch to prevent the none-prototyped warning, that Aaron
> detected.
> As we talked, I tested this patch for 32-bit and 64-bit mingw. I saw no
> new failure or regressions reasoned by this patch.
>
> ChangeLog
>
> 2008-10-10  Kai Tietz  <kai.tietz@onevision.com>
>
>        Fix PR/25502
>        * c-format.c (convert_format_name_to_system_name): Use
>        TARGET_OVERRIDES_FORMAT_INIT.
>        * config.gcc (extra_options): Add for mingw targets mingw.opt.
>        * config/i386/mingw.opt: New.
>        * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
>        * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
>        (ms_printf_length_specs): Removed const specifier.
>        * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.
>
> Is this patch ok for apply?

How did you bootstrap mingw32.  Since IRA merge, I have been unable to
bootstrap mingw32 because of miscompilation of cp/pt.c.  Did you use
-fno-ira in CFLAGS?

I realize that the bootstrap problem has nothing to do with your
patch, but I am curious as to how you tested.

Danny


>
> Kai

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-09  5:42                       ` Danny Smith
                                           ` (3 preceding siblings ...)
  2008-09-12 16:38                         ` NightStrike
@ 2008-10-10 12:14                         ` Kai Tietz
  2008-10-11 10:27                           ` Danny Smith
  2008-10-12  9:48                           ` Danny Smith
  4 siblings, 2 replies; 25+ messages in thread
From: Kai Tietz @ 2008-10-10 12:14 UTC (permalink / raw)
  To: Danny Smith; +Cc: gcc-patches, Joseph S. Myers, Kai Tietz, NightStrike

[-- Attachment #1: Type: text/plain, Size: 929 bytes --]

Hello Dany,

I updated the patch to prevent the none-prototyped warning, that Aaron 
detected.
As we talked, I tested this patch for 32-bit and 64-bit mingw. I saw no 
new failure or regressions reasoned by this patch.

ChangeLog

2008-10-10  Kai Tietz  <kai.tietz@onevision.com>

        Fix PR/25502
        * c-format.c (convert_format_name_to_system_name): Use
        TARGET_OVERRIDES_FORMAT_INIT.
        * config.gcc (extra_options): Add for mingw targets mingw.opt.
        * config/i386/mingw.opt: New.
        * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
        * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
        (ms_printf_length_specs): Removed const specifier.
        * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.

Is this patch ok for apply?

Kai



|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.

[-- Attachment #2: mingw-ped-warning.txt --]
[-- Type: text/plain, Size: 7782 bytes --]

Index: gcc/gcc/c-format.c
===================================================================
--- gcc.orig/gcc/c-format.c
+++ gcc/gcc/c-format.c
@@ -2714,6 +2714,9 @@ extern const format_kind_info TARGET_FOR
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
 extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
 #endif
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  extern void TARGET_OVERRIDES_FORMAT_INIT (void);
+#endif
 
 /* Attributes such as "printf" are equivalent to those such as
    "gnu_printf" unless this is overridden by a target.  */
@@ -2738,6 +2741,9 @@ convert_format_name_to_system_name (cons
   if (attr_name == NULL || *attr_name == 0
       || strncmp (attr_name, "gcc_", 4) == 0)
     return attr_name;
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  TARGET_OVERRIDES_FORMAT_INIT ();
+#endif
 
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
   /* Check if format attribute is overridden by target.  */
Index: gcc/gcc/config.gcc
===================================================================
--- gcc.orig/gcc/config.gcc
+++ gcc/gcc/config.gcc
@@ -1270,7 +1270,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 	xm_file=i386/xm-mingw32.h
 	tmake_file="${tmake_file} i386/t-cygming i386/t-mingw32"
 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
-	extra_options="${extra_options} i386/cygming.opt"
+	extra_options="${extra_options} i386/cygming.opt i386/mingw.opt"
 	extra_objs="winnt.o winnt-stubs.o"
 	c_target_objs="${c_target_objs} msformat-c.o"
 	cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
Index: gcc/gcc/config/i386/mingw.opt
===================================================================
--- /dev/null
+++ gcc/gcc/config/i386/mingw.opt
@@ -0,0 +1,23 @@
+; MinGW-specific options.
+
+; Copyright (C) 2008 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+Wpedantic-ms-format
+C ObjC C++ ObjC++ Var(warn_pedantic_ms_format) Init(1) Warning
+Warn about none ISO msvcrt scanf/printf width extensions
Index: gcc/gcc/config/i386/mingw32.h
===================================================================
--- gcc.orig/gcc/config/i386/mingw32.h
+++ gcc/gcc/config/i386/mingw32.h
@@ -169,6 +169,10 @@ do {						         \
 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
 
+/* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
+#undef TARGET_OVERRIDES_FORMAT_INIT
+#define TARGET_OVERRIDES_FORMAT_INIT msformat_init
+
 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
 #undef TARGET_FORMAT_TYPES
 #define TARGET_FORMAT_TYPES mingw_format_attributes
Index: gcc/gcc/config/i386/msformat-c.c
===================================================================
--- gcc.orig/gcc/config/i386/msformat-c.c
+++ gcc/gcc/config/i386/msformat-c.c
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3.  
 
 /* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime.  */
 
-static const format_length_info ms_printf_length_specs[] =
+static format_length_info ms_printf_length_specs[] =
 {
   { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
   { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
@@ -173,3 +173,25 @@ const target_ovr_attr mingw_format_attri
   { "ms_scanf", "scanf" },
   { "ms_strftime", "strftime" }
 };
+
+/* Setup for option Wpedantic-ms-format.  */
+
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+
+/* Make sure TARGET_OVERRIDES_FORMAT_INIT is prototyped.  */
+extern void TARGET_OVERRIDES_FORMAT_INIT (void);
+
+/* Helper.  */
+#define C89_OR_EXT (warn_pedantic_ms_format ? STD_EXT : STD_C89)
+
+void
+TARGET_OVERRIDES_FORMAT_INIT (void)
+{
+  ms_printf_length_specs[2].std = C89_OR_EXT; /* I32 */
+  ms_printf_length_specs[3].std = C89_OR_EXT; /* I64 */
+  ms_printf_length_specs[4].std = C89_OR_EXT; /* I */
+}
+
+#undef C89_OR_EXT
+
+#endif
Index: gcc/gcc/doc/tm.texi
===================================================================
--- gcc.orig/gcc/doc/tm.texi
+++ gcc/gcc/doc/tm.texi
@@ -10539,6 +10539,12 @@ If defined, this macro specifies the num
 @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
 @end defmac
 
+@defmac TARGET_OVERRIDES_FORMAT_INIT
+If defined, this macro specifies the optional initialization
+routine for target specific customizations of the system printf
+and scanf formatter settings.
+@end defmac
+
 @deftypefn {Target Hook} bool TARGET_RELAXED_ORDERING
 If set to @code{true}, means that the target's memory model does not
 guarantee that loads which do not depend on one another will access
Index: gcc/gcc/doc/invoke.texi
===================================================================
--- gcc.orig/gcc/doc/invoke.texi
+++ gcc/gcc/doc/invoke.texi
@@ -250,7 +250,8 @@ Objective-C and Objective-C++ Dialects}.
 -Wmissing-noreturn  -Wno-mudflap @gol
 -Wno-multichar  -Wnonnull  -Wno-overflow @gol
 -Woverlength-strings  -Wpacked  -Wpadded @gol
--Wparentheses  -Wpointer-arith  -Wno-pointer-to-int-cast @gol
+-Wparentheses  -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
+-Wpointer-arith  -Wno-pointer-to-int-cast @gol
 -Wredundant-decls @gol
 -Wreturn-type  -Wsequence-point  -Wshadow @gol
 -Wsign-compare  -Wsign-conversion  -Wstack-protector @gol
@@ -3571,6 +3572,14 @@ assume anything on the bounds of the loo
 @option{-funsafe-loop-optimizations} warn if the compiler made
 such assumptions.
 
+@item -Wno-pedantic-ms-format
+@opindex Wno-pedantic-ms-format
+@opindex Wpedantic-ms-format
+Disables the warnings about non-ISO @code{printf} / @code{scanf} format
+width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets
+depending on the MS runtime, when you are using the options @option{-Wformat}
+and @option{-pedantic} without gnu-extensions.
+
 @item -Wpointer-arith
 @opindex Wpointer-arith
 @opindex Wno-pointer-arith
Index: gcc/gcc/testsuite/gcc.dg/format/ms-format1.c
===================================================================
--- /dev/null
+++ gcc/gcc/testsuite/gcc.dg/format/ms-format1.c
@@ -0,0 +1,17 @@
+/* Test for printf formats.  Formats using extensions to the standard
+   should be rejected in strict pedantic mode. But allowed by -Wno-pedantic-ms-format.
+*/
+/* Origin: Kai Tietz <kai.tietz@onevision.com> */
+/* { dg-do compile { target { *-*-mingw* } } } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat -Wno-pedantic-ms-format" } */
+
+#define USE_SYSTEM_FORMATS
+#include "format.h"
+
+void
+foo (int i, long long ll, size_t z)
+{
+  printf ("%I32d", i);
+  printf ("%I64x", ll);
+  printf ("%Ix", z);
+}
Index: gcc/config/mh-mingw
===================================================================
--- gcc.orig/config/mh-mingw
+++ gcc/config/mh-mingw
@@ -1,6 +1,6 @@
 # Add -D__USE_MINGW_ACCESS to enable the built compiler to work on Windows
 # Vista (see PR33281 for details).
-BOOT_CFLAGS += -D__USE_MINGW_ACCESS
+BOOT_CFLAGS += -D__USE_MINGW_ACCESS -Wno-pedantic-ms-format
 CFLAGS += -D__USE_MINGW_ACCESS
 # Increase stack limit to same as Linux default.
 LDFLAGS += -Wl,--stack,8388608
=

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in  build
  2008-09-08 12:42                 ` Kai Tietz
  2008-09-08 15:44                   ` Joseph S. Myers
@ 2008-09-15  8:18                   ` Aaron W. LaFramboise
  1 sibling, 0 replies; 25+ messages in thread
From: Aaron W. LaFramboise @ 2008-09-15  8:18 UTC (permalink / raw)
  To: Kai Tietz
  Cc: Joseph S. Myers, Danny Smith, gcc-patches, Kai Tietz, NightStrike

[-- Attachment #1: Type: text/plain, Size: 960 bytes --]

Kai Tietz wrote:

> 2008-09-08  Kai Tietz  <kai.tietz@onevision.com>
> 
>         Fix PR/25502
>         * c-format.c (convert_format_name_to_system_name): Use
>         TARGET_OVERRIDES_FORMAT_INIT.
>         * config.gcc (extra_options): Add for mingw targets mingw.opt.
>         * config/i386/mingw.opt: New.
>         * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
>         * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
>         (ms_printf_length_specs): Removed const specifier.
>         * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.
>         * doc/invoke.texi (Wno-pedantic-ms-format): New.

Ironically, this patch is not actually -Werror-clean.  With this patch, 
I get a 'no previous prototype' warning which breaks bootstrap in 
msformat-c.c for msformat_init().

The attached patch, which should be applied on top of Kai's patch, fixes 
this problem by moving the prototype to mingw32.h next to the #define.

[-- Attachment #2: gcc-fixkaiformat.txt --]
[-- Type: text/plain, Size: 1077 bytes --]

diff -Naur gcc/c-format.c gcc+formatfix/c-format.c
--- gcc/c-format.c	2008-09-14 20:22:17.547496300 -0500
+++ gcc+formatfix/c-format.c	2008-09-14 12:51:48.122496000 -0500
@@ -2714,9 +2714,6 @@
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
 extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
 #endif
-#ifdef TARGET_OVERRIDES_FORMAT_INIT
-  extern void TARGET_OVERRIDES_FORMAT_INIT (void);
-#endif
 
 /* Attributes such as "printf" are equivalent to those such as
    "gnu_printf" unless this is overridden by a target.  */
diff -Naur gcc/config/i386/mingw32.h gcc+formatfix/config/i386/mingw32.h
--- gcc/config/i386/mingw32.h	2008-09-14 20:23:02.567496300 -0500
+++ gcc+formatfix/config/i386/mingw32.h	2008-09-14 12:51:23.162496000 -0500
@@ -170,6 +170,7 @@
 /* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
 #undef TARGET_OVERRIDES_FORMAT_INIT
 #define TARGET_OVERRIDES_FORMAT_INIT msformat_init
+extern void msformat_init (void);
 
 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
 #undef TARGET_FORMAT_TYPES

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-12 16:38                         ` NightStrike
@ 2008-09-12 21:42                           ` Danny Smith
  0 siblings, 0 replies; 25+ messages in thread
From: Danny Smith @ 2008-09-12 21:42 UTC (permalink / raw)
  To: NightStrike
  Cc: Aaron W. LaFramboise, Joseph S. Myers, Kai Tietz, gcc-patches, Kai Tietz

>
> The misunderstanding here stems from the idea that this is "just to
> allow --enable-werror builds."  The reasoning behind the patch is that
> a user of gcc on a windows based platform will legitimately want to be
> able to use features of the operating system without the compiler
> saying that it's wrong.  The warnings that gcc outputs for the windows
> platform regarding printf checking are not correct.


They are correct. 'I64'  is not an ISO printf format flag. -pedantic
is supposed to warn about non-ISO usage.
Danny

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-09  5:42                       ` Danny Smith
                                           ` (2 preceding siblings ...)
  2008-09-12 15:40                         ` Aaron W. LaFramboise
@ 2008-09-12 16:38                         ` NightStrike
  2008-09-12 21:42                           ` Danny Smith
  2008-10-10 12:14                         ` Kai Tietz
  4 siblings, 1 reply; 25+ messages in thread
From: NightStrike @ 2008-09-12 16:38 UTC (permalink / raw)
  To: Danny Smith
  Cc: Aaron W. LaFramboise, Joseph S. Myers, Kai Tietz, gcc-patches, Kai Tietz

On Tue, Sep 9, 2008 at 12:32 AM, Danny Smith <dansmister@gmail.com> wrote:
> On Tue, Sep 9, 2008 at 11:16 AM, Aaron W. LaFramboise
> <aaronavay62@aaronwl.com> wrote:
>> Joseph S. Myers wrote:
>>
>>> The C front-end change is OK, but the rest will need MinGW maintainer
>>> review and the MinGW maintainers will need to judge its suitability for
>>> Stage 3.
>>
>> I recommend Danny approve this for stage 3 because this is one of the last
>> things preventing --enable-werror builds from working, which is a valuable
>> feature.  It's also a bug, PR25502.
>>
>
> I really think that this is bit of an overkill and would prefer a more
> generic solution, eg fixing the bug
> "please provide a way to treat -pedantic as warning when using -Werror"
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37187
> or even including as part of  -fms-extensions
>
> In other words,  I am a bit concerned about adding YA MS-specific
> feature at stage 3, just to allow --enable-werror builds.

The misunderstanding here stems from the idea that this is "just to
allow --enable-werror builds."  The reasoning behind the patch is that
a user of gcc on a windows based platform will legitimately want to be
able to use features of the operating system without the compiler
saying that it's wrong.  The warnings that gcc outputs for the windows
platform regarding printf checking are not correct.

Shutting off all printf checking (or making all printf warnings be
handled differently regarding Werror) is a textbook case of "the baby
and the bathwater".

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-12 15:40                         ` Aaron W. LaFramboise
@ 2008-09-12 16:04                           ` NightStrike
  0 siblings, 0 replies; 25+ messages in thread
From: NightStrike @ 2008-09-12 16:04 UTC (permalink / raw)
  To: Aaron W. LaFramboise
  Cc: Danny Smith, Joseph S. Myers, Kai Tietz, gcc-patches, Kai Tietz

On Fri, Sep 12, 2008 at 11:32 AM, Aaron W. LaFramboise
<aaronavay62@aaronwl.com> wrote:
> Do you think this is sufficiently risky that it should be delayed to 4.5?
>  Or would you prefer it be rolled into -fms-extensions?

More specifically, why is it considered at risk at all?

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in  build
  2008-09-09  5:42                       ` Danny Smith
  2008-09-09  6:01                         ` Kai Tietz
  2008-09-12 15:33                         ` Kai Tietz
@ 2008-09-12 15:40                         ` Aaron W. LaFramboise
  2008-09-12 16:04                           ` NightStrike
  2008-09-12 16:38                         ` NightStrike
  2008-10-10 12:14                         ` Kai Tietz
  4 siblings, 1 reply; 25+ messages in thread
From: Aaron W. LaFramboise @ 2008-09-12 15:40 UTC (permalink / raw)
  To: Danny Smith
  Cc: Joseph S. Myers, Kai Tietz, gcc-patches, Kai Tietz, NightStrike

Danny Smith wrote:
> On Tue, Sep 9, 2008 at 11:16 AM, Aaron W. LaFramboise
> <aaronavay62@aaronwl.com> wrote:
>> Joseph S. Myers wrote:
>>
>>> The C front-end change is OK, but the rest will need MinGW maintainer
>>> review and the MinGW maintainers will need to judge its suitability for
>>> Stage 3.
>> I recommend Danny approve this for stage 3 because this is one of the last
>> things preventing --enable-werror builds from working, which is a valuable
>> feature.  It's also a bug, PR25502.
>>
> 
> I really think that this is bit of an overkill and would prefer a more
> generic solution, eg fixing the bug
> "please provide a way to treat -pedantic as warning when using -Werror"
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37187
> or even including as part of  -fms-extensions
> 
> In other words,  I am a bit concerned about adding YA MS-specific
> feature at stage 3, just to allow --enable-werror builds.

This is an important flag for most any Windows code, that will need to 
use the 64-bit formatter, but where the developers would also desire to 
compile with -pedantic and be warning clean, which I think is an 
extremely reasonable request.  Without this, -pedantic -Werror is not 
reasonably usable in Windows code that needs to print 64-bit integers.

Do you think this is sufficiently risky that it should be delayed to 
4.5?  Or would you prefer it be rolled into -fms-extensions?

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-09  5:42                       ` Danny Smith
  2008-09-09  6:01                         ` Kai Tietz
@ 2008-09-12 15:33                         ` Kai Tietz
  2008-09-12 15:40                         ` Aaron W. LaFramboise
                                           ` (2 subsequent siblings)
  4 siblings, 0 replies; 25+ messages in thread
From: Kai Tietz @ 2008-09-12 15:33 UTC (permalink / raw)
  To: Danny Smith
  Cc: Aaron W. LaFramboise, gcc-patches, Joseph S. Myers, Kai Tietz,
	NightStrike

Hi Danny,

"Danny Smith" <dansmister@gmail.com> wrote on 09.09.2008 06:32:43:

> On Tue, Sep 9, 2008 at 11:16 AM, Aaron W. LaFramboise
> <aaronavay62@aaronwl.com> wrote:
> > Joseph S. Myers wrote:
> >
> >> The C front-end change is OK, but the rest will need MinGW maintainer
> >> review and the MinGW maintainers will need to judge its suitability 
for
> >> Stage 3.
> >
> > I recommend Danny approve this for stage 3 because this is one of the 
last
> > things preventing --enable-werror builds from working, which is a 
valuable
> > feature.  It's also a bug, PR25502.
> >
> 
> I really think that this is bit of an overkill and would prefer a more
> generic solution, eg fixing the bug
> "please provide a way to treat -pedantic as warning when using -Werror"
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37187
> or even including as part of  -fms-extensions
> 
> In other words,  I am a bit concerned about adding YA MS-specific
> feature at stage 3, just to allow --enable-werror builds.

The problem case you mentioned is in my understanding a bit different then 
the problem 25502. In PR/37187 the issue is to down grade -pedantic to an 
simple warning (-W) option. Additionally it tells that the message should 
still be shown, but treated just as warning, even if -Werror is specified. 
This is a total different thing IIUC. PR/25502 wants to disable the 
warning for printf/scanf checking completly without any trail.
I think it is an good idea to turn off additionally for the option 
-fms-extension the -Wpedantic-ms-format option.

Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-09  5:42                       ` Danny Smith
@ 2008-09-09  6:01                         ` Kai Tietz
  2008-09-12 15:33                         ` Kai Tietz
                                           ` (3 subsequent siblings)
  4 siblings, 0 replies; 25+ messages in thread
From: Kai Tietz @ 2008-09-09  6:01 UTC (permalink / raw)
  To: Danny Smith
  Cc: Aaron W. LaFramboise, Joseph S. Myers, Kai Tietz, gcc-patches,
	NightStrike

2008/9/9 Danny Smith <dansmister@gmail.com>:
> On Tue, Sep 9, 2008 at 11:16 AM, Aaron W. LaFramboise
> <aaronavay62@aaronwl.com> wrote:
>> Joseph S. Myers wrote:
>>
>>> The C front-end change is OK, but the rest will need MinGW maintainer
>>> review and the MinGW maintainers will need to judge its suitability for
>>> Stage 3.
>>
>> I recommend Danny approve this for stage 3 because this is one of the last
>> things preventing --enable-werror builds from working, which is a valuable
>> feature.  It's also a bug, PR25502.
>>
>
> I really think that this is bit of an overkill and would prefer a more
> generic solution, eg fixing the bug
> "please provide a way to treat -pedantic as warning when using -Werror"
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37187
> or even including as part of  -fms-extensions
>
> In other words,  I am a bit concerned about adding YA MS-specific
> feature at stage 3, just to allow --enable-werror builds.
>
> Danny
>

Well, MA MS-specific feature is for a more silent bootstrap for w64
very important. For 32-bit there are less MS-specific formats used in
gcc. For w64 there are tons of them. So I see here really a bug, which
was reported, to be fixed.

Cheers,
Kai

-- 
| (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-09  0:12                     ` Aaron W. LaFramboise
@ 2008-09-09  5:42                       ` Danny Smith
  2008-09-09  6:01                         ` Kai Tietz
                                           ` (4 more replies)
  0 siblings, 5 replies; 25+ messages in thread
From: Danny Smith @ 2008-09-09  5:42 UTC (permalink / raw)
  To: Aaron W. LaFramboise
  Cc: Joseph S. Myers, Kai Tietz, gcc-patches, Kai Tietz, NightStrike

On Tue, Sep 9, 2008 at 11:16 AM, Aaron W. LaFramboise
<aaronavay62@aaronwl.com> wrote:
> Joseph S. Myers wrote:
>
>> The C front-end change is OK, but the rest will need MinGW maintainer
>> review and the MinGW maintainers will need to judge its suitability for
>> Stage 3.
>
> I recommend Danny approve this for stage 3 because this is one of the last
> things preventing --enable-werror builds from working, which is a valuable
> feature.  It's also a bug, PR25502.
>

I really think that this is bit of an overkill and would prefer a more
generic solution, eg fixing the bug
"please provide a way to treat -pedantic as warning when using -Werror"
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37187
or even including as part of  -fms-extensions

In other words,  I am a bit concerned about adding YA MS-specific
feature at stage 3, just to allow --enable-werror builds.

Danny

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in  build
  2008-09-08 15:44                   ` Joseph S. Myers
@ 2008-09-09  0:12                     ` Aaron W. LaFramboise
  2008-09-09  5:42                       ` Danny Smith
  0 siblings, 1 reply; 25+ messages in thread
From: Aaron W. LaFramboise @ 2008-09-09  0:12 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Kai Tietz, Danny Smith, gcc-patches, Kai Tietz, NightStrike

Joseph S. Myers wrote:

> The C front-end change is OK, but the rest will need MinGW maintainer 
> review and the MinGW maintainers will need to judge its suitability for 
> Stage 3.

I recommend Danny approve this for stage 3 because this is one of the 
last things preventing --enable-werror builds from working, which is a 
valuable feature.  It's also a bug, PR25502.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in  build
  2008-09-08 12:42                 ` Kai Tietz
@ 2008-09-08 15:44                   ` Joseph S. Myers
  2008-09-09  0:12                     ` Aaron W. LaFramboise
  2008-09-15  8:18                   ` Aaron W. LaFramboise
  1 sibling, 1 reply; 25+ messages in thread
From: Joseph S. Myers @ 2008-09-08 15:44 UTC (permalink / raw)
  To: Kai Tietz
  Cc: Aaron W. LaFramboise, Danny Smith, gcc-patches, Kai Tietz, NightStrike

On Mon, 8 Sep 2008, Kai Tietz wrote:

> 2008-09-08  Kai Tietz  <kai.tietz@onevision.com>
> 
>         Fix PR/25502
>         * c-format.c (convert_format_name_to_system_name): Use
>         TARGET_OVERRIDES_FORMAT_INIT.
>         * config.gcc (extra_options): Add for mingw targets mingw.opt.
>         * config/i386/mingw.opt: New.
>         * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
>         * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
>         (ms_printf_length_specs): Removed const specifier.
>         * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.
>         * doc/invoke.texi (Wno-pedantic-ms-format): New.
> 
> 2008-09-08  Kai Tietz  <kai.tietz@onevision.com>
> 
>         * testsuite/gcc.dg/format/ms-format1.c: New.
> 
> 
> 2008-09-08  Kai Tietz  <kai.tietz@onevision.com>
> 
>         * config/mh-mingw (BOOT_CFLAGS): Add -Wno-pedantic-ms-format
> 
> Ok for apply?

The C front-end change is OK, but the rest will need MinGW maintainer 
review and the MinGW maintainers will need to judge its suitability for 
Stage 3.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-08 12:28               ` Joseph S. Myers
@ 2008-09-08 12:42                 ` Kai Tietz
  2008-09-08 15:44                   ` Joseph S. Myers
  2008-09-15  8:18                   ` Aaron W. LaFramboise
  0 siblings, 2 replies; 25+ messages in thread
From: Kai Tietz @ 2008-09-08 12:42 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Aaron W. LaFramboise, Danny Smith, gcc-patches, Kai Tietz, NightStrike

[-- Attachment #1: Type: text/plain, Size: 1748 bytes --]

"Joseph S. Myers" <joseph@codesourcery.com> wrote on 08.09.2008 13:59:39:

> On Mon, 8 Sep 2008, Kai Tietz wrote:
> 
> > +Disables the warnings about none-ISO @code{printf} / @code{scanf} 
format
> 
> "non-ISO", not "none-ISO".
> 
> > +width specifiers @code{I32}, @code{I64}, and @code{I} used in 
> windows targets
> 
> "on Windows", not "in windows".
> 
> > +depending on the ms runtime, when you are using the option 
@option{-std=}
> 
> "MS", not "ms".
> 
> > +set an ISO standard without gnu-extensions, or the options 
> @option{-Wformat}
> > +and @option{-pedantic}.
> 
> This has nothing to do with -std, only -Wformat -pedantic.

I did the corrections to the documentation you mentioned and removed the 
ref to -std.

> The patch still lacks testcases for the new option.

2008-09-08  Kai Tietz  <kai.tietz@onevision.com>

        Fix PR/25502
        * c-format.c (convert_format_name_to_system_name): Use
        TARGET_OVERRIDES_FORMAT_INIT.
        * config.gcc (extra_options): Add for mingw targets mingw.opt.
        * config/i386/mingw.opt: New.
        * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
        * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
        (ms_printf_length_specs): Removed const specifier.
        * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.
        * doc/invoke.texi (Wno-pedantic-ms-format): New.

2008-09-08  Kai Tietz  <kai.tietz@onevision.com>

        * testsuite/gcc.dg/format/ms-format1.c: New.


2008-09-08  Kai Tietz  <kai.tietz@onevision.com>

        * config/mh-mingw (BOOT_CFLAGS): Add -Wno-pedantic-ms-format

Ok for apply?

Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.


[-- Attachment #2: mingw-ped-warning.txt --]
[-- Type: text/plain, Size: 7665 bytes --]

Index: gcc/gcc/c-format.c
===================================================================
--- gcc.orig/gcc/c-format.c
+++ gcc/gcc/c-format.c
@@ -2714,6 +2714,9 @@ extern const format_kind_info TARGET_FOR
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
 extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
 #endif
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  extern void TARGET_OVERRIDES_FORMAT_INIT (void);
+#endif
 
 /* Attributes such as "printf" are equivalent to those such as
    "gnu_printf" unless this is overridden by a target.  */
@@ -2738,6 +2741,9 @@ convert_format_name_to_system_name (cons
   if (attr_name == NULL || *attr_name == 0
       || strncmp (attr_name, "gcc_", 4) == 0)
     return attr_name;
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  TARGET_OVERRIDES_FORMAT_INIT ();
+#endif
 
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
   /* Check if format attribute is overridden by target.  */
Index: gcc/gcc/config.gcc
===================================================================
--- gcc.orig/gcc/config.gcc
+++ gcc/gcc/config.gcc
@@ -1270,7 +1270,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 	xm_file=i386/xm-mingw32.h
 	tmake_file="${tmake_file} i386/t-cygming i386/t-mingw32"
 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
-	extra_options="${extra_options} i386/cygming.opt"
+	extra_options="${extra_options} i386/cygming.opt i386/mingw.opt"
 	extra_objs="winnt.o winnt-stubs.o"
 	c_target_objs="${c_target_objs} msformat-c.o"
 	cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
Index: gcc/gcc/config/i386/mingw.opt
===================================================================
--- /dev/null
+++ gcc/gcc/config/i386/mingw.opt
@@ -0,0 +1,23 @@
+; MinGW-specific options.
+
+; Copyright (C) 2008 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+Wpedantic-ms-format
+C ObjC C++ ObjC++ Var(warn_pedantic_ms_format) Init(1) Warning
+Warn about none ISO msvcrt scanf/printf width extensions
Index: gcc/gcc/config/i386/mingw32.h
===================================================================
--- gcc.orig/gcc/config/i386/mingw32.h
+++ gcc/gcc/config/i386/mingw32.h
@@ -167,6 +167,10 @@ do {						         \
 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
 
+/* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
+#undef TARGET_OVERRIDES_FORMAT_INIT
+#define TARGET_OVERRIDES_FORMAT_INIT msformat_init
+
 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
 #undef TARGET_FORMAT_TYPES
 #define TARGET_FORMAT_TYPES mingw_format_attributes
Index: gcc/gcc/config/i386/msformat-c.c
===================================================================
--- gcc.orig/gcc/config/i386/msformat-c.c
+++ gcc/gcc/config/i386/msformat-c.c
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3.  
 
 /* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime.  */
 
-static const format_length_info ms_printf_length_specs[] =
+static format_length_info ms_printf_length_specs[] =
 {
   { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
   { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
@@ -173,3 +173,22 @@ const target_ovr_attr mingw_format_attri
   { "ms_scanf", "scanf" },
   { "ms_strftime", "strftime" }
 };
+
+/* Setup for option Wpedantic-ms-format.  */
+
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+
+/* Helper.  */
+#define C89_OR_EXT (warn_pedantic_ms_format ? STD_EXT : STD_C89)
+
+void
+TARGET_OVERRIDES_FORMAT_INIT (void)
+{
+  ms_printf_length_specs[2].std = C89_OR_EXT; /* I32 */
+  ms_printf_length_specs[3].std = C89_OR_EXT; /* I64 */
+  ms_printf_length_specs[4].std = C89_OR_EXT; /* I */
+}
+
+#undef C89_OR_EXT
+
+#endif
Index: gcc/gcc/doc/tm.texi
===================================================================
--- gcc.orig/gcc/doc/tm.texi
+++ gcc/gcc/doc/tm.texi
@@ -10528,6 +10528,12 @@ If defined, this macro specifies the num
 @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
 @end defmac
 
+@defmac TARGET_OVERRIDES_FORMAT_INIT
+If defined, this macro specifies the optional initialization
+routine for target specific customizations of the system printf
+and scanf formatter settings.
+@end defmac
+
 @deftypefn {Target Hook} bool TARGET_RELAXED_ORDERING
 If set to @code{true}, means that the target's memory model does not
 guarantee that loads which do not depend on one another will access
Index: gcc/gcc/doc/invoke.texi
===================================================================
--- gcc.orig/gcc/doc/invoke.texi
+++ gcc/gcc/doc/invoke.texi
@@ -249,7 +249,8 @@ Objective-C and Objective-C++ Dialects}.
 -Wmissing-noreturn  -Wno-mudflap @gol
 -Wno-multichar  -Wnonnull  -Wno-overflow @gol
 -Woverlength-strings  -Wpacked  -Wpadded @gol
--Wparentheses  -Wpointer-arith  -Wno-pointer-to-int-cast @gol
+-Wparentheses  -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
+-Wpointer-arith  -Wno-pointer-to-int-cast @gol
 -Wredundant-decls @gol
 -Wreturn-type  -Wsequence-point  -Wshadow @gol
 -Wsign-compare  -Wsign-conversion  -Wstack-protector @gol
@@ -3567,6 +3568,14 @@ assume anything on the bounds of the loo
 @option{-funsafe-loop-optimizations} warn if the compiler made
 such assumptions.
 
+@item -Wno-pedantic-ms-format
+@opindex Wno-pedantic-ms-format
+@opindex Wpedantic-ms-format
+Disables the warnings about non-ISO @code{printf} / @code{scanf} format
+width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets
+depending on the MS runtime, when you are using the options @option{-Wformat}
+and @option{-pedantic} without gnu-extensions.
+
 @item -Wpointer-arith
 @opindex Wpointer-arith
 @opindex Wno-pointer-arith
Index: gcc/gcc/testsuite/gcc.dg/format/ms-format1.c
===================================================================
--- /dev/null
+++ gcc/gcc/testsuite/gcc.dg/format/ms-format1.c
@@ -0,0 +1,17 @@
+/* Test for printf formats.  Formats using extensions to the standard
+   should be rejected in strict pedantic mode. But allowed by -Wno-pedantic-ms-format.
+*/
+/* Origin: Kai Tietz <kai.tietz@onevision.com> */
+/* { dg-do compile { target { *-*-mingw* } } } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat -Wno-pedantic-ms-format" } */
+
+#define USE_SYSTEM_FORMATS
+#include "format.h"
+
+void
+foo (int i, long long ll, size_t z)
+{
+  printf ("%I32d", i);
+  printf ("%I64x", ll);
+  printf ("%Ix", z);
+}
Index: gcc/config/mh-mingw
===================================================================
--- gcc.orig/config/mh-mingw
+++ gcc/config/mh-mingw
@@ -1,6 +1,6 @@
 # Add -D__USE_MINGW_ACCESS to enable the built compiler to work on Windows
 # Vista (see PR33281 for details).
-BOOT_CFLAGS += -D__USE_MINGW_ACCESS
+BOOT_CFLAGS += -D__USE_MINGW_ACCESS -Wno-pedantic-ms-format
 CFLAGS += -D__USE_MINGW_ACCESS
 # Increase stack limit to same as Linux default.
 LDFLAGS += -Wl,--stack,8388608
=

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in  build
  2008-09-08 10:54             ` Kai Tietz
@ 2008-09-08 12:28               ` Joseph S. Myers
  2008-09-08 12:42                 ` Kai Tietz
  0 siblings, 1 reply; 25+ messages in thread
From: Joseph S. Myers @ 2008-09-08 12:28 UTC (permalink / raw)
  To: Kai Tietz
  Cc: Aaron W. LaFramboise, Danny Smith, gcc-patches, Kai Tietz, NightStrike

On Mon, 8 Sep 2008, Kai Tietz wrote:

> +Disables the warnings about none-ISO @code{printf} / @code{scanf} format

"non-ISO", not "none-ISO".

> +width specifiers @code{I32}, @code{I64}, and @code{I} used in windows targets

"on Windows", not "in windows".

> +depending on the ms runtime, when you are using the option @option{-std=}

"MS", not "ms".

> +set an ISO standard without gnu-extensions, or the options @option{-Wformat}
> +and @option{-pedantic}.

This has nothing to do with -std, only -Wformat -pedantic.

The patch still lacks testcases for the new option.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-05 20:18           ` Joseph S. Myers
@ 2008-09-08 10:54             ` Kai Tietz
  2008-09-08 12:28               ` Joseph S. Myers
  0 siblings, 1 reply; 25+ messages in thread
From: Kai Tietz @ 2008-09-08 10:54 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Aaron W. LaFramboise, Danny Smith, gcc-patches, Kai Tietz, NightStrike

[-- Attachment #1: Type: text/plain, Size: 950 bytes --]

"Joseph S. Myers" <joseph@codesourcery.com> wrote on 05.09.2008 21:56:54:

> On Fri, 5 Sep 2008, Kai Tietz wrote:
> 
> > I missed to refresh my patch file. Sorry for this. I introduced 
prev_value 
> > to prevent the multiple setting of the array elements. If you mean, I 
can 
> > remove this code.
> 
> An initialization hook should be called just once - but it looks like it 

> would be harmless to call this more than once even without the 
prev_value 
> code.  Furthermore, I think you can initialize the variable to 1 rather 
> than needing to check for a -1 value.  Only the -Wno- version has any 
> effect, after all, and the documentation should make that clear (that 
the 
> -Wno- option disables some warnings with -Wformat -pedantic).

Well, I adjusted the patch as you suggested. Is it ok for apply?

Cheers,
Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.


[-- Attachment #2: mingw-ped-warning.txt --]
[-- Type: text/plain, Size: 6473 bytes --]

Index: gcc/gcc/c-format.c
===================================================================
--- gcc.orig/gcc/c-format.c
+++ gcc/gcc/c-format.c
@@ -2714,6 +2714,9 @@ extern const format_kind_info TARGET_FOR
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
 extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
 #endif
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  extern void TARGET_OVERRIDES_FORMAT_INIT (void);
+#endif
 
 /* Attributes such as "printf" are equivalent to those such as
    "gnu_printf" unless this is overridden by a target.  */
@@ -2738,6 +2741,9 @@ convert_format_name_to_system_name (cons
   if (attr_name == NULL || *attr_name == 0
       || strncmp (attr_name, "gcc_", 4) == 0)
     return attr_name;
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  TARGET_OVERRIDES_FORMAT_INIT ();
+#endif
 
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
   /* Check if format attribute is overridden by target.  */
Index: gcc/gcc/config.gcc
===================================================================
--- gcc.orig/gcc/config.gcc
+++ gcc/gcc/config.gcc
@@ -1270,7 +1270,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 	xm_file=i386/xm-mingw32.h
 	tmake_file="${tmake_file} i386/t-cygming i386/t-mingw32"
 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
-	extra_options="${extra_options} i386/cygming.opt"
+	extra_options="${extra_options} i386/cygming.opt i386/mingw.opt"
 	extra_objs="winnt.o winnt-stubs.o"
 	c_target_objs="${c_target_objs} msformat-c.o"
 	cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
Index: gcc/gcc/config/i386/mingw.opt
===================================================================
--- /dev/null
+++ gcc/gcc/config/i386/mingw.opt
@@ -0,0 +1,23 @@
+; MinGW-specific options.
+
+; Copyright (C) 2008 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+Wpedantic-ms-format
+C ObjC C++ ObjC++ Var(warn_pedantic_ms_format) Init(1) Warning
+Warn about none ISO msvcrt scanf/printf width extensions
Index: gcc/gcc/config/i386/mingw32.h
===================================================================
--- gcc.orig/gcc/config/i386/mingw32.h
+++ gcc/gcc/config/i386/mingw32.h
@@ -167,6 +167,10 @@ do {						         \
 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
 
+/* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
+#undef TARGET_OVERRIDES_FORMAT_INIT
+#define TARGET_OVERRIDES_FORMAT_INIT msformat_init
+
 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
 #undef TARGET_FORMAT_TYPES
 #define TARGET_FORMAT_TYPES mingw_format_attributes
Index: gcc/gcc/config/i386/msformat-c.c
===================================================================
--- gcc.orig/gcc/config/i386/msformat-c.c
+++ gcc/gcc/config/i386/msformat-c.c
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3.  
 
 /* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime.  */
 
-static const format_length_info ms_printf_length_specs[] =
+static format_length_info ms_printf_length_specs[] =
 {
   { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
   { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
@@ -173,3 +173,22 @@ const target_ovr_attr mingw_format_attri
   { "ms_scanf", "scanf" },
   { "ms_strftime", "strftime" }
 };
+
+/* Setup for option Wpedantic-ms-format.  */
+
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+
+/* Helper.  */
+#define C89_OR_EXT (warn_pedantic_ms_format ? STD_EXT : STD_C89)
+
+void
+TARGET_OVERRIDES_FORMAT_INIT (void)
+{
+  ms_printf_length_specs[2].std = C89_OR_EXT; /* I32 */
+  ms_printf_length_specs[3].std = C89_OR_EXT; /* I64 */
+  ms_printf_length_specs[4].std = C89_OR_EXT; /* I */
+}
+
+#undef C89_OR_EXT
+
+#endif
Index: gcc/gcc/doc/tm.texi
===================================================================
--- gcc.orig/gcc/doc/tm.texi
+++ gcc/gcc/doc/tm.texi
@@ -10528,6 +10528,12 @@ If defined, this macro specifies the num
 @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
 @end defmac
 
+@defmac TARGET_OVERRIDES_FORMAT_INIT
+If defined, this macro specifies the optional initialization
+routine for target specific customizations of the system printf
+and scanf formatter settings.
+@end defmac
+
 @deftypefn {Target Hook} bool TARGET_RELAXED_ORDERING
 If set to @code{true}, means that the target's memory model does not
 guarantee that loads which do not depend on one another will access
Index: gcc/gcc/doc/invoke.texi
===================================================================
--- gcc.orig/gcc/doc/invoke.texi
+++ gcc/gcc/doc/invoke.texi
@@ -249,7 +249,8 @@ Objective-C and Objective-C++ Dialects}.
 -Wmissing-noreturn  -Wno-mudflap @gol
 -Wno-multichar  -Wnonnull  -Wno-overflow @gol
 -Woverlength-strings  -Wpacked  -Wpadded @gol
--Wparentheses  -Wpointer-arith  -Wno-pointer-to-int-cast @gol
+-Wparentheses  -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
+-Wpointer-arith  -Wno-pointer-to-int-cast @gol
 -Wredundant-decls @gol
 -Wreturn-type  -Wsequence-point  -Wshadow @gol
 -Wsign-compare  -Wsign-conversion  -Wstack-protector @gol
@@ -3567,6 +3568,15 @@ assume anything on the bounds of the loo
 @option{-funsafe-loop-optimizations} warn if the compiler made
 such assumptions.
 
+@item -Wno-pedantic-ms-format
+@opindex Wno-pedantic-ms-format
+@opindex Wpedantic-ms-format
+Disables the warnings about none-ISO @code{printf} / @code{scanf} format
+width specifiers @code{I32}, @code{I64}, and @code{I} used in windows targets
+depending on the ms runtime, when you are using the option @option{-std=}
+set an ISO standard without gnu-extensions, or the options @option{-Wformat}
+and @option{-pedantic}.
+
 @item -Wpointer-arith
 @opindex Wpointer-arith
 @opindex Wno-pointer-arith
=

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in  build
  2008-09-05 16:28         ` Kai Tietz
@ 2008-09-05 20:18           ` Joseph S. Myers
  2008-09-08 10:54             ` Kai Tietz
  0 siblings, 1 reply; 25+ messages in thread
From: Joseph S. Myers @ 2008-09-05 20:18 UTC (permalink / raw)
  To: Kai Tietz
  Cc: Aaron W. LaFramboise, Danny Smith, gcc-patches, Kai Tietz, NightStrike

On Fri, 5 Sep 2008, Kai Tietz wrote:

> I missed to refresh my patch file. Sorry for this. I introduced prev_value 
> to prevent the multiple setting of the array elements. If you mean, I can 
> remove this code.

An initialization hook should be called just once - but it looks like it 
would be harmless to call this more than once even without the prev_value 
code.  Furthermore, I think you can initialize the variable to 1 rather 
than needing to check for a -1 value.  Only the -Wno- version has any 
effect, after all, and the documentation should make that clear (that the 
-Wno- option disables some warnings with -Wformat -pedantic).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-05 14:07       ` Joseph S. Myers
@ 2008-09-05 16:28         ` Kai Tietz
  2008-09-05 20:18           ` Joseph S. Myers
  0 siblings, 1 reply; 25+ messages in thread
From: Kai Tietz @ 2008-09-05 16:28 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Aaron W. LaFramboise, Danny Smith, gcc-patches, Kai Tietz, NightStrike

[-- Attachment #1: Type: text/plain, Size: 2285 bytes --]

"Joseph S. Myers" <joseph@codesourcery.com> wrote on 05.09.2008 16:01:21:

> On Fri, 5 Sep 2008, Kai Tietz wrote:
> 
> > Hi Joseph,
> > 
> > "Joseph S. Myers" <joseph@codesourcery.com> wrote on 05.09.2008 
15:48:48:
> > 
> > > On Fri, 5 Sep 2008, Kai Tietz wrote:
> > > 
> > > > I tested this patch for x86_64-pc-mingw32. Is this patch ok for 
apply?
> > > 
> > > Could you then explain how it passed testing with a single reference 
to 
> > > "warn_pedantice_ms_format" that appears to be a type?
> > 
> > Please see mingw.opt. It is an autogenerated variable (no type ?!).
> 
> The code uses both "warn_pedantic_ms_format" and 
> "warn_pedantice_ms_format", and it's the latter that's the typo (sorry). 
 
> I must suspect that your testing did not compile that part of the code 
at 
> all.  I also don't see why you need any of the code involving 
prev_value.
I missed to refresh my patch file. Sorry for this. I introduced prev_value 
to prevent the multiple setting of the array elements. If you mean, I can 
remove this code.

> > > It doesn't document the new option, and doesn't add any testcases, 
so 
> > > isn't ready for review anyway, and the patch should not change the 
> > > existing defaults for any warnings.
> > Well, about the place of the documentation of the option, I was 
uncertain. 
> > Maybe you could give me a hint to which .texi file it should be added.
> > The default value, altered in the attached patch.
> 
> Command-line options are documented in invoke.texi.
Thanks, I added some lines to invoke.texi for the new mingw option.

2008-09-05  Kai Tietz  <kai.tietz@onevision.com>

        Fix PR/25502
        * c-format.c (convert_format_name_to_system_name): Use
        TARGET_OVERRIDES_FORMAT_INIT.
        * config.gcc (extra_options): Add for mingw targets mingw.opt.
        * config/i386/mingw.opt: New.
        * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
        * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
        (ms_printf_length_specs): Removed const specifier.
        * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.
        * doc/invoke.texi (Wpedantic-ms-format): New.

Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.


[-- Attachment #2: mingw-ped-warning.txt --]
[-- Type: text/plain, Size: 6695 bytes --]

Index: gcc/gcc/c-format.c
===================================================================
--- gcc.orig/gcc/c-format.c
+++ gcc/gcc/c-format.c
@@ -2714,6 +2714,9 @@ extern const format_kind_info TARGET_FOR
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
 extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
 #endif
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  extern void TARGET_OVERRIDES_FORMAT_INIT (void);
+#endif
 
 /* Attributes such as "printf" are equivalent to those such as
    "gnu_printf" unless this is overridden by a target.  */
@@ -2738,6 +2741,9 @@ convert_format_name_to_system_name (cons
   if (attr_name == NULL || *attr_name == 0
       || strncmp (attr_name, "gcc_", 4) == 0)
     return attr_name;
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  TARGET_OVERRIDES_FORMAT_INIT ();
+#endif
 
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
   /* Check if format attribute is overridden by target.  */
Index: gcc/gcc/config.gcc
===================================================================
--- gcc.orig/gcc/config.gcc
+++ gcc/gcc/config.gcc
@@ -1270,7 +1270,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 	xm_file=i386/xm-mingw32.h
 	tmake_file="${tmake_file} i386/t-cygming i386/t-mingw32"
 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
-	extra_options="${extra_options} i386/cygming.opt"
+	extra_options="${extra_options} i386/cygming.opt i386/mingw.opt"
 	extra_objs="winnt.o winnt-stubs.o"
 	c_target_objs="${c_target_objs} msformat-c.o"
 	cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
Index: gcc/gcc/config/i386/mingw.opt
===================================================================
--- /dev/null
+++ gcc/gcc/config/i386/mingw.opt
@@ -0,0 +1,23 @@
+; MinGW-specific options.
+
+; Copyright (C) 2008 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+Wpedantic-ms-format
+C ObjC C++ ObjC++ Var(warn_pedantic_ms_format) Init(-1) Warning
+Warn about none ISO msvcrt scanf/printf width extensions
Index: gcc/gcc/config/i386/mingw32.h
===================================================================
--- gcc.orig/gcc/config/i386/mingw32.h
+++ gcc/gcc/config/i386/mingw32.h
@@ -167,6 +167,10 @@ do {						         \
 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
 
+/* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
+#undef TARGET_OVERRIDES_FORMAT_INIT
+#define TARGET_OVERRIDES_FORMAT_INIT msformat_init
+
 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
 #undef TARGET_FORMAT_TYPES
 #define TARGET_FORMAT_TYPES mingw_format_attributes
Index: gcc/gcc/config/i386/msformat-c.c
===================================================================
--- gcc.orig/gcc/config/i386/msformat-c.c
+++ gcc/gcc/config/i386/msformat-c.c
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3.  
 
 /* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime.  */
 
-static const format_length_info ms_printf_length_specs[] =
+static format_length_info ms_printf_length_specs[] =
 {
   { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
   { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
@@ -173,3 +173,31 @@ const target_ovr_attr mingw_format_attri
   { "ms_scanf", "scanf" },
   { "ms_strftime", "strftime" }
 };
+
+/* Setup for option Wpedantic-ms-format.  */
+
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+
+/* Helper.  */
+#define C89_OR_EXT (warn_pedantic_ms_format ? STD_EXT : STD_C89)
+
+void
+TARGET_OVERRIDES_FORMAT_INIT (void)
+{
+  static int prev_value = -1;
+  /* Setup warn_pedantic to default for 32-bit to warn and for 64-bit
+     to not warn by default.  */
+  if (warn_pedantic_ms_format == -1)
+    warn_pedantic_ms_format = 1;
+  if (prev_value == warn_pedantic_ms_format)
+    return;
+  prev_value = warn_pedantic_ms_format;
+
+  ms_printf_length_specs[2].std = C89_OR_EXT; /* I32 */
+  ms_printf_length_specs[3].std = C89_OR_EXT; /* I64 */
+  ms_printf_length_specs[4].std = C89_OR_EXT; /* I */
+}
+
+#undef C89_OR_EXT
+
+#endif
Index: gcc/gcc/doc/tm.texi
===================================================================
--- gcc.orig/gcc/doc/tm.texi
+++ gcc/gcc/doc/tm.texi
@@ -10528,6 +10528,12 @@ If defined, this macro specifies the num
 @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
 @end defmac
 
+@defmac TARGET_OVERRIDES_FORMAT_INIT
+If defined, this macro specifies the optional initialization
+routine for target specific customizations of the system printf
+and scanf formatter settings.
+@end defmac
+
 @deftypefn {Target Hook} bool TARGET_RELAXED_ORDERING
 If set to @code{true}, means that the target's memory model does not
 guarantee that loads which do not depend on one another will access
Index: gcc/gcc/doc/invoke.texi
===================================================================
--- gcc.orig/gcc/doc/invoke.texi
+++ gcc/gcc/doc/invoke.texi
@@ -249,7 +249,8 @@ Objective-C and Objective-C++ Dialects}.
 -Wmissing-noreturn  -Wno-mudflap @gol
 -Wno-multichar  -Wnonnull  -Wno-overflow @gol
 -Woverlength-strings  -Wpacked  -Wpadded @gol
--Wparentheses  -Wpointer-arith  -Wno-pointer-to-int-cast @gol
+-Wparentheses  -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
+-Wpointer-arith  -Wno-pointer-to-int-cast @gol
 -Wredundant-decls @gol
 -Wreturn-type  -Wsequence-point  -Wshadow @gol
 -Wsign-compare  -Wsign-conversion  -Wstack-protector @gol
@@ -3567,6 +3568,14 @@ assume anything on the bounds of the loo
 @option{-funsafe-loop-optimizations} warn if the compiler made
 such assumptions.
 
+@item -Wpedantic-ms-format
+@opindex Wpedantic-ms-format
+@opindex Wno-pedantic-ms-format
+Warn about none-ISO @code{printf} / @code{scanf} format width specifiers
+@code{I32}, @code{I64}, and @code{I} used in windows targets depending on
+the ms runtime. By default this warning is on for @option{-std=} set an ISO
+standard.
+
 @item -Wpointer-arith
 @opindex Wpointer-arith
 @opindex Wno-pointer-arith
=

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in  build
  2008-09-05 14:02     ` Kai Tietz
@ 2008-09-05 14:07       ` Joseph S. Myers
  2008-09-05 16:28         ` Kai Tietz
  0 siblings, 1 reply; 25+ messages in thread
From: Joseph S. Myers @ 2008-09-05 14:07 UTC (permalink / raw)
  To: Kai Tietz
  Cc: Aaron W. LaFramboise, Danny Smith, gcc-patches, Kai Tietz, NightStrike

On Fri, 5 Sep 2008, Kai Tietz wrote:

> Hi Joseph,
> 
> "Joseph S. Myers" <joseph@codesourcery.com> wrote on 05.09.2008 15:48:48:
> 
> > On Fri, 5 Sep 2008, Kai Tietz wrote:
> > 
> > > I tested this patch for x86_64-pc-mingw32. Is this patch ok for apply?
> > 
> > Could you then explain how it passed testing with a single reference to 
> > "warn_pedantice_ms_format" that appears to be a type?
> 
> Please see mingw.opt. It is an autogenerated variable (no type ?!).

The code uses both "warn_pedantic_ms_format" and 
"warn_pedantice_ms_format", and it's the latter that's the typo (sorry).  
I must suspect that your testing did not compile that part of the code at 
all.  I also don't see why you need any of the code involving prev_value.

> > It doesn't document the new option, and doesn't add any testcases, so 
> > isn't ready for review anyway, and the patch should not change the 
> > existing defaults for any warnings.
> Well, about the place of the documentation of the option, I was uncertain. 
> Maybe you could give me a hint to which .texi file it should be added.
> The default value, altered in the attached patch.

Command-line options are documented in invoke.texi.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-05 13:57   ` Joseph S. Myers
@ 2008-09-05 14:02     ` Kai Tietz
  2008-09-05 14:07       ` Joseph S. Myers
  0 siblings, 1 reply; 25+ messages in thread
From: Kai Tietz @ 2008-09-05 14:02 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Aaron W. LaFramboise, Danny Smith, gcc-patches, Kai Tietz, NightStrike

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

Hi Joseph,

"Joseph S. Myers" <joseph@codesourcery.com> wrote on 05.09.2008 15:48:48:

> On Fri, 5 Sep 2008, Kai Tietz wrote:
> 
> > I tested this patch for x86_64-pc-mingw32. Is this patch ok for apply?
> 
> Could you then explain how it passed testing with a single reference to 
> "warn_pedantice_ms_format" that appears to be a type?

Please see mingw.opt. It is an autogenerated variable (no type ?!).

> It doesn't document the new option, and doesn't add any testcases, so 
> isn't ready for review anyway, and the patch should not change the 
> existing defaults for any warnings.
Well, about the place of the documentation of the option, I was uncertain. 
Maybe you could give me a hint to which .texi file it should be added.
The default value, altered in the attached patch.

Cheers,
Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.


[-- Attachment #2: mingw-ped-warning.txt --]
[-- Type: text/plain, Size: 5451 bytes --]

Index: gcc/gcc/c-format.c
===================================================================
--- gcc.orig/gcc/c-format.c
+++ gcc/gcc/c-format.c
@@ -2714,6 +2714,9 @@ extern const format_kind_info TARGET_FOR
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
 extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
 #endif
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  extern void TARGET_OVERRIDES_FORMAT_INIT (void);
+#endif
 
 /* Attributes such as "printf" are equivalent to those such as
    "gnu_printf" unless this is overridden by a target.  */
@@ -2738,6 +2741,9 @@ convert_format_name_to_system_name (cons
   if (attr_name == NULL || *attr_name == 0
       || strncmp (attr_name, "gcc_", 4) == 0)
     return attr_name;
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  TARGET_OVERRIDES_FORMAT_INIT ();
+#endif
 
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
   /* Check if format attribute is overridden by target.  */
Index: gcc/gcc/config.gcc
===================================================================
--- gcc.orig/gcc/config.gcc
+++ gcc/gcc/config.gcc
@@ -1270,7 +1270,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 	xm_file=i386/xm-mingw32.h
 	tmake_file="${tmake_file} i386/t-cygming i386/t-mingw32"
 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
-	extra_options="${extra_options} i386/cygming.opt"
+	extra_options="${extra_options} i386/cygming.opt i386/mingw.opt"
 	extra_objs="winnt.o winnt-stubs.o"
 	c_target_objs="${c_target_objs} msformat-c.o"
 	cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
Index: gcc/gcc/config/i386/mingw.opt
===================================================================
--- /dev/null
+++ gcc/gcc/config/i386/mingw.opt
@@ -0,0 +1,23 @@
+; MinGW-specific options.
+
+; Copyright (C) 2008 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+Wpedantic-ms-format
+C ObjC C++ ObjC++ Var(warn_pedantic_ms_format) Init(-1) Warning
+Warn about none ISO msvcrt scanf/printf width extensions
Index: gcc/gcc/config/i386/mingw32.h
===================================================================
--- gcc.orig/gcc/config/i386/mingw32.h
+++ gcc/gcc/config/i386/mingw32.h
@@ -167,6 +167,10 @@ do {						         \
 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
 
+/* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
+#undef TARGET_OVERRIDES_FORMAT_INIT
+#define TARGET_OVERRIDES_FORMAT_INIT msformat_init
+
 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
 #undef TARGET_FORMAT_TYPES
 #define TARGET_FORMAT_TYPES mingw_format_attributes
Index: gcc/gcc/config/i386/msformat-c.c
===================================================================
--- gcc.orig/gcc/config/i386/msformat-c.c
+++ gcc/gcc/config/i386/msformat-c.c
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3.  
 
 /* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime.  */
 
-static const format_length_info ms_printf_length_specs[] =
+static format_length_info ms_printf_length_specs[] =
 {
   { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
   { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
@@ -173,3 +173,31 @@ const target_ovr_attr mingw_format_attri
   { "ms_scanf", "scanf" },
   { "ms_strftime", "strftime" }
 };
+
+/* Setup for option Wpedantic-ms-format.  */
+
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+
+/* Helper.  */
+#define C89_OR_EXT (warn_pedantic_ms_format ? STD_EXT : STD_C89)
+
+void
+TARGET_OVERRIDES_FORMAT_INIT (void)
+{
+  static int prev_value = -1;
+  /* Setup warn_pedantic to default for 32-bit to warn and for 64-bit
+     to not warn by default.  */
+  if (warn_pedantic_ms_format == -1)
+    warn_pedantic_ms_format = 1;
+  if (prev_value == warn_pedantice_ms_format)
+    return;
+  prev_value = warn_pedantice_ms_format;
+
+  ms_printf_length_specs[2].std = C89_OR_EXT; /* I32 */
+  ms_printf_length_specs[3].std = C89_OR_EXT; /* I64 */
+  ms_printf_length_specs[4].std = C89_OR_EXT; /* I */
+}
+
+#undef C89_OR_EXT
+
+#endif
Index: gcc/gcc/doc/tm.texi
===================================================================
--- gcc.orig/gcc/doc/tm.texi
+++ gcc/gcc/doc/tm.texi
@@ -10528,6 +10528,12 @@ If defined, this macro specifies the num
 @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
 @end defmac
 
+@defmac TARGET_OVERRIDES_FORMAT_INIT
+If defined, this macro specifies the optional initialization
+routine for target specific customizations of the system printf
+and scanf formatter settings.
+@end defmac
+
 @deftypefn {Target Hook} bool TARGET_RELAXED_ORDERING
 If set to @code{true}, means that the target's memory model does not
 guarantee that loads which do not depend on one another will access
=

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in  build
  2008-09-05 11:21 ` [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build Kai Tietz
@ 2008-09-05 13:57   ` Joseph S. Myers
  2008-09-05 14:02     ` Kai Tietz
  0 siblings, 1 reply; 25+ messages in thread
From: Joseph S. Myers @ 2008-09-05 13:57 UTC (permalink / raw)
  To: Kai Tietz
  Cc: Danny Smith, gcc-patches, Kai Tietz, NightStrike, Aaron W. LaFramboise

On Fri, 5 Sep 2008, Kai Tietz wrote:

> I tested this patch for x86_64-pc-mingw32. Is this patch ok for apply?

Could you then explain how it passed testing with a single reference to 
"warn_pedantice_ms_format" that appears to be a type?

It doesn't document the new option, and doesn't add any testcases, so 
isn't ready for review anyway, and the patch should not change the 
existing defaults for any warnings.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
  2008-09-04  8:00 [PATCH] Build libgcc_s on Windows Danny Smith
@ 2008-09-05 11:21 ` Kai Tietz
  2008-09-05 13:57   ` Joseph S. Myers
  0 siblings, 1 reply; 25+ messages in thread
From: Kai Tietz @ 2008-09-05 11:21 UTC (permalink / raw)
  To: Danny Smith; +Cc: gcc-patches, Kai Tietz, NightStrike, Aaron W. LaFramboise

[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]

Hello,

this patch fixes PR/25502 by introducing an optional custom initialization 
routine to c-format.c. I named it TARGET_OVERRIDES_FORMAT_INIT, 
accordingly to the other target macros there. I introduced for mingw 
targets an new warning named -Wpedantic-ms-format. By default it is on for 
32-bit, for 64-bit by default off.

ChangeLog

2008-09-05  Kai Tietz  <kai.tietz@onevision.com>

        Fix PR/25502
        * c-format.c (convert_format_name_to_system_name): Use
        TARGET_OVERRIDES_FORMAT_INIT.
        * config.gcc (extra_options): Add for mingw targets mingw.opt.
        * config/i386/mingw.opt: New.
        * config/i386/mingw32.h (TARGET_OVERRIDES_FORMAT_INIT): New.
        * config/i386/msformat-c.c (TARGET_OVERRIDES_FORMAT_INIT): New.
        (ms_printf_length_specs): Removed const specifier.
        * doc/tm.texi (TARGET_OVERRIDES_FORMAT_INIT): New.

I tested this patch for x86_64-pc-mingw32. Is this patch ok for apply?

Cheers,
Kai

|  (\_/)  This is Bunny. Copy and paste Bunny
| (='.'=) into your signature to help him gain
| (")_(") world domination.


[-- Attachment #2: mingw-ped-warning.txt --]
[-- Type: text/plain, Size: 5400 bytes --]

Index: gcc/gcc/c-format.c
===================================================================
--- gcc.orig/gcc/c-format.c
+++ gcc/gcc/c-format.c
@@ -2714,6 +2714,9 @@ extern const format_kind_info TARGET_FOR
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
 extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
 #endif
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  extern void TARGET_OVERRIDES_FORMAT_INIT (void);
+#endif
 
 /* Attributes such as "printf" are equivalent to those such as
    "gnu_printf" unless this is overridden by a target.  */
@@ -2738,6 +2741,9 @@ convert_format_name_to_system_name (cons
   if (attr_name == NULL || *attr_name == 0
       || strncmp (attr_name, "gcc_", 4) == 0)
     return attr_name;
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+  TARGET_OVERRIDES_FORMAT_INIT ();
+#endif
 
 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
   /* Check if format attribute is overridden by target.  */
Index: gcc/gcc/config.gcc
===================================================================
--- gcc.orig/gcc/config.gcc
+++ gcc/gcc/config.gcc
@@ -1270,7 +1270,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
 	xm_file=i386/xm-mingw32.h
 	tmake_file="${tmake_file} i386/t-cygming i386/t-mingw32"
 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
-	extra_options="${extra_options} i386/cygming.opt"
+	extra_options="${extra_options} i386/cygming.opt i386/mingw.opt"
 	extra_objs="winnt.o winnt-stubs.o"
 	c_target_objs="${c_target_objs} msformat-c.o"
 	cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
Index: gcc/gcc/config/i386/mingw.opt
===================================================================
--- /dev/null
+++ gcc/gcc/config/i386/mingw.opt
@@ -0,0 +1,23 @@
+; MinGW-specific options.
+
+; Copyright (C) 2008 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 3, or (at your option) any later
+; version.
+;
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING3.  If not see
+; <http://www.gnu.org/licenses/>.
+
+Wpedantic-ms-format
+C ObjC C++ ObjC++ Var(warn_pedantic_ms_format) Init(-1) Warning
+Warn about none ISO msvcrt scanf/printf width extensions
Index: gcc/gcc/config/i386/mingw32.h
===================================================================
--- gcc.orig/gcc/config/i386/mingw32.h
+++ gcc/gcc/config/i386/mingw32.h
@@ -167,6 +167,10 @@ do {						         \
 #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
 #define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
 
+/* Custom initialization for warning -Wpedantic-ms-format for c-format.  */
+#undef TARGET_OVERRIDES_FORMAT_INIT
+#define TARGET_OVERRIDES_FORMAT_INIT msformat_init
+
 /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
 #undef TARGET_FORMAT_TYPES
 #define TARGET_FORMAT_TYPES mingw_format_attributes
Index: gcc/gcc/config/i386/msformat-c.c
===================================================================
--- gcc.orig/gcc/config/i386/msformat-c.c
+++ gcc/gcc/config/i386/msformat-c.c
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3.  
 
 /* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime.  */
 
-static const format_length_info ms_printf_length_specs[] =
+static format_length_info ms_printf_length_specs[] =
 {
   { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
   { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
@@ -173,3 +173,26 @@ const target_ovr_attr mingw_format_attri
   { "ms_scanf", "scanf" },
   { "ms_strftime", "strftime" }
 };
+
+/* Setup for option Wpedantic-ms-format.  */
+
+#ifdef TARGET_OVERRIDES_FORMAT_INIT
+
+/* Helper.  */
+#define C89_OR_EXT (warn_pedantic_ms_format ? STD_EXT : STD_C89)
+
+void
+TARGET_OVERRIDES_FORMAT_INIT (void)
+{
+  static int prev_value = -1;
+  /* Setup warn_pedantic to default for 32-bit to warn and for 64-bit
+     to not warn by default.  */
+  if (warn_pedantic_ms_format == -1)
+    warn_pedantic_ms_format = (TARGET_64BIT ? 0 : 1);
+  if (prev_value == warn_pedantice_ms_format)
+    return;
+  ms_printf_length_specs[2].std = C89_OR_EXT; /* I32 */
+  ms_printf_length_specs[3].std = C89_OR_EXT; /* I64 */
+  ms_printf_length_specs[4].std = C89_OR_EXT; /* I */
+}
+#endif
Index: gcc/gcc/doc/tm.texi
===================================================================
--- gcc.orig/gcc/doc/tm.texi
+++ gcc/gcc/doc/tm.texi
@@ -10528,6 +10528,12 @@ If defined, this macro specifies the num
 @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
 @end defmac
 
+@defmac TARGET_OVERRIDES_FORMAT_INIT
+If defined, this macro specifies the optional initialization
+routine for target specific customizations of the system printf
+and scanf formatter settings.
+@end defmac
+
 @deftypefn {Target Hook} bool TARGET_RELAXED_ORDERING
 If set to @code{true}, means that the target's memory model does not
 guarantee that loads which do not depend on one another will access
=

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2008-11-21 13:58 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <OFB5BC0CC2.0ADC574F-ONC12574E1.0039EBC2-C12574E1.0039FBF6@LocalDomain>
2008-11-21 14:09 ` [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build Kai Tietz
2008-09-04  8:00 [PATCH] Build libgcc_s on Windows Danny Smith
2008-09-05 11:21 ` [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build Kai Tietz
2008-09-05 13:57   ` Joseph S. Myers
2008-09-05 14:02     ` Kai Tietz
2008-09-05 14:07       ` Joseph S. Myers
2008-09-05 16:28         ` Kai Tietz
2008-09-05 20:18           ` Joseph S. Myers
2008-09-08 10:54             ` Kai Tietz
2008-09-08 12:28               ` Joseph S. Myers
2008-09-08 12:42                 ` Kai Tietz
2008-09-08 15:44                   ` Joseph S. Myers
2008-09-09  0:12                     ` Aaron W. LaFramboise
2008-09-09  5:42                       ` Danny Smith
2008-09-09  6:01                         ` Kai Tietz
2008-09-12 15:33                         ` Kai Tietz
2008-09-12 15:40                         ` Aaron W. LaFramboise
2008-09-12 16:04                           ` NightStrike
2008-09-12 16:38                         ` NightStrike
2008-09-12 21:42                           ` Danny Smith
2008-10-10 12:14                         ` Kai Tietz
2008-10-11 10:27                           ` Danny Smith
2008-10-11 15:34                             ` Kai Tietz
2008-10-12  9:48                           ` Danny Smith
2008-10-13 11:36                             ` Kai Tietz
2008-09-15  8:18                   ` Aaron W. LaFramboise

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).