summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr46360.c13
-rw-r--r--gcc/tree-ssa-propagate.c10
4 files changed, 29 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5c73a47b150..110b7fb1797 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2010-11-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/46360
+ * tree-ssa-propagate.c (update_call_from_tree): Fix for use
+ not in SSA mode.
+
2010-11-09 Richard Guenther <rguenther@suse.de>
PR middle-end/46221
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e0f6069a7d2..07b1a58885c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2010-11-09 Jakub Jelinek <jakub@redhat.com>
+ PR middle-end/46360
+ * gcc.c-torture/compile/pr46360.c: New test.
+
PR c++/45894
* g++.dg/warn/Wsequence-point-2.C: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr46360.c b/gcc/testsuite/gcc.c-torture/compile/pr46360.c
new file mode 100644
index 00000000000..1a5239bc1a1
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr46360.c
@@ -0,0 +1,13 @@
+/* PR middle-end/46360 */
+
+__attribute__((gnu_inline, always_inline)) extern inline char *
+strncpy (char *dest, const char *src, __SIZE_TYPE__ len)
+{
+ return __builtin_strncpy (dest, src, len);
+}
+
+void
+foo (char *s)
+{
+ strncpy (s, "", 0);
+}
diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c
index c97960cfdf7..7f1d84ebdfe 100644
--- a/gcc/tree-ssa-propagate.c
+++ b/gcc/tree-ssa-propagate.c
@@ -760,8 +760,11 @@ update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
/* No value is expected, and EXPR has no effect.
Replace it with an empty statement. */
new_stmt = gimple_build_nop ();
- unlink_stmt_vdef (stmt);
- release_defs (stmt);
+ if (gimple_in_ssa_p (cfun))
+ {
+ unlink_stmt_vdef (stmt);
+ release_defs (stmt);
+ }
}
else
{
@@ -773,7 +776,8 @@ update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
lhs = create_tmp_var (TREE_TYPE (expr), NULL);
new_stmt = gimple_build_assign (lhs, expr);
add_referenced_var (lhs);
- lhs = make_ssa_name (lhs, new_stmt);
+ if (gimple_in_ssa_p (cfun))
+ lhs = make_ssa_name (lhs, new_stmt);
gimple_assign_set_lhs (new_stmt, lhs);
gimple_set_vuse (new_stmt, gimple_vuse (stmt));
gimple_set_vdef (new_stmt, gimple_vdef (stmt));