Commit 94564826 by Kai Tietz Committed by Kai Tietz

Fix PR/25502

2008-10-13  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.
	* testsuite/gcc.dg/format/ms-format1.c: New.

From-SVN: r141087
parent 36c713e0
2008-10-13 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-10-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2008-10-13 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.c: Remove MPFR_VERSION_NUM(2,3,0) conditionals. * builtins.c: Remove MPFR_VERSION_NUM(2,3,0) conditionals.
......
...@@ -2714,6 +2714,9 @@ extern const format_kind_info TARGET_FORMAT_TYPES[]; ...@@ -2714,6 +2714,9 @@ extern const format_kind_info TARGET_FORMAT_TYPES[];
#ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[]; extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
#endif #endif
#ifdef TARGET_OVERRIDES_FORMAT_INIT
extern void TARGET_OVERRIDES_FORMAT_INIT (void);
#endif
/* Attributes such as "printf" are equivalent to those such as /* Attributes such as "printf" are equivalent to those such as
"gnu_printf" unless this is overridden by a target. */ "gnu_printf" unless this is overridden by a target. */
...@@ -2738,6 +2741,9 @@ convert_format_name_to_system_name (const char *attr_name) ...@@ -2738,6 +2741,9 @@ convert_format_name_to_system_name (const char *attr_name)
if (attr_name == NULL || *attr_name == 0 if (attr_name == NULL || *attr_name == 0
|| strncmp (attr_name, "gcc_", 4) == 0) || strncmp (attr_name, "gcc_", 4) == 0)
return attr_name; return attr_name;
#ifdef TARGET_OVERRIDES_FORMAT_INIT
TARGET_OVERRIDES_FORMAT_INIT ();
#endif
#ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES #ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
/* Check if format attribute is overridden by target. */ /* Check if format attribute is overridden by target. */
......
...@@ -1270,7 +1270,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*) ...@@ -1270,7 +1270,7 @@ i[34567]86-*-mingw* | x86_64-*-mingw*)
xm_file=i386/xm-mingw32.h xm_file=i386/xm-mingw32.h
tmake_file="${tmake_file} i386/t-cygming i386/t-mingw32" tmake_file="${tmake_file} i386/t-cygming i386/t-mingw32"
target_gtfiles="\$(srcdir)/config/i386/winnt.c" 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" extra_objs="winnt.o winnt-stubs.o"
c_target_objs="${c_target_objs} msformat-c.o" c_target_objs="${c_target_objs} msformat-c.o"
cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o" cxx_target_objs="${cxx_target_objs} winnt-cxx.o msformat-c.o"
......
; 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
...@@ -169,6 +169,10 @@ do { \ ...@@ -169,6 +169,10 @@ do { \
#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT #undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3 #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. */ /* MS specific format attributes for ms_printf, ms_scanf, ms_strftime. */
#undef TARGET_FORMAT_TYPES #undef TARGET_FORMAT_TYPES
#define TARGET_FORMAT_TYPES mingw_format_attributes #define TARGET_FORMAT_TYPES mingw_format_attributes
......
...@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3. If not see
/* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime. */ /* 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 }, { "h", FMT_LEN_h, STD_C89, NULL, 0, 0 },
{ "l", FMT_LEN_l, STD_C89, NULL, 0, 0 }, { "l", FMT_LEN_l, STD_C89, NULL, 0, 0 },
...@@ -173,3 +173,25 @@ const target_ovr_attr mingw_format_attribute_overrides[4] = ...@@ -173,3 +173,25 @@ const target_ovr_attr mingw_format_attribute_overrides[4] =
{ "ms_scanf", "scanf" }, { "ms_scanf", "scanf" },
{ "ms_strftime", "strftime" } { "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
...@@ -250,7 +250,8 @@ Objective-C and Objective-C++ Dialects}. ...@@ -250,7 +250,8 @@ Objective-C and Objective-C++ Dialects}.
-Wmissing-noreturn -Wno-mudflap @gol -Wmissing-noreturn -Wno-mudflap @gol
-Wno-multichar -Wnonnull -Wno-overflow @gol -Wno-multichar -Wnonnull -Wno-overflow @gol
-Woverlength-strings -Wpacked -Wpadded @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 -Wredundant-decls @gol
-Wreturn-type -Wsequence-point -Wshadow @gol -Wreturn-type -Wsequence-point -Wshadow @gol
-Wsign-compare -Wsign-conversion -Wstack-protector @gol -Wsign-compare -Wsign-conversion -Wstack-protector @gol
...@@ -3572,6 +3573,14 @@ assume anything on the bounds of the loop indices. With ...@@ -3572,6 +3573,14 @@ assume anything on the bounds of the loop indices. With
@option{-funsafe-loop-optimizations} warn if the compiler made @option{-funsafe-loop-optimizations} warn if the compiler made
such assumptions. 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 @item -Wpointer-arith
@opindex Wpointer-arith @opindex Wpointer-arith
@opindex Wno-pointer-arith @opindex Wno-pointer-arith
......
...@@ -10539,6 +10539,12 @@ If defined, this macro specifies the number of entries in ...@@ -10539,6 +10539,12 @@ If defined, this macro specifies the number of entries in
@code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}. @code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
@end defmac @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 @deftypefn {Target Hook} bool TARGET_RELAXED_ORDERING
If set to @code{true}, means that the target's memory model does not 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 guarantee that loads which do not depend on one another will access
......
2008-10-13 Kai Tietz <kai.tietz@onevision.com>
* testsuite/gcc.dg/format/ms-format1.c: New.
2008-10-12 Daniel Kraft <d@domob.eu> 2008-10-12 Daniel Kraft <d@domob.eu>
PR fortran/37688 PR fortran/37688
......
/* 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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment