Hi! With VALUE attr, the PARM_DECLs hold the values and thus are (usually) not read-only, therefore telling the middle-end they are read-only leads to invalid IL.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2015-01-13 Jakub Jelinek <ja...@redhat.com> PR fortran/64528 * trans-decl.c (create_function_arglist): Don't set TREE_READONLY on dummy args with VALUE attribute. * gfortran.dg/pr64528.f90: New test. --- gcc/fortran/trans-decl.c.jj 2015-01-09 21:59:47.000000000 +0100 +++ gcc/fortran/trans-decl.c 2015-01-13 14:24:22.342682352 +0100 @@ -2327,8 +2327,9 @@ create_function_arglist (gfc_symbol * sy /* Fill in arg stuff. */ DECL_CONTEXT (parm) = fndecl; DECL_ARG_TYPE (parm) = TREE_VALUE (typelist); - /* All implementation args are read-only. */ - TREE_READONLY (parm) = 1; + /* All implementation args except for VALUE are read-only. */ + if (!f->sym->attr.value) + TREE_READONLY (parm) = 1; if (POINTER_TYPE_P (type) && (!f->sym->attr.proc_pointer && f->sym->attr.flavor != FL_PROCEDURE)) --- gcc/testsuite/gfortran.dg/pr64528.f90.jj 2015-01-13 14:27:13.475650977 +0100 +++ gcc/testsuite/gfortran.dg/pr64528.f90 2015-01-13 14:26:46.000000000 +0100 @@ -0,0 +1,20 @@ +! PR fortran/64528 +! { dg-do compile } +! { dg-options "-O -fno-tree-dce -fno-tree-ccp" } + +program pr64528 + interface + subroutine foo(x) + integer, value :: x + end subroutine foo + end interface + integer :: x + x = 10 + call foo(x) + if(x .ne. 10) then + endif +end program pr64528 +subroutine foo(x) + integer, value :: x + x = 11 +end subroutine foo Jakub