Commit 05cf561d by Steven Bosscher Committed by Steven Bosscher

re PR c++/17412 (tree check failure in fold-const)

	PR c++/17412
	* fold-const.c (fold): Do not try to fold the operand of a
	CLEANUP_POINT_EXPR if that operand does itself not have any
	operands.
testsuite/
	* g++.dg/parse/break-in-for.C: New test.

	PR middle-end/17417
	* langhooks.c (lhd_decl_printable_name): Make sure that this
	function is called with is a decl node that has an identifier.
	* tree-pretty-print.c (dump_function_name): New function to
	wrap PRINT_FUNCTION_NAME and dump_decl_name.
	(print_call_name): Use it.

From-SVN: r87363
parent a0be84dd
2004-09-11 Steven Bosscher <stevenb@suse.de>
PR c++/17412
* fold-const.c (fold): Do not try to fold the operand of a
CLEANUP_POINT_EXPR if that operand does itself not have any
operands.
PR middle-end/17417
* langhooks.c (lhd_decl_printable_name): Make sure that this
function is called with is a decl node that has an identifier.
* tree-pretty-print.c (dump_function_name): New function to
wrap PRINT_FUNCTION_NAME and dump_decl_name.
(print_call_name): Use it.
2004-09-11 Mohan Embar <gnustuff@thisiscool.com> 2004-09-11 Mohan Embar <gnustuff@thisiscool.com>
* ggc-none.c: Include "bconfig.h" if -DGENERATOR_FILE, * ggc-none.c: Include "bconfig.h" if -DGENERATOR_FILE,
......
...@@ -8946,29 +8946,31 @@ fold (tree expr) ...@@ -8946,29 +8946,31 @@ fold (tree expr)
TREE_OPERAND (arg0, 1))))); TREE_OPERAND (arg0, 1)))));
return t; return t;
case CLEANUP_POINT_EXPR:
/* Pull arithmetic ops out of the CLEANUP_POINT_EXPR where /* Pull arithmetic ops out of the CLEANUP_POINT_EXPR where
appropriate. */ appropriate. */
case CLEANUP_POINT_EXPR:
if (! has_cleanups (arg0)) if (! has_cleanups (arg0))
return TREE_OPERAND (t, 0); return TREE_OPERAND (t, 0);
{ {
enum tree_code code0 = TREE_CODE (arg0); enum tree_code code0 = TREE_CODE (arg0);
int kind0 = TREE_CODE_CLASS (code0); int kind0 = TREE_CODE_CLASS (code0);
tree arg00 = TREE_OPERAND (arg0, 0);
tree arg01;
if (kind0 == '1' || code0 == TRUTH_NOT_EXPR) if (kind0 == '1' || code0 == TRUTH_NOT_EXPR)
return fold (build1 (code0, type, {
fold (build1 (CLEANUP_POINT_EXPR, tree arg00 = TREE_OPERAND (arg0, 0);
TREE_TYPE (arg00), arg00)))); return fold (build1 (code0, type,
fold (build1 (CLEANUP_POINT_EXPR,
TREE_TYPE (arg00), arg00))));
}
if (kind0 == '<' || kind0 == '2' if (kind0 == '<' || kind0 == '2'
|| code0 == TRUTH_ANDIF_EXPR || code0 == TRUTH_ORIF_EXPR || code0 == TRUTH_ANDIF_EXPR || code0 == TRUTH_ORIF_EXPR
|| code0 == TRUTH_AND_EXPR || code0 == TRUTH_OR_EXPR || code0 == TRUTH_AND_EXPR || code0 == TRUTH_OR_EXPR
|| code0 == TRUTH_XOR_EXPR) || code0 == TRUTH_XOR_EXPR)
{ {
arg01 = TREE_OPERAND (arg0, 1); tree arg00 = TREE_OPERAND (arg0, 0);
tree arg01 = TREE_OPERAND (arg0, 1);
if (TREE_CONSTANT (arg00) if (TREE_CONSTANT (arg00)
|| ((code0 == TRUTH_ANDIF_EXPR || code0 == TRUTH_ORIF_EXPR) || ((code0 == TRUTH_ANDIF_EXPR || code0 == TRUTH_ORIF_EXPR)
......
...@@ -267,6 +267,7 @@ lhd_expand_decl (tree ARG_UNUSED (t)) ...@@ -267,6 +267,7 @@ lhd_expand_decl (tree ARG_UNUSED (t))
const char * const char *
lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity)) lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity))
{ {
gcc_assert (decl && DECL_NAME (decl));
return IDENTIFIER_POINTER (DECL_NAME (decl)); return IDENTIFIER_POINTER (DECL_NAME (decl));
} }
......
2004-09-11 Steven Bosscher <stevenb@suse.de>
* g++.dg/parse/break-in-for.C: New test.
2004-09-11 Jakub Jelinek <jakub@redhat.com> 2004-09-11 Jakub Jelinek <jakub@redhat.com>
* gcc.dg/tree-ssa/20040911-1.c: New test. * gcc.dg/tree-ssa/20040911-1.c: New test.
......
/* PR17412
fold-const would try to fold the operands of the break statement. */
/* { dg-do compile } */
void foo ()
{
for (;;)
for (;;({break;}));
}
...@@ -172,6 +172,17 @@ dump_decl_name (pretty_printer *buffer, tree node, int flags) ...@@ -172,6 +172,17 @@ dump_decl_name (pretty_printer *buffer, tree node, int flags)
} }
} }
/* Like the above, but used for pretty printing function calls. */
static void
dump_function_name (pretty_printer *buffer, tree node)
{
if (DECL_NAME (node))
PRINT_FUNCTION_NAME (node);
else
dump_decl_name (buffer, node, 0);
}
/* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
FLAGS are as in dump_generic_node. */ FLAGS are as in dump_generic_node. */
...@@ -1892,7 +1903,7 @@ print_call_name (pretty_printer *buffer, tree node) ...@@ -1892,7 +1903,7 @@ print_call_name (pretty_printer *buffer, tree node)
{ {
case VAR_DECL: case VAR_DECL:
case PARM_DECL: case PARM_DECL:
PRINT_FUNCTION_NAME (op0); dump_function_name (buffer, op0);
break; break;
case ADDR_EXPR: case ADDR_EXPR:
...@@ -1914,7 +1925,7 @@ print_call_name (pretty_printer *buffer, tree node) ...@@ -1914,7 +1925,7 @@ print_call_name (pretty_printer *buffer, tree node)
/* The function is a pointer contained in a structure. */ /* The function is a pointer contained in a structure. */
if (TREE_CODE (TREE_OPERAND (op0, 0)) == INDIRECT_REF || if (TREE_CODE (TREE_OPERAND (op0, 0)) == INDIRECT_REF ||
TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL) TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
PRINT_FUNCTION_NAME (TREE_OPERAND (op0, 1)); dump_function_name (buffer, TREE_OPERAND (op0, 1));
else else
dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, 0, false); dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, 0, false);
/* else /* else
...@@ -1925,7 +1936,7 @@ print_call_name (pretty_printer *buffer, tree node) ...@@ -1925,7 +1936,7 @@ print_call_name (pretty_printer *buffer, tree node)
case ARRAY_REF: case ARRAY_REF:
if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL) if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
PRINT_FUNCTION_NAME (TREE_OPERAND (op0, 0)); dump_function_name (buffer, TREE_OPERAND (op0, 0));
else else
dump_generic_node (buffer, op0, 0, 0, false); dump_generic_node (buffer, op0, 0, 0, false);
break; break;
......
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