public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kai Tietz <Kai.Tietz@onevision.com>
To: "Danny Smith" <dansmister@gmail.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	        "Joseph S. Myers" <joseph@codesourcery.com>,
	        "Kai Tietz" <ktietz70@googlemail.com>,
	        NightStrike <nightstrike@gmail.com>
Subject: Re: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build
Date: Fri, 10 Oct 2008 12:14:00 -0000	[thread overview]
Message-ID: <OF0E4D3105.51E14B66-ONC12574DE.0039B8DE-C12574DE.003A61CD@onevision.de> (raw)
In-Reply-To: <9c03c2dd0809082132h2e70ae68kc1386cf5ce9bc539@mail.gmail.com>

[-- 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
=

  parent reply	other threads:[~2008-10-10 10:38 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-18 19:08 [PATCH] Build libgcc_s on Windows Aaron W. LaFramboise
2008-08-19  5:16 ` Danny Smith
2008-08-20 14:30   ` Aaron W. LaFramboise
2008-08-21  5:15     ` Danny Smith
2008-08-28  4:15       ` Dave Korn
2008-08-28  9:15         ` Danny Smith
2008-08-28  9:35           ` Brian Dessent
2008-08-19  8:05 ` Paolo Bonzini
2008-08-19 13:20   ` Aaron W. LaFramboise
2008-08-19 16:17     ` Paolo Bonzini
2008-09-02  6:40 ` NightStrike
2008-09-02 12:03   ` Kai Tietz
2008-09-02 16:30     ` NightStrike
2008-09-03  9:51       ` Kai Tietz
2008-09-03 18:03         ` NightStrike
2008-09-04  3:52         ` Danny Smith
2008-09-04  6:25           ` NightStrike
2008-09-04  8:00             ` Danny Smith
2008-09-04 10:48               ` [patch i386]: Adjust DWARF_OFFSET_SIZE for w64 Kai Tietz
2008-09-04 16:30                 ` NightStrike
2008-09-09 21:18                 ` Richard Henderson
2008-09-10  8:20                   ` Kai Tietz
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 [this message]
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
2008-09-04  8:31           ` [PATCH] Build libgcc_s on Windows Kai Tietz
2008-09-09 19:57           ` lkcl
2008-09-10  8:49             ` lkcl
2008-09-10  9:11               ` Brian Dessent
2008-09-10  9:26                 ` lkcl
2008-09-10 12:32                   ` lkcl
2008-09-10  9:19               ` lkcl
     [not found] <1221035558.13510.ezmlm@gcc.gnu.org>
2008-09-10  9:09 ` Jay
2008-09-10  9:43   ` lkcl
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OF0E4D3105.51E14B66-ONC12574DE.0039B8DE-C12574DE.003A61CD@onevision.de \
    --to=kai.tietz@onevision.com \
    --cc=dansmister@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=ktietz70@googlemail.com \
    --cc=nightstrike@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).