re PR fortran/83246 (internal compiler error or loader problem might be related to...
authorJakub Jelinek <jakub@redhat.com>
Fri, 1 Feb 2019 22:54:05 +0000 (23:54 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 1 Feb 2019 22:54:05 +0000 (23:54 +0100)
PR fortran/83246
PR fortran/89084
* trans-decl.c (generate_local_decl): Add referenced FL_PARAMETERs
if sym->ns->construct_entities rather than if
sym->ns->parent->code->op == EXEC_BLOCK.

* gfortran.dg/pr89084.f90: New test.
* gfortran.dg/lto/pr89084_0.f90: New test.
* gfortran.dg/pr83246.f90: New test.

From-SVN: r268462

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/lto/pr89084_0.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr83246.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr89084.f90 [new file with mode: 0644]

index 7f2a7afbbb9537dd5c14ed5ce3ccb458243971e5..0a5da36a601041783326281e2423123aa6c40dc5 100644 (file)
@@ -1,3 +1,11 @@
+2019-02-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/83246
+       PR fortran/89084
+       * trans-decl.c (generate_local_decl): Add referenced FL_PARAMETERs
+       if sym->ns->construct_entities rather than if
+       sym->ns->parent->code->op == EXEC_BLOCK.
+
 2019-01-31  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/88669
index 1fe1165181612e0435c93c7a0531693f803af851..b8f50f74e1a4fe4bdf490b8104fdafc905a15190 100644 (file)
@@ -5735,10 +5735,7 @@ generate_local_decl (gfc_symbol * sym)
                          "imported at %L", sym->name, &sym->declared_at);
        }
 
-      if (sym->ns
-         && sym->ns->parent
-         && sym->ns->parent->code
-         && sym->ns->parent->code->op == EXEC_BLOCK)
+      if (sym->ns && sym->ns->construct_entities)
        {
          if (sym->attr.referenced)
            gfc_get_symbol_decl (sym);
index 1df9ba2674d62c4b336afdb88925e4e424d8b8c4..02a4b857e0e8626dcdc5aacac156e1373a8c1a45 100644 (file)
@@ -1,3 +1,11 @@
+2019-02-01  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/83246
+       PR fortran/89084
+       * gfortran.dg/pr89084.f90: New test.
+       * gfortran.dg/lto/pr89084_0.f90: New test.
+       * gfortran.dg/pr83246.f90: New test.
+
 2019-02-01  Marek Polacek  <polacek@redhat.com>
 
        PR c++/88325 - ICE with invalid out-of-line template member definition.
diff --git a/gcc/testsuite/gfortran.dg/lto/pr89084_0.f90 b/gcc/testsuite/gfortran.dg/lto/pr89084_0.f90
new file mode 100644 (file)
index 0000000..2c49749
--- /dev/null
@@ -0,0 +1,24 @@
+! PR fortran/89084
+! { dg-lto-do link }
+! { dg-lto-options {{ -O0 -flto }} }
+
+integer function foo ()
+  write (*,*) 'foo'
+  block
+    integer, parameter :: idxs(3) = (/ 1, 2, 3 /)
+    integer :: i
+    foo = 0
+    do i = 1, size(idxs)
+      foo = foo + idxs(i)
+    enddo
+  end block
+end function foo
+program pr89084
+  integer :: i
+  interface
+    integer function foo ()
+    end function
+  end interface
+  i = foo ()
+  if (i.ne.6) stop 1
+end
diff --git a/gcc/testsuite/gfortran.dg/pr83246.f90 b/gcc/testsuite/gfortran.dg/pr83246.f90
new file mode 100644 (file)
index 0000000..32097e3
--- /dev/null
@@ -0,0 +1,9 @@
+! PR fortran/83246
+! { dg-do link }
+   program dusty_corner 
+   write(*,*)'BLOCK TESTS' 
+   MAKEDATAP: block
+   integer,parameter :: scratch(*)=[1,2,3]
+   write(*,*)scratch
+   endblock MAKEDATAP
+   end program dusty_corner
diff --git a/gcc/testsuite/gfortran.dg/pr89084.f90 b/gcc/testsuite/gfortran.dg/pr89084.f90
new file mode 100644 (file)
index 0000000..3ac6b37
--- /dev/null
@@ -0,0 +1,23 @@
+! PR fortran/89084
+! { dg-do run }
+
+integer function foo ()
+  write (*,*) 'foo'
+  block
+    integer, parameter :: idxs(3) = (/ 1, 2, 3 /)
+    integer :: i
+    foo = 0
+    do i = 1, size(idxs)
+      foo = foo + idxs(i)
+    enddo
+  end block
+end function foo
+program pr89084
+  integer :: i
+  interface
+    integer function foo ()
+    end function
+  end interface
+  i = foo ()
+  if (i.ne.6) stop 1
+end