Hi Dominique,

If I am not mistaken, the patch causes:

FAIL: gfortran.dg/pr71935.f90   -O  (test for excess errors)
FAIL: gfortran.dg/substr_6.f90   -O0  execution test
FAIL: gfortran.dg/substr_6.f90   -O1  execution test
FAIL: gfortran.dg/substr_6.f90   -O2  execution test
FAIL: gfortran.dg/substr_6.f90   -O3 -fomit-frame-pointer -funroll-loops 
-fpeel-loops -ftracer -finline-functions  execution test
FAIL: gfortran.dg/substr_6.f90   -O3 -g  execution test
FAIL: gfortran.dg/substr_6.f90   -Os  execution test

These have been resolved now - I have removed the invalid code
from substr_6.f90 (PR85130), and the error is now suppressed
in the attached patch.

Re-regression-tested. OK for trunk?

Regards

        Thomas

2018-03-25  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/51260
        * resolve.c (resolve_variable): Simplify cases where access to a
        parameter array results in a single constant.

2018-03-25  Thomas Koenig  <tkoe...@gcc.gnu.org>

        PR fortran/51260
        * gfortran.dg/parameter_array_element_3.f90: New test.
! { dg-do compile }
! PR 51260 - an unneeded parameter found its way into the
! assembly code. Original test case by Tobias Burnus.
module x
contains
  subroutine foo(i)
    integer, intent(in) :: i
  end subroutine foo
end module x

program main
  use x
  integer, parameter:: unneeded_parameter (10000)=(/(i,i=1,10000)/)
  call foo(unneeded_parameter (1))
  print *,unneeded_parameter (1)
end program
! { dg-final { scan-assembler-times "unneeded_parameter" 0 } }
Index: resolve.c
===================================================================
--- resolve.c	(Revision 258845)
+++ resolve.c	(Arbeitskopie)
@@ -5577,6 +5577,16 @@ resolve_procedure:
   if (t && flag_coarray == GFC_FCOARRAY_LIB && gfc_is_coindexed (e))
     add_caf_get_intrinsic (e);
 
+  /* Simplify cases where access to a parameter array results in a
+     single constant.  Suppress errors since those will have been
+     issued before, as warnings.  */
+  if (e->rank == 0 && sym->as && sym->attr.flavor == FL_PARAMETER)
+    {
+      gfc_push_suppress_errors ();
+      gfc_simplify_expr (e, 1);
+      gfc_pop_suppress_errors ();
+    }
+
   return t;
 }
 

Reply via email to