re PR fortran/69455 ([F08] Assembler error(s) when using intrinsic modules in two...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 18 Oct 2019 17:27:06 +0000 (17:27 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 18 Oct 2019 17:27:06 +0000 (17:27 +0000)
2019-10-18  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/69455
* trans-decl.c (generate_local_decl): Avoid misconstructed
intrinsic modules in a BLOCK construct.

2019-10-18  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/69455
* gfortran.dg/pr69455_1.f90: New test.
* gfortran.dg/pr69455_2.f90: Ditto.

From-SVN: r277158

gcc/fortran/ChangeLog
gcc/fortran/trans-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr69455_1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/pr69455_2.f90 [new file with mode: 0644]

index 8a1beeafa01bb9d6d3916551c53f32ae5ed81fba..5ba62d251ef5008d71cea80aaa08a41f1cd68081 100644 (file)
@@ -1,3 +1,9 @@
+2019-10-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/69455
+       * trans-decl.c (generate_local_decl): Avoid misconstructed
+       intrinsic modules in a BLOCK construct.
+
 2019-10-18  Tobias Burnus  <tobias@codesourcery.com>
 
        PR fortran/91586
index 3ad802e5d83e846d426bdef1214af8859c45bb80..fc295b4e843dd79ca72c9a5185ff1d9b870e5aa8 100644 (file)
@@ -5987,7 +5987,14 @@ generate_local_decl (gfc_symbol * sym)
 
       if (sym->ns && sym->ns->construct_entities)
        {
-         if (sym->attr.referenced)
+         /* Construction of the intrinsic modules within a BLOCK
+            construct, where ONLY and RENAMED entities are included,
+            seems to be bogus.  This is a workaround that can be removed
+            if someone ever takes on the task to creating full-fledge
+            modules.  See PR 69455.  */
+         if (sym->attr.referenced
+             && sym->from_intmod != INTMOD_ISO_C_BINDING
+             && sym->from_intmod != INTMOD_ISO_FORTRAN_ENV)
            gfc_get_symbol_decl (sym);
          sym->mark = 1;
        }
index 7d427a96d6df688cf2a5013fd2d5f6c963090f05..5379447194bc37f811de3e0496c6fa7d79648b8f 100644 (file)
@@ -1,3 +1,9 @@
+2019-10-18  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/69455
+       * gfortran.dg/pr69455_1.f90: New test.
+       * gfortran.dg/pr69455_2.f90: Ditto.
+
 2019-10-18  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
        * gcc.target/arm/multilib.exp: Add extra tests.
diff --git a/gcc/testsuite/gfortran.dg/pr69455_1.f90 b/gcc/testsuite/gfortran.dg/pr69455_1.f90
new file mode 100644 (file)
index 0000000..fe62e5c
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do run }
+program foo
+   block
+      use, intrinsic :: iso_c_binding, only: wp => c_float, ik => c_int
+      if (ik /= 4) stop 1
+      if (wp /= 4) stop 2
+   end block
+   block
+      use, intrinsic :: iso_c_binding, only: wp => c_double, ik => c_int64_t
+      if (ik /= 8) stop 3
+      if (wp /= 8) stop 4
+   end block
+end program foo
+
diff --git a/gcc/testsuite/gfortran.dg/pr69455_2.f90 b/gcc/testsuite/gfortran.dg/pr69455_2.f90
new file mode 100644 (file)
index 0000000..8f9fb35
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do run }
+program foo
+   block
+      use, intrinsic :: ISO_FORTRAN_ENV, only: wp => REAL32, ik => INT32
+      if (ik /= 4) stop 1
+      if (wp /= 4) stop 2
+   end block
+   block
+      use, intrinsic :: ISO_FORTRAN_ENV, only: wp => REAL64, ik => INT64
+      if (ik /= 8) stop 3
+      if (wp /= 8) stop 4
+   end block
+end program foo