aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSteven Bosscher <stevenb@suse.de>2004-09-11 19:48:58 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2004-09-11 19:48:58 +0000
commit05cf561db41aa56f53e0c77b4489987f25fe2efa (patch)
treebb1962bfc50766eb7a19c562763e5c166da579bc /gcc
parenta0be84dd8c0a461050ab96d8c563c9e9482e0107 (diff)
downloadgcc-05cf561db41aa56f53e0c77b4489987f25fe2efa.zip
gcc-05cf561db41aa56f53e0c77b4489987f25fe2efa.tar.gz
gcc-05cf561db41aa56f53e0c77b4489987f25fe2efa.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/fold-const.c16
-rw-r--r--gcc/langhooks.c1
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/parse/break-in-for.C11
-rw-r--r--gcc/tree-pretty-print.c17
6 files changed, 53 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d584ea6..c469e27 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+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>
* ggc-none.c: Include "bconfig.h" if -DGENERATOR_FILE,
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index d0720e9..31bf7fd 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8946,29 +8946,31 @@ fold (tree expr)
TREE_OPERAND (arg0, 1)))));
return t;
+ case CLEANUP_POINT_EXPR:
/* Pull arithmetic ops out of the CLEANUP_POINT_EXPR where
appropriate. */
- case CLEANUP_POINT_EXPR:
if (! has_cleanups (arg0))
return TREE_OPERAND (t, 0);
{
enum tree_code code0 = TREE_CODE (arg0);
int kind0 = TREE_CODE_CLASS (code0);
- tree arg00 = TREE_OPERAND (arg0, 0);
- tree arg01;
if (kind0 == '1' || code0 == TRUTH_NOT_EXPR)
- return fold (build1 (code0, type,
- fold (build1 (CLEANUP_POINT_EXPR,
- TREE_TYPE (arg00), arg00))));
+ {
+ tree arg00 = TREE_OPERAND (arg0, 0);
+ return fold (build1 (code0, type,
+ fold (build1 (CLEANUP_POINT_EXPR,
+ TREE_TYPE (arg00), arg00))));
+ }
if (kind0 == '<' || kind0 == '2'
|| code0 == TRUTH_ANDIF_EXPR || code0 == TRUTH_ORIF_EXPR
|| code0 == TRUTH_AND_EXPR || code0 == TRUTH_OR_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)
|| ((code0 == TRUTH_ANDIF_EXPR || code0 == TRUTH_ORIF_EXPR)
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 9f0a236..309bef5 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -267,6 +267,7 @@ lhd_expand_decl (tree ARG_UNUSED (t))
const char *
lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity))
{
+ gcc_assert (decl && DECL_NAME (decl));
return IDENTIFIER_POINTER (DECL_NAME (decl));
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3727d52..27c1ecf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+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>
* gcc.dg/tree-ssa/20040911-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/parse/break-in-for.C b/gcc/testsuite/g++.dg/parse/break-in-for.C
new file mode 100644
index 0000000..92cac42
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/break-in-for.C
@@ -0,0 +1,11 @@
+/* PR17412
+ fold-const would try to fold the operands of the break statement. */
+/* { dg-do compile } */
+
+
+void foo ()
+{
+ for (;;)
+ for (;;({break;}));
+}
+
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index 5aa1743..d0b9aed 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -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
FLAGS are as in dump_generic_node. */
@@ -1892,7 +1903,7 @@ print_call_name (pretty_printer *buffer, tree node)
{
case VAR_DECL:
case PARM_DECL:
- PRINT_FUNCTION_NAME (op0);
+ dump_function_name (buffer, op0);
break;
case ADDR_EXPR:
@@ -1914,7 +1925,7 @@ print_call_name (pretty_printer *buffer, tree node)
/* The function is a pointer contained in a structure. */
if (TREE_CODE (TREE_OPERAND (op0, 0)) == INDIRECT_REF ||
TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
- PRINT_FUNCTION_NAME (TREE_OPERAND (op0, 1));
+ dump_function_name (buffer, TREE_OPERAND (op0, 1));
else
dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, 0, false);
/* else
@@ -1925,7 +1936,7 @@ print_call_name (pretty_printer *buffer, tree node)
case ARRAY_REF:
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
dump_generic_node (buffer, op0, 0, 0, false);
break;