/* The C standard version we are checking formats against when pedantic. */
#define C_STD_VER ((int) (c_dialect_cxx () \
? CPLUSPLUS_STD_VER \
- : (flag_isoc99 \
- ? STD_C99 \
- : (flag_isoc94 ? STD_C94 : STD_C89))))
+ : (flag_isoc2x \
+ ? STD_C2X \
+ : (flag_isoc99 \
+ ? STD_C99 \
+ : (flag_isoc94 ? STD_C94 : STD_C89)))))
/* The name to give to the standard version we are warning about when
pedantic. FEATURE_VER is the version in which the feature warned out
appeared, which is higher than C_STD_VER. */
: "ISO C++11") \
: ((FEATURE_VER) == STD_EXT \
? "ISO C" \
- : "ISO C90"))
+ : ((FEATURE_VER) == STD_C2X \
+ ? "ISO C17" \
+ : "ISO C90")))
/* Adjust a C standard version, which may be STD_C9L, to account for
-Wno-long-long. Returns other standard versions unchanged. */
#define ADJ_STD(VER) ((int) ((VER) == STD_C9L \
{ 'E', 0, 0, 0, N_("'E' modifier"), N_("the 'E' strftime modifier"), STD_C99 },
{ 'O', 0, 0, 0, N_("'O' modifier"), N_("the 'O' strftime modifier"), STD_C99 },
{ 'O', 'o', 0, 0, NULL, N_("the 'O' modifier"), STD_EXT },
+ { 'O', 'p', 0, 0, NULL, N_("the 'O' modifier"), STD_C2X },
{ 0, 0, 0, 0, NULL, NULL, STD_C89 }
};
static const format_char_info time_char_table[] =
{
/* C89 conversion specifiers. */
- { "ABZab", 0, STD_C89, NOLENGTHS, "^#", "", NULL },
+ { "AZa", 0, STD_C89, NOLENGTHS, "^#", "", NULL },
+ { "Bb", 0, STD_C89, NOLENGTHS, "O^#", "p", NULL },
{ "cx", 0, STD_C89, NOLENGTHS, "E", "3", NULL },
{ "HIMSUWdmw", 0, STD_C89, NOLENGTHS, "-_0Ow", "", NULL },
{ "j", 0, STD_C89, NOLENGTHS, "-_0Ow", "o", NULL },
STD_C94,
STD_C9L, /* C99, but treat as C89 if -Wno-long-long. */
STD_C99,
+ STD_C2X,
STD_EXT
};
two digit year formats, "3" for strftime formats giving two digit
years in some locales, "4" for "2" which becomes "3" with an "E" modifier,
"o" if use of strftime "O" is a GNU extension beyond C99,
+ "p" if use of strftime "O" is a C2x feature,
"W" if the argument is a pointer which is dereferenced and written into,
"R" if the argument is a pointer which is dereferenced and read from,
"i" for printf integer formats where the '0' flag is ignored with
--- /dev/null
+/* Test for strftime formats. Formats using C2x features. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic -Wformat" } */
+
+#include "format.h"
+
+void
+foo (char *s, size_t m, const struct tm *tp)
+{
+ strftime (s, m, "%Ob", tp);
+ strftime (s, m, "%OB", tp);
+ /* It's not clear that %h equivalence to %b means %Oh is equivalent
+ to %Ob; here we expect %Oh to be diagnosed. */
+ strftime (s, m, "%Oh", tp); /* { dg-warning "flag|modifier" "bad %Oh" } */
+}