Module Name: src
Committed By: christos
Date: Wed Oct 14 16:05:15 UTC 2015
Modified Files:
src/external/gpl3/gcc.old/dist/gcc/c-family: c-format.c c-format.h
src/external/gpl3/gcc.old/dist/gcc/config: netbsd.h
src/external/gpl3/gcc/dist/gcc/c-family: c-format.c c-format.h
src/external/gpl3/gcc/dist/gcc/config: netbsd.h
Log Message:
Introduce a syslog format that accepts %m. Stop accepting %m in printf
like formats. Support for this is detected via the __syslog_attribute__
macro.
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c \
src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h
cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/gcc.old/dist/gcc/config/netbsd.h
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/external/gpl3/gcc/dist/gcc/c-family/c-format.c \
src/external/gpl3/gcc/dist/gcc/c-family/c-format.h
cvs rdiff -u -r1.14 -r1.15 src/external/gpl3/gcc/dist/gcc/config/netbsd.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c
diff -u src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c:1.1.1.1 src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c:1.2
--- src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c:1.1.1.1 Tue Sep 22 23:03:26 2015
+++ src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.c Wed Oct 14 12:05:14 2015
@@ -860,14 +860,20 @@ static const format_kind_info format_typ
},
{ "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,
+ FMT_FLAG_FANCY_PERCENT_OK|FMT_FLAG_M_OK, 'w', 0, 0, 0, 0, 0,
NULL, 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
- }
+ },
+ { "gnu_syslog", 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|FMT_FLAG_M_OK,
+ 'w', 0, 'p', 0, 'L', 0,
+ &integer_type_node, &integer_type_node
+ },
};
/* This layer of indirection allows GCC to reassign format_types with
@@ -1983,6 +1989,14 @@ check_format_info_main (format_check_res
warning (OPT_Wformat_, "conversion lacks type at end of format");
continue;
}
+
+ if (format_char == 'm' && !(fki->flags & FMT_FLAG_M_OK))
+ {
+ warning (OPT_Wformat_,
+ "%%m is only allowed in syslog(3) like functions");
+ continue;
+ }
+
format_chars++;
fci = fki->conversion_specs;
while (fci->format_chars != 0
@@ -2854,6 +2868,7 @@ extern const target_ovr_attr TARGET_OVER
static const target_ovr_attr gnu_target_overrides_format_attributes[] =
{
{ "gnu_printf", "printf" },
+ { "gnu_syslog", "syslog" },
{ "gnu_scanf", "scanf" },
{ "gnu_strftime", "strftime" },
{ "gnu_strfmon", "strfmon" },
Index: src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h
diff -u src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h:1.1.1.1 src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h:1.2
--- src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h:1.1.1.1 Tue Sep 22 23:03:26 2015
+++ src/external/gpl3/gcc.old/dist/gcc/c-family/c-format.h Wed Oct 14 12:05:14 2015
@@ -75,11 +75,13 @@ enum
FMT_FLAG_DOLLAR_GAP_POINTER_OK = 128,
/* The format arg is an opaque object that will be parsed by an external
facility. */
- FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256
+ FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256,
/* Not included here: details of whether width or precision may occur
(controlled by width_char and precision_char); details of whether
'*' can be used for these (width_type and precision_type); details
of whether length modifiers can occur (length_char_specs). */
+ FMT_FLAG_M_OK = 512
+ /* %m is only allowed in syslog */
};
/* Structure describing a length modifier supported in format checking, and
Index: src/external/gpl3/gcc.old/dist/gcc/config/netbsd.h
diff -u src/external/gpl3/gcc.old/dist/gcc/config/netbsd.h:1.3 src/external/gpl3/gcc.old/dist/gcc/config/netbsd.h:1.4
--- src/external/gpl3/gcc.old/dist/gcc/config/netbsd.h:1.3 Tue Sep 22 23:39:12 2015
+++ src/external/gpl3/gcc.old/dist/gcc/config/netbsd.h Wed Oct 14 12:05:15 2015
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.
{ \
builtin_define ("__NetBSD__"); \
builtin_define ("__unix__"); \
+ builtin_define ("__syslog_attribute__"); \
builtin_assert ("system=bsd"); \
builtin_assert ("system=unix"); \
builtin_assert ("system=NetBSD"); \
Index: src/external/gpl3/gcc/dist/gcc/c-family/c-format.c
diff -u src/external/gpl3/gcc/dist/gcc/c-family/c-format.c:1.1.1.1 src/external/gpl3/gcc/dist/gcc/c-family/c-format.c:1.2
--- src/external/gpl3/gcc/dist/gcc/c-family/c-format.c:1.1.1.1 Sat Mar 1 03:43:01 2014
+++ src/external/gpl3/gcc/dist/gcc/c-family/c-format.c Wed Oct 14 12:05:14 2015
@@ -860,14 +860,20 @@ static const format_kind_info format_typ
},
{ "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,
+ FMT_FLAG_FANCY_PERCENT_OK|FMT_FLAG_M_OK, 'w', 0, 0, 0, 0, 0,
NULL, 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
- }
+ },
+ { "gnu_syslog", 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|FMT_FLAG_M_OK,
+ 'w', 0, 'p', 0, 'L', 0,
+ &integer_type_node, &integer_type_node
+ },
};
/* This layer of indirection allows GCC to reassign format_types with
@@ -1983,6 +1989,14 @@ check_format_info_main (format_check_res
warning (OPT_Wformat_, "conversion lacks type at end of format");
continue;
}
+
+ if (format_char == 'm' && !(fki->flags & FMT_FLAG_M_OK))
+ {
+ warning (OPT_Wformat_,
+ "%%m is only allowed in syslog(3) like functions");
+ continue;
+ }
+
format_chars++;
fci = fki->conversion_specs;
while (fci->format_chars != 0
@@ -2854,6 +2868,7 @@ extern const target_ovr_attr TARGET_OVER
static const target_ovr_attr gnu_target_overrides_format_attributes[] =
{
{ "gnu_printf", "printf" },
+ { "gnu_syslog", "syslog" },
{ "gnu_scanf", "scanf" },
{ "gnu_strftime", "strftime" },
{ "gnu_strfmon", "strfmon" },
Index: src/external/gpl3/gcc/dist/gcc/c-family/c-format.h
diff -u src/external/gpl3/gcc/dist/gcc/c-family/c-format.h:1.1.1.1 src/external/gpl3/gcc/dist/gcc/c-family/c-format.h:1.2
--- src/external/gpl3/gcc/dist/gcc/c-family/c-format.h:1.1.1.1 Sat Mar 1 03:43:01 2014
+++ src/external/gpl3/gcc/dist/gcc/c-family/c-format.h Wed Oct 14 12:05:14 2015
@@ -75,11 +75,13 @@ enum
FMT_FLAG_DOLLAR_GAP_POINTER_OK = 128,
/* The format arg is an opaque object that will be parsed by an external
facility. */
- FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256
+ FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL = 256,
/* Not included here: details of whether width or precision may occur
(controlled by width_char and precision_char); details of whether
'*' can be used for these (width_type and precision_type); details
of whether length modifiers can occur (length_char_specs). */
+ FMT_FLAG_M_OK = 512
+ /* %m is only allowed in syslog */
};
/* Structure describing a length modifier supported in format checking, and
Index: src/external/gpl3/gcc/dist/gcc/config/netbsd.h
diff -u src/external/gpl3/gcc/dist/gcc/config/netbsd.h:1.14 src/external/gpl3/gcc/dist/gcc/config/netbsd.h:1.15
--- src/external/gpl3/gcc/dist/gcc/config/netbsd.h:1.14 Wed Oct 22 19:17:24 2014
+++ src/external/gpl3/gcc/dist/gcc/config/netbsd.h Wed Oct 14 12:05:15 2015
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.
{ \
builtin_define ("__NetBSD__"); \
builtin_define ("__unix__"); \
+ builtin_define ("__syslog_attribute__"); \
builtin_assert ("system=bsd"); \
builtin_assert ("system=unix"); \
builtin_assert ("system=NetBSD"); \