This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
strftime format checking patch
- To: gcc-patches at gcc dot gnu dot org
- Subject: strftime format checking patch
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Fri, 4 Aug 2000 23:03:36 +0100 (BST)
This patch adds details of which strftime formats were added in C99 to
the format checking information, adds appropriate -pedantic warnings
outside of C99 mode, adds the missing C99 %F format (ISO 8601 date
%Y-%m-%d), and makes some other corrections to the strftime format
checking data.
Bootstrapped with no regressions on i686-pc-linux-gnu. OK to commit?
2000-08-04 Joseph S. Myers <jsm28@cam.ac.uk>
* c-common.c (time_char_table): Mark up formats added in C99 and
make other corrections. %D and %g were added in C99. %Og is an
extension. %EX is permitted. %R, %T, %n, %r, %t were added in
C99. %e was added in C99. %Oj is an extension. %G and %z are in
C99 rather than GNU extensions, but %OG and %Oz are extensions.
%h was added in C99. %C was added in C99. %OY and %OC are
extensions. Add the C99 format %F.
(check_format_info): If pedantic and not in C99 mode, warn for C99
formats, %E and %O.
--- c-common.c Fri Aug 4 16:02:03 2000
+++ c-common.c.new Fri Aug 4 18:45:22 2000
@@ -1268,22 +1268,31 @@
'E' - E modifier is acceptable
'O' - O modifier is acceptable to Standard C
'o' - O modifier is acceptable as a GNU extension
+ '9' - added to the C standard in C99
'G' - other GNU extensions */
static format_char_info time_char_table[] = {
{ "y", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "2EO-_0w" },
- { "D", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "2" },
- { "g", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "2O-_0w" },
+ { "D", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "29" },
+ { "g", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "2Oo-_0w9" },
{ "cx", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "3E" },
- { "%RTXnrt", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "" },
+ { "%", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "" },
+ { "X", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "E" },
+ { "RTnrt", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "9" },
{ "P", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "G" },
- { "HIMSUWdemw", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Ow" },
- { "Vju", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Oow" },
- { "Gklsz", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0OGw" },
+ { "HIMSUWdmw", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Ow" },
+ { "e", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Ow9" },
+ { "j", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Oow" },
+ { "Vu", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Ow9" },
+ { "Gz", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Oow9" },
+ { "kls", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0OGw" },
{ "ABZa", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "^#" },
{ "p", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "#" },
- { "bh", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "^" },
- { "CY", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0EOw" },
+ { "b", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "^" },
+ { "h", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "^9" },
+ { "Y", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0EOow" },
+ { "F", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "w9" },
+ { "C", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0EOow9" },
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
@@ -1900,9 +1909,14 @@
{
if (index (fci->flag_chars, 'G') != 0)
warning ("ANSI C does not support `%%%c'", format_char);
- if (index (fci->flag_chars, 'o') != 0
+ if (index (fci->flag_chars, '9') != 0 && !flag_isoc99)
+ warning ("ANSI C does not support `%%%c'", format_char);
+ if ((index (fci->flag_chars, 'o') != 0
+ || (!flag_isoc99 && index (fci->flag_chars, 'O') != 0))
&& index (flag_chars, 'O') != 0)
warning ("ANSI C does not support `%%O%c'", format_char);
+ if (!flag_isoc99 && index (flag_chars, 'E'))
+ warning ("ANSI C does not support `%%E%c'", format_char);
}
if (wide && index (fci->flag_chars, 'w') == 0)
warning ("width used with `%c' format", format_char);
--
Joseph S. Myers
jsm28@cam.ac.uk