aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2006-03-10 17:47:08 -0500
committerJason Merrill <jason@gcc.gnu.org>2006-03-10 17:47:08 -0500
commit21f9ec0c6ad431e25e58dee6b9e6759ab7e74003 (patch)
tree2b1be739b500fee318e5f1d12833519be9204c09
parente16187d98d7a47a24ea909d01bf17349aed93aeb (diff)
downloadgcc-21f9ec0c6ad431e25e58dee6b9e6759ab7e74003.zip
gcc-21f9ec0c6ad431e25e58dee6b9e6759ab7e74003.tar.gz
gcc-21f9ec0c6ad431e25e58dee6b9e6759ab7e74003.tar.bz2
re PR middle-end/26004 (gcc errors on valid code [SVO])
PR c/26004 * gimplify.c (gimplify_modify_expr_rhs): Don't do return slot opt if the target was declared 'register'. From-SVN: r111947
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimplify.c3
-rw-r--r--gcc/testsuite/gcc.dg/pr26004.c11
3 files changed, 19 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8bb4a2a..0d90fa2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-03-10 Jason Merrill <jason@redhat.com>
+
+ PR c/26004
+ * gimplify.c (gimplify_modify_expr_rhs): Don't do return slot opt if
+ the target was declared 'register'.
+
2006-03-10 Adam Nemet <anemet@caviumnetworks.com>
* genpreds.c (write_insn_constraint_len): Change definition of
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 4b58201..c9498ee 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -3295,7 +3295,8 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, tree *pre_p,
&& needs_to_live_in_memory (*to_p))
/* It's OK to use the return slot directly unless it's an NRV. */
use_target = true;
- else if (is_gimple_reg_type (TREE_TYPE (*to_p)))
+ else if (is_gimple_reg_type (TREE_TYPE (*to_p))
+ || (DECL_P (*to_p) && DECL_REGISTER (*to_p)))
/* Don't force regs into memory. */
use_target = false;
else if (TREE_CODE (*to_p) == VAR_DECL
diff --git a/gcc/testsuite/gcc.dg/pr26004.c b/gcc/testsuite/gcc.dg/pr26004.c
new file mode 100644
index 0000000..35e6a2f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr26004.c
@@ -0,0 +1,11 @@
+/* PR c/26004 */
+/* Bug: the return slot optimization was taking the address of s_3,
+ causing an error. */
+
+struct s_3 { short s[3]; } z_3, s_3;
+struct s_3 add_struct_3 (struct s_3 s){}
+wack_struct_3 (void)
+{
+ int i; register struct s_3 u = z_3;
+ u = add_struct_3 (u);
+}