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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141087
138bc75d-0d04-0410-961f-
82ee72b054a4
+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>
* builtins.c: Remove MPFR_VERSION_NUM(2,3,0) conditionals.
#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. */
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. */
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"
--- /dev/null
+; 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
#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
/* 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 },
{ "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
-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
@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
@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
+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>
PR fortran/37688
--- /dev/null
+/* 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);
+}