summaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-23 08:14:33 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-23 08:14:33 +0000
commitce43c806f609396f27f739151cf71ff852dbe997 (patch)
tree53f2733f9b2d5981233b4f403e52b59105601acd /gcc/gimplify.c
parenta31688d73e765cabff84a5192f5c9da53f69555b (diff)
downloadgcc-ce43c806f609396f27f739151cf71ff852dbe997.tar.gz
PR c++/16405
* gimplify.c (gimplify_modify_expr_rhs): Handle INDIRECT_REF/ADDR_EXPR combinations. PR c++/16405 * g++.dg/opt/temp1.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92539 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 2434a815c7c..0f610e4d242 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2801,6 +2801,33 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, tree *pre_p,
while (ret != GS_UNHANDLED)
switch (TREE_CODE (*from_p))
{
+ case INDIRECT_REF:
+ {
+ /* If we have code like
+
+ *(const A*)(A*)&x
+
+ where the type of "x" is a (possibly cv-qualified variant
+ of "A"), treat the entire expression as identical to "x".
+ This kind of code arises in C++ when an object is bound
+ to a const reference, and if "x" is a TARGET_EXPR we want
+ to take advantage of the optimization below. */
+ tree pointer;
+
+ pointer = TREE_OPERAND (*from_p, 0);
+ STRIP_NOPS (pointer);
+ if (TREE_CODE (pointer) == ADDR_EXPR
+ && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (pointer, 0)))
+ == TYPE_MAIN_VARIANT (TREE_TYPE (*from_p))))
+ {
+ *from_p = TREE_OPERAND (pointer, 0);
+ ret = GS_OK;
+ }
+ else
+ ret = GS_UNHANDLED;
+ break;
+ }
+
case TARGET_EXPR:
{
/* If we are initializing something from a TARGET_EXPR, strip the