On Thu, 2016-12-08 at 21:08 +0100, Bernd Schmidt wrote:
> On 12/08/2016 09:39 PM, David Malcolm wrote:
> > 
> > OK as adjustments to patches 8a and 8b?
> 
> Ok. Is it possible to adjust these macros to return something like a
> const reference to ensure people can't make this kind of error?
> 
> 
> Bernd

The following patch leads to errors like this for that kind
of mistake:

error: assignment of member 'mem_attrs::offset' in read-only object
        MEM_OFFSET (x) = atoi (name.string);
                                          ^

Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu.

OK for trunk?

gcc/ChangeLog:
        * rtl.h (get_mem_attrs): Add "const" qualifier to returned
        pointer.
---
 gcc/rtl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/rtl.h b/gcc/rtl.h
index a5efa28..4f0efa6 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -3355,7 +3355,7 @@ extern struct target_rtl *this_target_rtl;
 
 #ifndef GENERATOR_FILE
 /* Return the attributes of a MEM rtx.  */
-static inline struct mem_attrs *
+static inline const struct mem_attrs *
 get_mem_attrs (const_rtx x)
 {
   struct mem_attrs *attrs;
-- 
1.8.5.3

Reply via email to