]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/6631 (Miscompiled structure access)
authorMark Mitchell <mark@codesourcery.com>
Mon, 14 Oct 2002 21:04:33 +0000 (21:04 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 14 Oct 2002 21:04:33 +0000 (21:04 +0000)
PR optimization/6631
* Makefile.in (function.o): Depend on langhooks.h.
* alias.c (objects_must_conflict_p): Check honor_readonly when
examining TYPE_READONLY.
* function.c (assign_stack_temp_for_type): Likewise.

PR optimization/6631
* g++.dg/opt/const2.C: New test.

From-SVN: r58134

gcc/ChangeLog
gcc/Makefile.in
gcc/alias.c
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/const2.C [new file with mode: 0644]

index 6482378db6a9c914d32cfae9bcd62975e56fc0cf..aaa3abfb40e716ed79e25c0d38edb358f4e58f96 100644 (file)
@@ -1,3 +1,11 @@
+2002-10-14  Mark Mitchell  <mark@codesourcery.com>
+
+       PR optimization/6631
+       * Makefile.in (function.o): Depend on langhooks.h.
+       * alias.c (objects_must_conflict_p): Check honor_readonly when
+       examining TYPE_READONLY.
+       * function.c (assign_stack_temp_for_type): Likewise.
+
 2002-10-12  John David Anglin  <dave@hiauly1.hia.nrc.ca>
 
        * tree.c (tree_size): Revise expressions using TREE_CODE_LENGTH and
index 5afd30ef046770be023d5ff75947497bdd6b9faa..366919bb962a1aa1192061ec81643494aca1f14a 100644 (file)
@@ -1383,7 +1383,8 @@ varasm.o : varasm.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) flags.h \
    $(HASHTAB_H) $(TARGET_H) langhooks.h
 function.o : function.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h \
    function.h $(EXPR_H) libfuncs.h $(REGS_H) hard-reg-set.h \
-   insn-config.h $(RECOG_H) output.h toplev.h except.h hash.h $(GGC_H) $(TM_P_H)
+   insn-config.h $(RECOG_H) output.h toplev.h except.h hash.h $(GGC_H) \
+   $(TM_P_H) langhooks.h
 stmt.o : stmt.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) $(TREE_H) flags.h function.h  \
    insn-config.h hard-reg-set.h $(EXPR_H) libfuncs.h except.h \
    $(LOOP_H) $(RECOG_H) toplev.h output.h varray.h $(GGC_H) $(TM_P_H)
index 6d4104e640b5ed7043f9ca57877d2c4e64e1aa74..15f2d7b86618a994b92dca589923c9017a759d96 100644 (file)
@@ -1,5 +1,5 @@
 /* Alias analysis for GNU C
-   Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by John Carr (jfc@mit.edu).
 
 This file is part of GCC.
@@ -321,8 +321,8 @@ objects_must_conflict_p (t1, t2)
      then they may not conflict.  */
   if ((t1 != 0 && readonly_fields_p (t1))
       || (t2 != 0 && readonly_fields_p (t2))
-      || (t1 != 0 && TYPE_READONLY (t1))
-      || (t2 != 0 && TYPE_READONLY (t2)))
+      || (t1 != 0 && lang_hooks.honor_readonly && TYPE_READONLY (t1))
+      || (t2 != 0 && lang_hooks.honor_readonly && TYPE_READONLY (t2)))
     return 0;
 
   /* If they are the same type, they must conflict.  */
index 9ddf676b5aba4cdb2d0bcdae662a6002e1f45df5..b326d10e69daa88617dba130f75ccd9f071df8bd 100644 (file)
@@ -59,6 +59,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "ggc.h"
 #include "tm_p.h"
 #include "integrate.h"
+#include "langhooks.h"
 
 #ifndef TRAMPOLINE_ALIGNMENT
 #define TRAMPOLINE_ALIGNMENT FUNCTION_BOUNDARY
@@ -826,7 +827,8 @@ assign_stack_temp_for_type (mode, size, keep, type)
   /* If a type is specified, set the relevant flags.  */
   if (type != 0)
     {
-      RTX_UNCHANGING_P (slot) = TYPE_READONLY (type);
+      RTX_UNCHANGING_P (slot) = (lang_hooks.honor_readonly 
+                                && TYPE_READONLY (type));
       MEM_VOLATILE_P (slot) = TYPE_VOLATILE (type);
       MEM_SET_IN_STRUCT_P (slot, AGGREGATE_TYPE_P (type));
     }
index 3b857e0bcaa8357883257883433ddff894580570..d0d2b431d54256559f5413991b90afd4abc6ee2e 100644 (file)
@@ -1,5 +1,8 @@
 2002-10-14  Mark Mitchell  <mark@codesourcery.com>
 
+       PR optimization/6631
+       * g++.dg/opt/const2.C: New test.
+
        PR c++/7176
        * g++.dg/parse/friend1.C: New test.
        * g++.old-deja/g++.pt/memtemp64.C: Adjust.
diff --git a/gcc/testsuite/g++.dg/opt/const2.C b/gcc/testsuite/g++.dg/opt/const2.C
new file mode 100644 (file)
index 0000000..9ddc5e1
--- /dev/null
@@ -0,0 +1,40 @@
+// { dg-do run }
+// { dg-options "-O" }
+
+extern "C" void abort (void);
+
+struct QSize
+{
+  QSize();
+  QSize( int w, int h );
+  int wd, ht;
+  friend inline const QSize operator+( const QSize &, const QSize & );
+};
+
+inline QSize::QSize()
+{ wd = ht = -1; }
+
+inline QSize::QSize( int w, int h )
+{ wd = w; ht = h; }
+
+inline const QSize operator+( const QSize & s1, const QSize & s2 )
+{ return QSize(s1.wd+s2.wd, s1.ht+s2.ht); }
+
+QSize minimumSize()
+{
+  return QSize (100, 200);
+}
+
+QSize totalMinimumSize()
+{
+    QSize s = minimumSize();
+    return s + QSize( 0, 0 );
+}
+
+int main()
+{
+  QSize s = totalMinimumSize();
+  if (s.wd != 100 || s.ht != 200)
+    abort ();
+}
+