re PR middle-end/42898 (volatile structures and compound literal initializers)
PR middle-end/42898 Backport from mainline: 2009-04-23 Eric Botcazou <ebotcazou@adacore.com> * gimplify.c (gimplify_modify_expr_rhs) <VAR_DECL>: Do not do a direct assignment from the constructor either if the target is volatile. From-SVN: r156415
This commit is contained in:
parent
a3c66ee4f8
commit
61e53d13e6
|
@ -1,3 +1,12 @@
|
|||
2010-01-31 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
PR middle-end/42898
|
||||
Backport from mainline:
|
||||
2009-04-23 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gimplify.c (gimplify_modify_expr_rhs) <VAR_DECL>: Do not do a direct
|
||||
assignment from the constructor either if the target is volatile.
|
||||
|
||||
2010-01-31 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR middle-end/42898
|
||||
|
|
|
@ -3946,11 +3946,14 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p,
|
|||
switch (TREE_CODE (*from_p))
|
||||
{
|
||||
case VAR_DECL:
|
||||
/* If we're assigning from a constant constructor, move the
|
||||
constructor expression to the RHS of the MODIFY_EXPR. */
|
||||
/* If we're assigning from a read-only variable initialized with
|
||||
a constructor, do the direct assignment from the constructor,
|
||||
but only if neither source nor target are volatile since this
|
||||
latter assignment might end up being done on a per-field basis. */
|
||||
if (DECL_INITIAL (*from_p)
|
||||
&& TREE_READONLY (*from_p)
|
||||
&& !TREE_THIS_VOLATILE (*from_p)
|
||||
&& !TREE_THIS_VOLATILE (*to_p)
|
||||
&& TREE_CODE (DECL_INITIAL (*from_p)) == CONSTRUCTOR)
|
||||
{
|
||||
tree old_from = *from_p;
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2010-01-31 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
PR middle-end/42898
|
||||
* gcc.dg/torture/pr42898-2.c: New test.
|
||||
|
||||
2010-01-31 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR middle-end/42898
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fdump-tree-optimized" } */
|
||||
|
||||
struct hardware {
|
||||
int parm1:8;
|
||||
int :4;
|
||||
int parm2:4;
|
||||
int parm3:15;
|
||||
int parm4:1;
|
||||
};
|
||||
|
||||
const struct hardware h = {
|
||||
.parm1=42,
|
||||
.parm2=13,
|
||||
.parm3=11850,
|
||||
.parm4=1,
|
||||
};
|
||||
|
||||
void f1(volatile struct hardware *ptr)
|
||||
{
|
||||
*ptr = h;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump-times "\\*ptr" 1 "optimized" } } */
|
||||
/* { dg-final { cleanup-tree-dump "optimized" } } */
|
Loading…
Reference in New Issue