Commit 631238ac by Martin Sebor Committed by Martin Sebor

PR translation/80280 - Missing closing quote (%>) c/semantics.c and c/c-typeck.c

gcc/c-family/ChangeLog:

	PR translation/80280
	* c-format.h (struct format_flag_spec): Add new member.
	(T89_T): New macro.
	* c-format.c (local_tree_type_node): New global.
	(printf_flag_specs, asm_fprintf_flag_spec): Initialize new data.
	(gcc_diag_flag_specs, scanf_flag_specs, strftime_flag_specs): Ditto.
	(strfmon_flag_specs): Likewise.
	(gcc_diag_char_table, gcc_cdiag_char_table): Split up specifiers
	with distinct quoting properties.
	(gcc_tdiag_char_table, gcc_cxxdiag_char_table): Same.
	(flag_chars_t::validate): Add argument and handle bad quoting.
	(check_format_info_main): Handle quoting problems.
	(init_dynamic_diag_info): Simplify.

gcc/testsuite/ChangeLog:

	PR translation/80280
	* gcc.dg/format/gcc_diag-10.c: New test.

From-SVN: r247778
parent 6ba86ba7
2017-05-08 Martin Sebor <msebor@redhat.com>
PR translation/80280
* c-format.h (struct format_flag_spec): Add new member.
(T89_T): New macro.
* c-format.c (local_tree_type_node): New global.
(printf_flag_specs, asm_fprintf_flag_spec): Initialize new data.
(gcc_diag_flag_specs, scanf_flag_specs, strftime_flag_specs): Ditto.
(strfmon_flag_specs): Likewise.
(gcc_diag_char_table, gcc_cdiag_char_table): Split up specifiers
with distinct quoting properties.
(gcc_tdiag_char_table, gcc_cxxdiag_char_table): Same.
(flag_chars_t::validate): Add argument and handle bad quoting.
(check_format_info_main): Handle quoting problems.
(init_dynamic_diag_info): Simplify.
2017-05-08 Jason Merrill <jason@redhat.com>
* c-opts.c (c_common_post_options): Update defaults for
......
......@@ -151,7 +151,16 @@ struct format_char_info
"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
precision, and "[" for the starting character of a scanf scanset. */
precision, and "[" for the starting character of a scanf scanset,
"<" if the specifier introduces a quoted sequence (such as "%<"),
">" if the specifier terminates a quoted sequence (such as "%>"),
"[" if the specifier introduces a color sequence (such as "%r"),
"]" if the specifier terminates a color sequence (such as "%R"),
"'" (single quote) if the specifier is expected to be quoted when
it appears outside a quoted sequence and unquoted otherwise (such
as the GCC internal printf format directive "%T"), and
"\"" (double quote) if the specifier is not expected to appear in
a quoted sequence (such as the GCC internal format directive "%K". */
const char *flags2;
/* If this format conversion character consumes more than one argument,
CHAIN points to information about the next argument. For later
......@@ -178,6 +187,8 @@ struct format_flag_spec
/* Nonzero if the next character after this flag in the format should
be skipped ('=' in strfmon), zero otherwise. */
int skip_next_char;
/* True if the flag introduces quoting (as in GCC's %qE). */
bool quoting;
/* The name to use for this flag in diagnostic messages. For example,
N_("'0' flag"), N_("field width"). */
const char *name;
......@@ -287,6 +298,7 @@ struct format_kind_info
#define T_UC &unsigned_char_type_node
#define T99_UC { STD_C99, NULL, T_UC }
#define T_V &void_type_node
#define T89_T { STD_C89, NULL, &local_tree_type_node }
#define T89_V { STD_C89, NULL, T_V }
#define T_W &wchar_type_node
#define T94_W { STD_C94, "wchar_t", T_W }
......
2017-05-08 Martin Sebor <msebor@redhat.com>
PR translation/80280
* gcc.dg/format/gcc_diag-10.c: New test.
2017-05-08 Kelvin Nilsen <kelvin@gcc.gnu.org>
PR target/80101
......
/* Test for GCC internal format directives.
{ dg-do compile }
{ dg-options "-std=gnu99 -Wformat" } */
/* Magic identifiers must be set before the attribute is used. */
typedef long long __gcc_host_wide_int__;
typedef struct location_s
{
const char *file;
int line;
} location_t;
union tree_node;
typedef union tree_node *tree;
#define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2)))
void diag (const char*, ...) FORMAT (diag);
void cdiag (const char*, ...) FORMAT (cdiag);
void tdiag (const char*, ...) FORMAT (tdiag);
void cxxdiag (const char*, ...) FORMAT (cxxdiag);
void test_diag (tree t)
{
diag ("%<"); /* { dg-warning "unterminated quoting directive" } */
diag ("%>"); /* { dg-warning "unmatched quoting directive " } */
diag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
diag ("%K", t);
diag ("%R"); /* { dg-warning "unmatched color reset directive" } */
diag ("%r", ""); /* { dg-warning "unterminated color directive" } */
diag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
diag ("%r%R", "");
diag ("%r%r%R", "", "");
diag ("%r%R%r%R", "", "");
diag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */
diag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
diag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
diag ("%<%r%R%>", "");
}
void test_cdiag (tree t)
{
cdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
cdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
cdiag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
cdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
cdiag ("%E", t);
cdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */
cdiag ("%K", t);
cdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
cdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
cdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
cdiag ("%r%R", "");
cdiag ("%r%r%R", "", "");
cdiag ("%r%R%r%R", "", "");
cdiag ("%T", t); /* { dg-warning ".T. conversion used unquoted" } */
cdiag ("%V", t); /* { dg-warning ".V. conversion used unquoted" } */
cdiag ("%<%D%>", t);
cdiag ("%<%E%>", t);
cdiag ("%<%F%>", t);
cdiag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */
cdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
cdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
cdiag ("%<%r%R%>", "");
cdiag ("%<%T%>", t);
cdiag ("%<%V%>", t);
cdiag ("%<%qD%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
cdiag ("%<%qE%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
cdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
}
void test_tdiag (tree t)
{
tdiag ("%<"); /* { dg-warning "unterminated quoting directive" } */
tdiag ("%>"); /* { dg-warning "unmatched quoting directive " } */
tdiag ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
tdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
tdiag ("%E", t);
tdiag ("%K", t);
tdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
tdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
tdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
tdiag ("%r%R", "");
tdiag ("%r%R", "");
tdiag ("%r%r%R", "", "");
tdiag ("%r%R%r%R", "", "");
tdiag ("%T", t); /* { dg-warning ".T. conversion used unquoted" } */
tdiag ("%<%D%>", t);
tdiag ("%<%E%>", t);
tdiag ("%<%K%>", t); /* { dg-warning ".K. conversion used within a quoted sequence" } */
tdiag ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
tdiag ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
tdiag ("%<%r%R%>", "");
tdiag ("%<%T%>", t);
tdiag ("%<%qD%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
tdiag ("%<%qE%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
tdiag ("%<%qT%>", t); /* { dg-warning ".q. flag used within a quoted sequence" } */
}
void test_cxxdiag (tree t)
{
cxxdiag ("%A", t); /* { dg-warning ".A. conversion used unquoted" } */
cxxdiag ("%D", t); /* { dg-warning ".D. conversion used unquoted" } */
cxxdiag ("%E", t);
cxxdiag ("%F", t); /* { dg-warning ".F. conversion used unquoted" } */
cxxdiag ("%R"); /* { dg-warning "unmatched color reset directive" } */
cxxdiag ("%r", ""); /* { dg-warning "unterminated color directive" } */
cxxdiag ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
cxxdiag ("%r%R", "");
cxxdiag ("%r%R", "");
cxxdiag ("%r%r%R", "", "");
cxxdiag ("%r%R%r%R", "", "");
cxxdiag ("%S", t); /* { dg-warning ".S. conversion used unquoted" } */
cxxdiag ("%T", t); /* { dg-warning ".T. conversion used unquoted" } */
cxxdiag ("%V", t); /* { dg-warning ".V. conversion used unquoted" } */
cxxdiag ("%X", t); /* { dg-warning ".X. conversion used unquoted" } */
cxxdiag ("%<%A%>", t);
cxxdiag ("%<%D%>", t);
cxxdiag ("%<%E%>", t);
cxxdiag ("%<%F%>", t);
cxxdiag ("%<%R%>"); /* { dg-warning "unmatched color reset" } */
cxxdiag ("%<%r%R%>", "");
cxxdiag ("%<%S%>", t);
cxxdiag ("%<%T%>", t);
cxxdiag ("%<%V%>", t);
cxxdiag ("%<%X%>", t);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment