From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6993 invoked by alias); 5 Sep 2008 11:09:03 -0000 Received: (qmail 6984 invoked by uid 22791); 5 Sep 2008 11:09:02 -0000 X-Spam-Check-By: sourceware.org Received: from outdoor.onevision.de (HELO outdoor.onevision.de) (212.77.172.51) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 05 Sep 2008 11:08:04 +0000 Received: from sanders.onevision.de (moonrace [212.77.172.62]) by outdoor.onevision.de (8.13.7/8.13.7/ROSCH/DDB) with ESMTP id m85B7nn6025011; Fri, 5 Sep 2008 13:07:52 +0200 In-Reply-To: <9c03c2dd0809040017m1f1d2700jc2d3e6883964c36e@mail.gmail.com> To: "Danny Smith" Cc: gcc-patches , "Kai Tietz" , NightStrike , "Aaron W. LaFramboise" Subject: [patch]: Fix bootstrap/PR 25502: I64d format Werror problem in build MIME-Version: 1.0 X-Mailer: Lotus Notes Release 7.0.1 January 17, 2006 Message-ID: From: Kai Tietz Date: Fri, 05 Sep 2008 11:21:00 -0000 Content-Type: multipart/mixed; boundary="=_mixed 003D21F4C12574BB_=" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-09/txt/msg00470.txt.bz2 --=_mixed 003D21F4C12574BB_= Content-Type: text/plain; charset="US-ASCII" Content-length: 1090 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 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. --=_mixed 003D21F4C12574BB_= Content-Type: text/plain; name="mingw-ped-warning.txt" Content-Disposition: attachment; filename="mingw-ped-warning.txt" Content-Transfer-Encoding: quoted-printable Content-length: 6163 Index: gcc/gcc/c-format.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 /* 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 =3D=3D NULL || *attr_name =3D=3D 0 || strncmp (attr_name, "gcc_", 4) =3D=3D 0) return attr_name; +#ifdef TARGET_OVERRIDES_FORMAT_INIT + TARGET_OVERRIDES_FORMAT_INIT (); +#endif =20 #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES /* Check if format attribute is overridden by target. */ Index: gcc/gcc/config.gcc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- gcc.orig/gcc/config.gcc +++ gcc/gcc/config.gcc @@ -1270,7 +1270,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*) xm_file=3Di386/xm-mingw32.h tmake_file=3D"${tmake_file} i386/t-cygming i386/t-mingw32" target_gtfiles=3D"\$(srcdir)/config/i386/winnt.c" - extra_options=3D"${extra_options} i386/cygming.opt" + extra_options=3D"${extra_options} i386/cygming.opt i386/mingw.opt" extra_objs=3D"winnt.o winnt-stubs.o" c_target_objs=3D"${c_target_objs} msformat-c.o" cxx_target_objs=3D"${cxx_target_objs} winnt-cxx.o msformat-c.o" Index: gcc/gcc/config/i386/mingw.opt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /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 +; . + +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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 +/* 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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.=20=20 =20 /* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime. = */ =20 -static const format_length_info ms_printf_length_specs[] =3D +static format_length_info ms_printf_length_specs[] =3D { { "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 =3D -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 =3D=3D -1) + warn_pedantic_ms_format =3D (TARGET_64BIT ? 0 : 1); + if (prev_value =3D=3D warn_pedantice_ms_format) + return; + ms_printf_length_specs[2].std =3D C89_OR_EXT; /* I32 */ + ms_printf_length_specs[3].std =3D C89_OR_EXT; /* I64 */ + ms_printf_length_specs[4].std =3D C89_OR_EXT; /* I */ +} +#endif Index: gcc/gcc/doc/tm.texi =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 =20 +@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 =3D= --=_mixed 003D21F4C12574BB_=--