[patch, fortran] Fix PR 68009, wrong prototype in runtime_error

Thomas Koenig tkoenig@netcologne.de
Sun Mar 17 12:04:00 GMT 2019


Hello world,

this fixes a 7/8/9 regression. The problem is that front-end inlining
of matmul could generate calls to _gfortran_runtime_error which were
called as non-variadic.  This fixes the problem by setting the
backend_decl on the resovled symbol, so it always uses the right one.

Putting it into the resolution stage seems a bit strange, but I tried
several other methods such as putting it into the global symbol table,
and nothing else I tried worked.

You can check on x86_64 if the patch works by doing

$ cat nn.f90
module x
contains
   subroutine mm(a,b,c)
     real, dimension(:) :: a, c
     real, dimension(:,:) :: b
     c = matmul(a,b)
   end subroutine mm
end module x

$ gfortran -S -O -fcheck=bounds nn.f90

and then looking for code snippets like

         movl    $89, %ecx
         movq    %rdi, %rdx
         movl    $.LC0, %edi
         movl    $0, %eax
         call    _gfortran_runtime_error

where setting %eax to zero indicates that we are indeed using
varargs, because %eax contains the number of float arguments,
which is zero.

No test case, because there is not really a good way to check for this.

So, OK for trunk?

Regards

	Thomas

2019-03-17  Thomas Koenig  <tkoeng@gcc.gnu.org>

	PR fortran/68009
	* iresolve.c: Include trans.h.
	(gfc_resolve_fe_runtine_error): Set backend_decl on
	resolved_sym.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p2.diff
Type: text/x-patch
Size: 766 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20190317/6049865d/attachment.bin>


More information about the Fortran mailing list