diff mbox

Don't set TREE_READONLY on dummy args with VALUE attr (PR fortran/64528)

Message ID 20150113162430.GG1405@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Jan. 13, 2015, 4:24 p.m. UTC
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  <jakub@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.


	Jakub

Comments

Tobias Burnus Jan. 13, 2015, 4:32 p.m. UTC | #1
Jakub Jelinek wrote:
> 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?

OK. Thanks for the patch. I haven't checked whether it also applies to
4.8/4.9, if so, the patch is also okay for those branches.

Tobias
diff mbox

Patch

--- 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