This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Don't make all MEM_REFs with TREE_READONLY arguments TREE_READONLY (PR sanitizer/64336)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 17 Dec 2014 14:18:15 +0100
- Subject: [PATCH] Don't make all MEM_REFs with TREE_READONLY arguments TREE_READONLY (PR sanitizer/64336)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
MEM_REF (the only tcc_reference code with 2 operands) has TREE_READONLY set
whenever all the arguments are TREE_READONLY, which is wrong, if the
pointer/reference is read-only, it doesn't say anything about whether
what it points to is also read-only.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
I'll work on TREE_THIS_VOLATILE for MEM_REF/TARGET_MEM_REF later on, as
a follow-up.
2014-12-17 Jakub Jelinek <jakub@redhat.com>
PR sanitizer/64336
* tree.c (build2_stat): Don't set TREE_READONLY on MEM_REF
even when the arguments are TREE_READONLY.
--- gcc/tree.c.jj 2014-12-15 10:36:23.000000000 +0100
+++ gcc/tree.c 2014-12-17 10:48:07.216729576 +0100
@@ -4352,7 +4352,7 @@ build2_stat (enum tree_code code, tree t
arguments are as well. */
constant = (TREE_CODE_CLASS (code) == tcc_comparison
|| TREE_CODE_CLASS (code) == tcc_binary);
- read_only = 1;
+ read_only = code != MEM_REF;
side_effects = TREE_SIDE_EFFECTS (t);
PROCESS_ARG (0);
Jakub