Commit 84628aa8 by Jakub Jelinek Committed by Jakub Jelinek

re PR c/46015 (-Wunused-but-set-variable warns for arrays used in gotos)

	PR c/46015
	* c-parser.c (c_parser_statement_after_labels): Call mark_exp_read
	on computed goto argument.

	* semantics.c (finish_goto_stmt): Call mark_rvalue_use on computed
	goto destination.

	* c-c++-common/Wunused-var-13.c: New test.

From-SVN: r165643
parent 0f8d6231
2010-10-18 Jakub Jelinek <jakub@redhat.com>
PR c/46015
* c-parser.c (c_parser_statement_after_labels): Call mark_exp_read
on computed goto argument.
2010-10-18 Richard Guenther <rguenther@suse.de> 2010-10-18 Richard Guenther <rguenther@suse.de>
PR tree-optimization/45967 PR tree-optimization/45967
...@@ -4151,9 +4151,12 @@ c_parser_statement_after_labels (c_parser *parser) ...@@ -4151,9 +4151,12 @@ c_parser_statement_after_labels (c_parser *parser)
} }
else if (c_parser_next_token_is (parser, CPP_MULT)) else if (c_parser_next_token_is (parser, CPP_MULT))
{ {
tree val;
c_parser_consume_token (parser); c_parser_consume_token (parser);
stmt = c_finish_goto_ptr (loc, val = c_parser_expression (parser).value;
c_parser_expression (parser).value); mark_exp_read (val);
stmt = c_finish_goto_ptr (loc, val);
} }
else else
c_parser_error (parser, "expected identifier or %<*%>"); c_parser_error (parser, "expected identifier or %<*%>");
......
2010-10-18 Jakub Jelinek <jakub@redhat.com>
PR c/46015
* semantics.c (finish_goto_stmt): Call mark_rvalue_use on computed
goto destination.
2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com> 2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from apple/trunk branch on FSF servers. Merge from apple/trunk branch on FSF servers.
......
...@@ -537,6 +537,7 @@ finish_goto_stmt (tree destination) ...@@ -537,6 +537,7 @@ finish_goto_stmt (tree destination)
TREE_USED (destination) = 1; TREE_USED (destination) = 1;
else else
{ {
destination = mark_rvalue_use (destination);
if (!processing_template_decl) if (!processing_template_decl)
{ {
destination = cp_convert (ptr_type_node, destination); destination = cp_convert (ptr_type_node, destination);
......
2010-10-18 Jakub Jelinek <jakub@redhat.com>
PR c/46015
* c-c++-common/Wunused-var-13.c: New test.
2010-10-18 Richard Guenther <rguenther@suse.de> 2010-10-18 Richard Guenther <rguenther@suse.de>
PR tree-optimization/45967 PR tree-optimization/45967
......
/* PR c/46015 */
/* { dg-options "-Wunused" } */
/* { dg-do compile } */
int
f1 (int i)
{
static void *labs[2] = { &&lab1, &&lab2 };
goto *(labs[i & 1]);
lab1:
return 1;
lab2:
return 2;
}
int
f2 (int i)
{
void *labs[2] = { &&lab1, &&lab2 };
goto *labs[i & 1];
lab1:
return 1;
lab2:
return 2;
}
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