Commit 0633ee10 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/71372 (C++ FE drops TREE_THIS_VOLATILE in cp_fold on all tcc_reference trees)

	PR c++/71372
	* cp-gimplify.c (cp_fold): For INDIRECT_REF, if the folded expression
	is INDIRECT_REF or MEM_REF, copy over TREE_READONLY, TREE_SIDE_EFFECTS
	and TREE_THIS_VOLATILE flags.  For ARRAY_REF and ARRAY_RANGE_REF, copy
	over TREE_READONLY, TREE_SIDE_EFFECTS and TREE_THIS_VOLATILE flags
	to the newly built tree.

	* c-c++-common/pr71372.c: New test.

From-SVN: r237041
parent 4ae1c663
2016-06-02 Jakub Jelinek <jakub@redhat.com>
PR c++/71372
* cp-gimplify.c (cp_fold): For INDIRECT_REF, if the folded expression
is INDIRECT_REF or MEM_REF, copy over TREE_READONLY, TREE_SIDE_EFFECTS
and TREE_THIS_VOLATILE flags. For ARRAY_REF and ARRAY_RANGE_REF, copy
over TREE_READONLY, TREE_SIDE_EFFECTS and TREE_THIS_VOLATILE flags
to the newly built tree.
2016-05-31 Jason Merrill <jason@redhat.com>
* pt.c (instantiate_decl): Avoid recalculation.
......
......@@ -2035,7 +2035,16 @@ cp_fold (tree x)
if (op0 == error_mark_node)
x = error_mark_node;
else
x = fold_build1_loc (loc, code, TREE_TYPE (x), op0);
{
x = fold_build1_loc (loc, code, TREE_TYPE (x), op0);
if (code == INDIRECT_REF
&& (INDIRECT_REF_P (x) || TREE_CODE (x) == MEM_REF))
{
TREE_READONLY (x) = TREE_READONLY (org_x);
TREE_SIDE_EFFECTS (x) = TREE_SIDE_EFFECTS (org_x);
TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (org_x);
}
}
}
else
x = fold (x);
......@@ -2312,7 +2321,12 @@ cp_fold (tree x)
|| op3 == error_mark_node)
x = error_mark_node;
else
x = build4_loc (loc, code, TREE_TYPE (x), op0, op1, op2, op3);
{
x = build4_loc (loc, code, TREE_TYPE (x), op0, op1, op2, op3);
TREE_READONLY (x) = TREE_READONLY (org_x);
TREE_SIDE_EFFECTS (x) = TREE_SIDE_EFFECTS (org_x);
TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (org_x);
}
}
x = fold (x);
......
2016-06-02 Jakub Jelinek <jakub@redhat.com>
PR c++/71372
* c-c++-common/pr71372.c: New test.
* gcc.dg/cpp/source_date_epoch-1.c (main): Test __DATE__ and
__TIME__ strings with __builtin_strcmp instead of printf and
dg-output.
......
/* PR c++/71372 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
void
foo (volatile int *p, int q)
{
*(volatile int *)p = 0;
*(p + (q - q) + 1) = 0;
*(p + (q - q) + 2) = 0;
*(p + (q - q) + 3) = 0;
}
/* { dg-final { scan-tree-dump-times " ={v} " 4 "optimized" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment