OSDN Git Service

PR optimization/6631
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 14 Oct 2002 21:19:05 +0000 (21:19 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 14 Oct 2002 21:19:05 +0000 (21:19 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@58136 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 2064e1d..2513b47 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-14  Mark Mitchell  <mark@codesourcery.com>
+
+       PR optimization/6631
+       * alias.c (objects_must_conflict_p): Check honor_readonly when
+       examining TYPE_READONLY.
+       * function.c (assign_stack_temp_for_type): Likewise.
+
 2002-10-14  Falk Hueffner  <falk.hueffner@student.uni-tuebingen.de>
 
        * config/alpha/alpha.md (extendsidi2_nofix, extendsidi2_fix):
index 914b153..ca560b6 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.
@@ -332,8 +332,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 479ecef..0c066ed 100644 (file)
@@ -798,7 +798,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 5b1374c..b368a72 100644 (file)
@@ -1,5 +1,10 @@
 2002-10-14  Mark Mitchell  <mark@codesourcery.com>
 
+       PR optimization/6631
+       * g++.dg/opt/const2.C: New test.
+
+2002-10-14  Mark Mitchell  <mark@codesourcery.com>
+
        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 ();
+}
+