tree.c (unsafe_for_reeval): Consider callee child of CALL_EXPR.
authorDale Johannesen <dalej@apple.com>
Fri, 6 Dec 2002 00:08:11 +0000 (00:08 +0000)
committerDale Johannesen <dalej@gcc.gnu.org>
Fri, 6 Dec 2002 00:08:11 +0000 (00:08 +0000)
2002-12-05  Dale Johannesen  <dalej@apple.com>

        * tree.c (unsafe_for_reeval):  Consider callee child of CALL_EXPR.

From-SVN: r59875

gcc/ChangeLog
gcc/testsuite/gcc.dg/20021205-1.c [new file with mode: 0644]
gcc/tree.c

index 683219fd952d1af0b23c5431e61eaa5e5c56a83a..dc7a57d47e3d9105ad3c6048234778c01edf9a96 100644 (file)
@@ -1,3 +1,7 @@
+2002-12-05  Dale Johannesen  <dalej@apple.com>
+
+       * tree.c (unsafe_for_reeval):  Consider callee child of CALL_EXPR.
+
 2002-12-05  Danny Smith  <dannysmith@users.sourceforge.net>
 
        * config/i386/cygwin.h (SUBTARGET_PROLOGUE): Replace with
diff --git a/gcc/testsuite/gcc.dg/20021205-1.c b/gcc/testsuite/gcc.dg/20021205-1.c
new file mode 100644 (file)
index 0000000..a187625
--- /dev/null
@@ -0,0 +1,10 @@
+/* dg-do compile */
+/* dg-options "-O3" */
+typedef struct x x;
+struct x { char * (*bar) (int); };
+static x **foo() { return ((x**)baz()); }
+int xyzzy()
+{
+    baz((*foo())->bar(0));
+    return 3;
+}
index dfac289f137643e2af8f12cefc125b146dc0da32..04fddb26dd3f2c9b7a274f94d11be4613dd065df 100644 (file)
@@ -1634,7 +1634,7 @@ unsafe_for_reeval (expr)
 {
   int unsafeness = 0;
   enum tree_code code;
-  int i, tmp;
+  int i, tmp, tmp2;
   tree exp;
   int first_rtl;
 
@@ -1660,8 +1660,9 @@ unsafe_for_reeval (expr)
       return unsafeness;
 
     case CALL_EXPR:
+      tmp2 = unsafe_for_reeval (TREE_OPERAND (expr, 0));
       tmp = unsafe_for_reeval (TREE_OPERAND (expr, 1));
-      return MAX (tmp, 1);
+      return MAX (MAX (tmp, 1), tmp2);
 
     case TARGET_EXPR:
       unsafeness = 1;