re PR middle-end/77959 (ICE in ix86_decompose_address, at i386/i386.c:14954)
authorJakub Jelinek <jakub@redhat.com>
Fri, 14 Oct 2016 19:36:58 +0000 (21:36 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 14 Oct 2016 19:36:58 +0000 (21:36 +0200)
PR middle-end/77959
* expr.c (expand_expr_real_1) <case CONST_DECL>: For EXPAND_WRITE
return a MEM.

* gfortran.dg/pr77959.f90: New test.

From-SVN: r241182

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr77959.f90 [new file with mode: 0644]

index 63034cd6d58a265592e71395832da2aa6791528b..732ccb28f0e3155ce06ca2d240d20f6c6d9281b6 100644 (file)
@@ -1,3 +1,9 @@
+2016-10-14  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/77959
+       * expr.c (expand_expr_real_1) <case CONST_DECL>: For EXPAND_WRITE
+       return a MEM.
+
 2016-10-14  Eric Botcazou  <ebotcazou@adacore.com>
 
        * config/sparc/sparc-passes.def: New file.
index b587da82180acb2b2d0479d010223965ec1a8b22..28242b2551d017ca354ada6db1fcd39521f4af6c 100644 (file)
@@ -9915,6 +9915,19 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
       }
 
     case CONST_DECL:
+      if (modifier == EXPAND_WRITE)
+       {
+         /* Writing into CONST_DECL is always invalid, but handle it
+            gracefully.  */
+         addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (exp));
+         machine_mode address_mode = targetm.addr_space.address_mode (as);
+         op0 = expand_expr_addr_expr_1 (exp, NULL_RTX, address_mode,
+                                        EXPAND_NORMAL, as);
+         op0 = memory_address_addr_space (mode, op0, as);
+         temp = gen_rtx_MEM (mode, op0);
+         set_mem_addr_space (temp, as);
+         return temp;
+       }
       return expand_expr (DECL_INITIAL (exp), target, VOIDmode, modifier);
 
     case REAL_CST:
index 25115d4130d060fa69f970a7871665a308e35957..849c6e49de6809cec913f47190c35c7023d7cb44 100644 (file)
@@ -1,5 +1,8 @@
 2016-10-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/77959
+       * gfortran.dg/pr77959.f90: New test.
+
        DR 1511 - const volatile variables and ODR
        * g++.dg/DRs/dr1511-1.C: New test.
        * g++.dg/DRs/dr1511-2.C: New test.
diff --git a/gcc/testsuite/gfortran.dg/pr77959.f90 b/gcc/testsuite/gfortran.dg/pr77959.f90
new file mode 100644 (file)
index 0000000..36754a0
--- /dev/null
@@ -0,0 +1,16 @@
+! PR middle-end/77959
+! { dg-do compile }
+! { dg-options "-O2" }
+
+program pr77959
+  interface
+    subroutine foo(x)  ! { dg-warning "Type mismatch in argument" }
+      real :: x
+    end
+  end interface
+  call foo(1.0)
+end
+subroutine foo(x)
+  complex :: x
+  x = x + 1
+end