SOURCES: crossmingw64-gcc-msvcrt-fmt.patch (NEW) - fixes backported from 4.4.

pluto pluto at pld-linux.org
Mon Sep 22 16:12:30 CEST 2008


Author: pluto                        Date: Mon Sep 22 14:12:30 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- fixes backported from 4.4.

---- Files affected:
SOURCES:
   crossmingw64-gcc-msvcrt-fmt.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/crossmingw64-gcc-msvcrt-fmt.patch
diff -u /dev/null SOURCES/crossmingw64-gcc-msvcrt-fmt.patch:1.1
--- /dev/null	Mon Sep 22 16:12:31 2008
+++ SOURCES/crossmingw64-gcc-msvcrt-fmt.patch	Mon Sep 22 16:12:24 2008
@@ -0,0 +1,3169 @@
+diff -r ddadaee88373 gcc/c-format.c
+--- a/gcc/c-format.c	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/c-format.c	Mon Jun 02 08:07:22 2008 -0600
+@@ -62,8 +62,7 @@
+ 		   gcc_diag_format_type, gcc_tdiag_format_type,
+ 		   gcc_cdiag_format_type,
+ 		   gcc_cxxdiag_format_type, gcc_gfc_format_type,
+-		   scanf_format_type, strftime_format_type,
+-		   strfmon_format_type, format_type_error = -1};
++		   format_type_error = -1};
+ 
+ typedef struct function_format_info
+ {
+@@ -80,7 +79,8 @@
+ 				 int flags, bool *no_add_attrs);
+ static bool get_constant (tree expr, unsigned HOST_WIDE_INT *value,
+ 			  int validated_p);
+-
++static const char *convert_format_name_to_system_name (const char *attr_name);
++static bool cmp_attribs (const char *tattr_name, const char *attr_name);
+ 
+ /* Handle a "format_arg" attribute; arguments as in
+    struct attribute_spec.handler.  */
+@@ -190,6 +190,8 @@
+   else
+     {
+       const char *p = IDENTIFIER_POINTER (format_type_id);
++
++      p = convert_format_name_to_system_name (p);
+ 
+       info->format_type = decode_format_type (p);
+ 
+@@ -715,7 +717,7 @@
+ /* This must be in the same order as enum format_type.  */
+ static const format_kind_info format_types_orig[] =
+ {
+-  { "printf",   printf_length_specs,  print_char_table, " +#0-'I", NULL,
++  { "gnu_printf",   printf_length_specs,  print_char_table, " +#0-'I", NULL,
+     printf_flag_specs, printf_flag_pairs,
+     FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK,
+     'w', 0, 'p', 0, 'L', 0,
+@@ -757,18 +759,18 @@
+     0, 0, 0, 0, 0, 0,
+     NULL, NULL
+   },
+-  { "scanf",    scanf_length_specs,   scan_char_table,  "*'I", NULL,
++  { "gnu_scanf",    scanf_length_specs,   scan_char_table,  "*'I", NULL,
+     scanf_flag_specs, scanf_flag_pairs,
+     FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK,
+     'w', 0, 0, '*', 'L', 'm',
+     NULL, NULL
+   },
+-  { "strftime", NULL,                 time_char_table,  "_-0^#", "EO",
++  { "gnu_strftime", NULL,                 time_char_table,  "_-0^#", "EO",
+     strftime_flag_specs, strftime_flag_pairs,
+     FMT_FLAG_FANCY_PERCENT_OK, 'w', 0, 0, 0, 0, 0,
+     NULL, NULL
+   },
+-  { "strfmon",  strfmon_length_specs, monetary_char_table, "=^+(!-", NULL,
++  { "gnu_strfmon",  strfmon_length_specs, monetary_char_table, "=^+(!-", NULL,
+     strfmon_flag_specs, strfmon_flag_pairs,
+     FMT_FLAG_ARG_CONVERT, 'w', '#', 'p', 0, 'L', 0,
+     NULL, NULL
+@@ -847,6 +849,8 @@
+ {
+   int i;
+   int slen;
++
++  s = convert_format_name_to_system_name (s);
+   slen = strlen (s);
+   for (i = 0; i < n_format_types; i++)
+     {
+@@ -1775,11 +1779,12 @@
+       length_chars_std = STD_C89;
+       if (fli)
+ 	{
+-	  while (fli->name != 0 && fli->name[0] != *format_chars)
+-	    fli++;
++	  while (fli->name != 0 
++ 		 && strncmp (fli->name, format_chars, strlen (fli->name)))
++	      fli++;
+ 	  if (fli->name != 0)
+ 	    {
+-	      format_chars++;
++ 	      format_chars += strlen (fli->name);
+ 	      if (fli->double_name != 0 && fli->name[0] == *format_chars)
+ 		{
+ 		  format_chars++;
+@@ -2703,6 +2708,84 @@
+ extern const format_kind_info TARGET_FORMAT_TYPES[];
+ #endif
+ 
++#ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
++extern const target_ovr_attr TARGET_OVERRIDES_FORMAT_ATTRIBUTES[];
++#endif
++
++/* Attributes such as "printf" are equivalent to those such as
++   "gnu_printf" unless this is overridden by a target.  */
++static const target_ovr_attr gnu_target_overrides_format_attributes[] =
++{
++  { "gnu_printf",   "printf" },
++  { "gnu_scanf",    "scanf" },
++  { "gnu_strftime", "strftime" },
++  { "gnu_strfmon",  "strfmon" },
++  { NULL,           NULL }
++};
++
++/* Translate to unified attribute name. This is used in decode_format_type and
++   decode_format_attr. In attr_name the user specified argument is passed. It
++   returns the unified format name from TARGET_OVERRIDES_FORMAT_ATTRIBUTES
++   or the attr_name passed to this function, if there is no matching entry.  */
++static const char *
++convert_format_name_to_system_name (const char *attr_name)
++{
++  int i;
++
++  if (attr_name == NULL || *attr_name == 0
++      || strncmp (attr_name, "gcc_", 4) == 0)
++    return attr_name;
++
++#ifdef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
++  /* Check if format attribute is overridden by target.  */
++  if (TARGET_OVERRIDES_FORMAT_ATTRIBUTES != NULL
++      && TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT > 0)
++    {
++      for (i = 0; i < TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT; ++i)
++        {
++          if (cmp_attribs (TARGET_OVERRIDES_FORMAT_ATTRIBUTES[i].named_attr_src,
++			   attr_name))
++            return attr_name;
++          if (cmp_attribs (TARGET_OVERRIDES_FORMAT_ATTRIBUTES[i].named_attr_dst,
++			   attr_name))
++            return TARGET_OVERRIDES_FORMAT_ATTRIBUTES[i].named_attr_src;
++        }
++    }
++#endif
++  /* Otherwise default to gnu format.  */
++  for (i = 0;
++       gnu_target_overrides_format_attributes[i].named_attr_src != NULL;
++       ++i)
++    {
++      if (cmp_attribs (gnu_target_overrides_format_attributes[i].named_attr_src,
++		       attr_name))
++        return attr_name;
++      if (cmp_attribs (gnu_target_overrides_format_attributes[i].named_attr_dst,
++		       attr_name))
++        return gnu_target_overrides_format_attributes[i].named_attr_src;
++    }
++
++  return attr_name;
++}
++
++/* Return true if TATTR_NAME and ATTR_NAME are the same format attribute,
++   counting "name" and "__name__" as the same, false otherwise.  */
++static bool
++cmp_attribs (const char *tattr_name, const char *attr_name)
++{
++  int alen = strlen (attr_name);
++  int slen = (tattr_name ? strlen (tattr_name) : 0);
++  if (alen > 4 && attr_name[0] == '_' && attr_name[1] == '_'
++      && attr_name[alen - 1] == '_' && attr_name[alen - 2] == '_')
++    {
++      attr_name += 2;
++      alen -= 4;
++    }
++  if (alen != slen || strncmp (tattr_name, attr_name, alen) != 0)
++    return false;
++  return true;
++}
++
+ /* Handle a "format" attribute; arguments as in
+    struct attribute_spec.handler.  */
+ tree
+@@ -2762,7 +2845,10 @@
+ 	}
+     }
+ 
+-  if (info.format_type == strftime_format_type && info.first_arg_num != 0)
++  /* Check if this is a strftime variant. Just for this variant
++     FMT_FLAG_ARG_CONVERT is not set.  */
++  if ((format_types[info.format_type].flags & (int) FMT_FLAG_ARG_CONVERT) == 0
++      && info.first_arg_num != 0)
+     {
+       error ("strftime formats cannot format arguments");
+       *no_add_attrs = true;
+diff -r ddadaee88373 gcc/c-format.h
+--- a/gcc/c-format.h	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/c-format.h	Mon Jun 02 08:07:22 2008 -0600
+@@ -80,12 +80,13 @@
+      of whether length modifiers can occur (length_char_specs).  */
+ };
+ 
+-
+ /* Structure describing a length modifier supported in format checking, and
+    possibly a doubled version such as "hh".  */
+ typedef struct
+ {
+-  /* Name of the single-character length modifier.  */
++  /* Name of the single-character length modifier. If prefixed by
++     a zero character, it describes a multi character length
++     modifier, like I64, I32, etc.  */
+   const char *name;
+   /* Index into a format_char_info.types array.  */
+   enum format_lengths index;
+@@ -306,4 +307,16 @@
+ #define T_D128  &dfloat128_type_node
+ #define TEX_D128 { STD_EXT, "_Decimal128", T_D128 }
+ 
++/* Structure describing how format attributes such as "printf" are
++   interpreted as "gnu_printf" or "ms_printf" on a particular system.
++   TARGET_OVERRIDES_FORMAT_ATTRIBUTES is used to specify target-specific
++   defaults.  */
++typedef struct
++{
++  /* The name of the to be copied format attribute. */
++  const char *named_attr_src;
++  /* The name of the to be overridden format attribute. */
++  const char *named_attr_dst;
++} target_ovr_attr;
++
+ #endif /* GCC_C_FORMAT_H */
+diff -r ddadaee88373 gcc/config.gcc
+--- a/gcc/config.gcc	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/config.gcc	Mon Jun 02 08:07:22 2008 -0600
+@@ -1365,8 +1365,8 @@
+ 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
+ 	extra_options="${extra_options} i386/cygming.opt"
+ 	extra_objs="winnt.o winnt-stubs.o"
+-	c_target_objs=cygwin2.o
+-	cxx_target_objs="cygwin2.o winnt-cxx.o"
++	c_target_objs="cygwin2.o msformat-c.o"
++	cxx_target_objs="cygwin2.o winnt-cxx.o msformat-c.o"
+ 	extra_gcc_objs=cygwin1.o
+ 	if test x$enable_threads = xyes; then
+ 		thread_file='posix'
+@@ -1379,7 +1379,8 @@
+ 	target_gtfiles="\$(srcdir)/config/i386/winnt.c"
+ 	extra_options="${extra_options} i386/cygming.opt"
+ 	extra_objs="winnt.o winnt-stubs.o"
+-	cxx_target_objs=winnt-cxx.o
++	c_target_objs="msformat-c.o"
++	cxx_target_objs="winnt-cxx.o msformat-c.o"
+ 	default_use_cxa_atexit=yes
+ 	case ${enable_threads} in
+ 	  "" | yes | win32)
+diff -r ddadaee88373 gcc/config/i386/mingw32.h
+--- a/gcc/config/i386/mingw32.h	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/config/i386/mingw32.h	Mon Jun 02 08:07:22 2008 -0600
+@@ -143,6 +143,23 @@
+    to register C++ static destructors.  */
+ #define TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT hook_bool_void_true
+ 
++/* Contains a pointer to type target_ovr_attr defining the target specific
++   overrides of format attributes.  See c-format.h for structure
++   definition.  */
++#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES
++#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES mingw_format_attribute_overrides
++
++/* Specify the count of elements in TARGET_OVERRIDES_ATTRIBUTE.  */
++#undef TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
++#define TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT 3
++
++/* MS specific format attributes for ms_printf, ms_scanf, ms_strftime.  */
++#undef TARGET_FORMAT_TYPES
++#define TARGET_FORMAT_TYPES mingw_format_attributes
++
++#undef TARGET_N_FORMAT_TYPES
++#define TARGET_N_FORMAT_TYPES 3
++
+ /* JCR_SECTION works on mingw32.  */
+ #undef TARGET_USE_JCR_SECTION
+ #define TARGET_USE_JCR_SECTION 1
+diff -r ddadaee88373 gcc/config/i386/msformat-c.c
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/gcc/config/i386/msformat-c.c	Mon Jun 02 08:07:22 2008 -0600
+@@ -0,0 +1,175 @@
++/* Check calls to formatted I/O functions (-Wformat).
++   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
++   2001, 2002, 2003, 2004, 2005, 2007 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/>.  */
++
++#include "config.h"
++#include "system.h"
++#include "coretypes.h"
++#include "tm.h"
++#include "tree.h"
++#include "flags.h"
++#include "c-common.h"
++#include "toplev.h"
++#include "intl.h"
++#include "diagnostic.h"
++#include "langhooks.h"
++#include "c-format.h"
++#include "alloc-pool.h"
++
++/* Mingw specific format attributes ms_printf, ms_scanf, and ms_strftime.  */
++
++static const 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 },
++  { "I32", FMT_LEN_l, STD_EXT, NULL, 0, 0 },
++  { "I64", FMT_LEN_ll, STD_EXT, NULL, 0, 0 },
++  { "I", FMT_LEN_L, STD_EXT, NULL, 0, 0 },
++  { NULL, 0, 0, NULL, 0, 0 }
++};
++
++static const format_flag_spec ms_printf_flag_specs[] =
++{
++  { ' ',  0, 0, N_("' ' flag"),        N_("the ' ' printf flag"),              STD_C89 },
++  { '+',  0, 0, N_("'+' flag"),        N_("the '+' printf flag"),              STD_C89 },
++  { '#',  0, 0, N_("'#' flag"),        N_("the '#' printf flag"),              STD_C89 },
++  { '0',  0, 0, N_("'0' flag"),        N_("the '0' printf flag"),              STD_C89 },
++  { '-',  0, 0, N_("'-' flag"),        N_("the '-' printf flag"),              STD_C89 },
++  { '\'', 0, 0, N_("''' flag"),        N_("the ''' printf flag"),              STD_EXT },
++  { 'w',  0, 0, N_("field width"),     N_("field width in printf format"),     STD_C89 },
++  { 'p',  0, 0, N_("precision"),       N_("precision in printf format"),       STD_C89 },
++  { 'L',  0, 0, N_("length modifier"), N_("length modifier in printf format"), STD_C89 },
++  { 0, 0, 0, NULL, NULL, 0 }
++};
++
++static const format_flag_pair ms_printf_flag_pairs[] =
++{
++  { ' ', '+', 1, 0   },
++  { '0', '-', 1, 0   }, { '0', 'p', 1, 'i' },
++  { 0, 0, 0, 0 }
++};
++
++static const format_flag_spec ms_scanf_flag_specs[] =
++{
++  { '*',  0, 0, N_("assignment suppression"), N_("the assignment suppression scanf feature"), STD_C89 },
++  { 'a',  0, 0, N_("'a' flag"),               N_("the 'a' scanf flag"),                       STD_EXT },
++  { 'w',  0, 0, N_("field width"),            N_("field width in scanf format"),              STD_C89 },
++  { 'L',  0, 0, N_("length modifier"),        N_("length modifier in scanf format"),          STD_C89 },
++  { '\'', 0, 0, N_("''' flag"),               N_("the ''' scanf flag"),                       STD_EXT },
++  { 0, 0, 0, NULL, NULL, 0 }
++};
++
++static const format_flag_pair ms_scanf_flag_pairs[] =
++{
++  { '*', 'L', 0, 0 },
++  { 0, 0, 0, 0 }
++};
++
++static const format_flag_spec ms_strftime_flag_specs[] =
++{
++  { '#', 0,   0, N_("'#' flag"),     N_("the '#' strftime flag"),          STD_EXT },
++  { 0, 0, 0, NULL, NULL, 0 }
++};
++
++static const format_flag_pair ms_strftime_flag_pairs[] =
++{
++  { 0, 0, 0, 0 }
++};
++
++static const format_char_info ms_print_char_table[] =
++{
++  /* C89 conversion specifiers.  */
++  { "di",  0, STD_C89, { T89_I,   BADLEN,  T89_S,   T89_L,   T9L_LL,  T99_SST,  BADLEN, BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN  }, "-wp0 +'",  "i",  NULL },
++  { "oxX", 0, STD_C89, { T89_UI,  BADLEN,  T89_US,  T89_UL,  T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN,  BADLEN,  BADLEN }, "-wp0#",     "i",  NULL },
++  { "u",   0, STD_C89, { T89_UI,  BADLEN,  T89_US,  T89_UL,  T9L_ULL, T99_ST, BADLEN, BADLEN, BADLEN, BADLEN,  BADLEN,  BADLEN }, "-wp0'",    "i",  NULL },
++  { "fgG", 0, STD_C89, { T89_D,   BADLEN,  BADLEN,  T99_D,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN, BADLEN, BADLEN }, "-wp0 +#'", "",   NULL },
++  { "eE",  0, STD_C89, { T89_D,   BADLEN,  BADLEN,  T99_D,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN, BADLEN, BADLEN }, "-wp0 +#",  "",   NULL },
++  { "c",   0, STD_C89, { T89_I,   BADLEN,  T89_S,  T94_WI,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "-w",        "",   NULL },
++  { "s",   1, STD_C89, { T89_C,   BADLEN,  T89_S,  T94_W,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "-wp",       "cR", NULL },
++  { "p",   1, STD_C89, { T89_V,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "-w",        "c",  NULL },
++  { "n",   1, STD_C89, { T89_I,   BADLEN,  T89_S,   T89_L,   T9L_LL,  BADLEN,  BADLEN, BADLEN,  T99_IM,  BADLEN,  BADLEN,  BADLEN }, "",          "W",  NULL },
++  /* X/Open conversion specifiers.  */
++  { "C",   0, STD_EXT, { TEX_WI,  BADLEN,  T89_S,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "-w",        "",   NULL },
++  { "S",   1, STD_EXT, { TEX_W,   BADLEN,  T89_S,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "-wp",       "R",  NULL },
++  { NULL,  0, 0, NOLENGTHS, NULL, NULL, NULL }
++};
++
++static const format_char_info ms_scan_char_table[] =
++{
++  /* C89 conversion specifiers.  */
++  { "di",    1, STD_C89, { T89_I,   BADLEN,  T89_S,   T89_L,   T9L_LL,  T99_SST,  BADLEN, BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "*w'", "W",   NULL },
++  { "u",     1, STD_C89, { T89_UI,  BADLEN,  T89_US,  T89_UL,  T9L_ULL, T99_ST, BADLEN,  BADLEN, BADLEN, BADLEN,  BADLEN,  BADLEN }, "*w'", "W",   NULL },
++  { "oxX",   1, STD_C89, { T89_UI,  BADLEN,  T89_US,  T89_UL,  T9L_ULL, T99_ST, BADLEN,  BADLEN, BADLEN, BADLEN,  BADLEN,  BADLEN }, "*w",   "W",   NULL },
++  { "efgEG", 1, STD_C89, { T89_F,   BADLEN,  BADLEN,  T89_D,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN, BADLEN, BADLEN }, "*w'",  "W",   NULL },
++  { "c",     1, STD_C89, { T89_C,   BADLEN,  T89_S,  T94_W,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "*w",   "cW",  NULL },
++  { "s",     1, STD_C89, { T89_C,   BADLEN,  T89_S,  T94_W,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "*aw",  "cW",  NULL },
++  { "[",     1, STD_C89, { T89_C,   BADLEN,  BADLEN,  T94_W,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "*aw",  "cW[", NULL },
++  { "p",     2, STD_C89, { T89_V,   BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "*w",   "W",   NULL },
++  { "n",     1, STD_C89, { T89_I,   BADLEN,  T89_S,   T89_L,   T9L_LL,  BADLEN,  BADLEN, BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "",     "W",   NULL },
++  /* X/Open conversion specifiers.  */
++  { "C",     1, STD_EXT, { TEX_W,   BADLEN,  T89_S,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "*w",   "W",   NULL },
++  { "S",     1, STD_EXT, { TEX_W,   BADLEN,  T89_S,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN,  BADLEN }, "*aw",  "W",   NULL },
++  { NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL }
++};
++
++static const format_char_info ms_time_char_table[] =
++{
++  /* C89 conversion specifiers.  */
++  { "ABZab",		0, STD_C89, NOLENGTHS, "#",     "",   NULL },
++  { "cx",		0, STD_C89, NOLENGTHS, "#",      "3",  NULL },
++  { "HIMSUWdmw",	0, STD_C89, NOLENGTHS, "#",  "",   NULL },
++  { "j",		0, STD_C89, NOLENGTHS, "#",  "",  NULL },
++  { "p",		0, STD_C89, NOLENGTHS, "#",      "",   NULL },
++  { "X",		0, STD_C89, NOLENGTHS, "#",      "",   NULL },
++  { "y",		0, STD_C89, NOLENGTHS, "#", "4",  NULL },
++  { "Y",		0, STD_C89, NOLENGTHS, "#", "",  NULL },
++  { "%",		0, STD_C89, NOLENGTHS, "",       "",   NULL },
++  /* C99 conversion specifiers.  */
++  { "z",		0, STD_C99, NOLENGTHS, "#",      "",  NULL },
++  { NULL,		0, 0, NOLENGTHS, NULL, NULL, NULL }
++};
++
++const format_kind_info mingw_format_attributes[3] =
++{
++  { "ms_printf",   ms_printf_length_specs,  ms_print_char_table, " +#0-'", NULL,
++    ms_printf_flag_specs, ms_printf_flag_pairs,
++    FMT_FLAG_ARG_CONVERT|FMT_FLAG_DOLLAR_MULTIPLE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_EMPTY_PREC_OK,
++    'w', 0, 'p', 0, 'L', 0,
++    &integer_type_node, &integer_type_node
++  },
++  { "ms_scanf",    ms_printf_length_specs,   ms_scan_char_table,  "*'", NULL,
++    ms_scanf_flag_specs, ms_scanf_flag_pairs,
++    FMT_FLAG_ARG_CONVERT|FMT_FLAG_SCANF_A_KLUDGE|FMT_FLAG_USE_DOLLAR|FMT_FLAG_ZERO_WIDTH_BAD|FMT_FLAG_DOLLAR_GAP_POINTER_OK,
++    'w', 0, 0, '*', 'L', 0,
++    NULL, NULL
++  },
++  { "ms_strftime", NULL,                 ms_time_char_table,  "", "#",
++    ms_strftime_flag_specs, ms_strftime_flag_pairs,
++    FMT_FLAG_FANCY_PERCENT_OK, 0, 0, 0, 0, 0, 0,
++    NULL, NULL
++  }
++};
++
++/* Default overrides for printf, scanf and strftime.  */
++const target_ovr_attr mingw_format_attribute_overrides[4] =
++{
++  { "ms_printf", "printf" },
++  { "ms_scanf", "scanf" },
++  { "ms_strftime", "strftime" }
++};
+diff -r ddadaee88373 gcc/config/i386/t-cygming
+--- a/gcc/config/i386/t-cygming	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/config/i386/t-cygming	Mon Jun 02 08:07:22 2008 -0600
+@@ -29,4 +29,10 @@
+ 	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+ 	$(srcdir)/config/i386/winnt-stubs.c
+ 
++msformat-c.o: $(srcdir)/config/i386/msformat-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
++  $(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \
++  $(TM_P_H) toplev.h $(HASHTAB_H) $(GGC_H)
++	$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
++	$(srcdir)/config/i386/msformat-c.c
++
+ STMP_FIXINC=stmp-fixinc
+diff -r ddadaee88373 gcc/doc/extend.texi
+--- a/gcc/doc/extend.texi	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/doc/extend.texi	Mon Jun 02 08:07:22 2008 -0600
+@@ -2204,13 +2204,22 @@
+ @code{my_format}.
+ 
+ The parameter @var{archetype} determines how the format string is
+-interpreted, and should be @code{printf}, @code{scanf}, @code{strftime}
+-or @code{strfmon}.  (You can also use @code{__printf__},
+- at code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  The
+-parameter @var{string-index} specifies which argument is the format
+-string argument (starting from 1), while @var{first-to-check} is the
+-number of the first argument to check against the format string.  For
+-functions where the arguments are not available to be checked (such as
++interpreted, and should be @code{printf}, @code{scanf}, @code{strftime},
++ at code{gnu_printf}, @code{gnu_scanf}, @code{gnu_strftime} or
++ at code{strfmon}.  (You can also use @code{__printf__},
++ at code{__scanf__}, @code{__strftime__} or @code{__strfmon__}.)  On
++MinGW targets, @code{ms_printf}, @code{ms_scanf}, and
++ at code{ms_strftime} are also present.
++ at var{archtype} values such as @code{printf} refer to the formats accepted
++by the system's C run-time library, while @code{gnu_} values always refer
++to the formats accepted by the GNU C Library.  On Microsoft Windows
++targets, @code{ms_} values refer to the formats accepted by the
++ at file{msvcrt.dll} library.
++The parameter @var{string-index}
++specifies which argument is the format string argument (starting
++from 1), while @var{first-to-check} is the number of the first
++argument to check against the format string.  For functions
++where the arguments are not available to be checked (such as
+ @code{vprintf}), specify the third parameter as zero.  In this case the
+ compiler only checks the format string for consistency.  For
+ @code{strftime} formats, the third parameter is required to be zero.
+diff -r ddadaee88373 gcc/doc/tm.texi
+--- a/gcc/doc/tm.texi	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/doc/tm.texi	Mon Jun 02 08:07:22 2008 -0600
+@@ -10319,6 +10319,18 @@
+ @code{TARGET_FORMAT_TYPES}.
+ @end defmac
+ 
++ at defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES
++If defined, this macro is the name of a global variable containing
++target-specific format overrides for the @option{-Wformat} option. The
++default is to have no target-specific format overrides. If defined,
++ at code{TARGET_FORMAT_TYPES} must be defined, too.
++ at end defmac
++
++ at defmac TARGET_OVERRIDES_FORMAT_ATTRIBUTES_COUNT
++If defined, this macro specifies the number of entries in
++ at code{TARGET_OVERRIDES_FORMAT_ATTRIBUTES}.
++ at 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
+diff -r ddadaee88373 gcc/pretty-print.c
+--- a/gcc/pretty-print.c	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/pretty-print.c	Mon Jun 02 08:07:22 2008 -0600
+@@ -50,7 +50,7 @@
+         break;                                               \
+                                                              \
+       case 2:                                                \
+-        pp_scalar (PP, "%ll" F, va_arg (ARG, long long T));  \
++        pp_scalar (PP, "%" HOST_LONG_LONG_FORMAT F, va_arg (ARG, long long T));  \
+         break;                                               \
+                                                              \
+       default:                                               \
+diff -r ddadaee88373 gcc/testsuite/gcc.dg/format/attr-1.c
+--- a/gcc/testsuite/gcc.dg/format/attr-1.c	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/testsuite/gcc.dg/format/attr-1.c	Mon Jun 02 08:07:22 2008 -0600
+@@ -3,7 +3,8 @@
+ /* { dg-do compile } */
+ /* { dg-options "-std=gnu99 -Wformat" } */
+ 
++#define DONT_GNU_PROTOTYPE
+ #include "format.h"
+ 
+-extern void foo0 (const char *) __attribute__((__format__(__strftime__, 1, 0)));
+-extern void foo1 (const char *, ...) __attribute__((__format__(__strftime__, 1, 2))); /* { dg-error "cannot format" "strftime first_arg_num != 0" } */
++extern void foo0 (const char *) __attribute__((__format__(gnu_attr___strftime__, 1, 0)));
++extern void foo1 (const char *, ...) __attribute__((__format__(gnu_attr___strftime__, 1, 2))); /* { dg-error "cannot format" "strftime first_arg_num != 0" } */
+diff -r ddadaee88373 gcc/testsuite/gcc.dg/format/attr-2.c
+--- a/gcc/testsuite/gcc.dg/format/attr-2.c	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/testsuite/gcc.dg/format/attr-2.c	Mon Jun 02 08:07:22 2008 -0600
+@@ -3,22 +3,23 @@
+ /* { dg-do compile } */
+ /* { dg-options "-std=gnu99 -Wformat" } */
+ 
++#define DONT_GNU_PROTOTYPE
+ #include "format.h"
+ 
+-extern void tformatprintf (const char *, ...) __attribute__((format(printf, 1, 2)));
+-extern void tformat__printf__ (const char *, ...) __attribute__((format(__printf__, 1, 2)));
+-extern void tformatscanf (const char *, ...) __attribute__((format(scanf, 1, 2)));
+-extern void tformat__scanf__ (const char *, ...) __attribute__((format(__scanf__, 1, 2)));
+-extern void tformatstrftime (const char *) __attribute__((format(strftime, 1, 0)));
+-extern void tformat__strftime__ (const char *) __attribute__((format(__strftime__, 1, 0)));
++extern void tformatprintf (const char *, ...) __attribute__((format(gnu_attr_printf, 1, 2)));
++extern void tformat__printf__ (const char *, ...) __attribute__((format(gnu_attr___printf__, 1, 2)));
++extern void tformatscanf (const char *, ...) __attribute__((format(gnu_attr_scanf, 1, 2)));
++extern void tformat__scanf__ (const char *, ...) __attribute__((format(gnu_attr___scanf__, 1, 2)));
++extern void tformatstrftime (const char *) __attribute__((format(gnu_attr_strftime, 1, 0)));
++extern void tformat__strftime__ (const char *) __attribute__((format(gnu_attr___strftime__, 1, 0)));
+ extern void tformatstrfmon (const char *, ...) __attribute__((format(strfmon, 1, 2)));
+ extern void tformat__strfmon__ (const char *, ...) __attribute__((format(__strfmon__, 1, 2)));
+-extern void t__format__printf (const char *, ...) __attribute__((__format__(printf, 1, 2)));
+-extern void t__format____printf__ (const char *, ...) __attribute__((__format__(__printf__, 1, 2)));
+-extern void t__format__scanf (const char *, ...) __attribute__((__format__(scanf, 1, 2)));
+-extern void t__format____scanf__ (const char *, ...) __attribute__((__format__(__scanf__, 1, 2)));
+-extern void t__format__strftime (const char *) __attribute__((__format__(strftime, 1, 0)));
+-extern void t__format____strftime__ (const char *) __attribute__((__format__(__strftime__, 1, 0)));
++extern void t__format__printf (const char *, ...) __attribute__((__format__(gnu_attr_printf, 1, 2)));
++extern void t__format____printf__ (const char *, ...) __attribute__((__format__(gnu_attr___printf__, 1, 2)));
++extern void t__format__scanf (const char *, ...) __attribute__((__format__(gnu_attr_scanf, 1, 2)));
++extern void t__format____scanf__ (const char *, ...) __attribute__((__format__(gnu_attr___scanf__, 1, 2)));
++extern void t__format__strftime (const char *) __attribute__((__format__(gnu_attr_strftime, 1, 0)));
++extern void t__format____strftime__ (const char *) __attribute__((__format__(gnu_attr___strftime__, 1, 0)));
+ extern void t__format__strfmon (const char *, ...) __attribute__((__format__(strfmon, 1, 2)));
+ extern void t__format____strfmon__ (const char *, ...) __attribute__((__format__(__strfmon__, 1, 2)));
+ 
+diff -r ddadaee88373 gcc/testsuite/gcc.dg/format/attr-3.c
+--- a/gcc/testsuite/gcc.dg/format/attr-3.c	Thu May 29 20:27:38 2008 -0600
++++ b/gcc/testsuite/gcc.dg/format/attr-3.c	Mon Jun 02 08:07:22 2008 -0600
+@@ -3,20 +3,21 @@
+ /* { dg-do compile } */
+ /* { dg-options "-std=gnu99 -Wformat" } */
<<Diff was trimmed, longer than 597 lines>>


More information about the pld-cvs-commit mailing list