re PR fortran/78297 (ICE in finish_equivalences, at fortran/trans-common.c:1246)
authorSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 23 Nov 2016 21:44:05 +0000 (21:44 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 23 Nov 2016 21:44:05 +0000 (21:44 +0000)
2016-11-23  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/78297
* trans-common.c (finish_equivalences): Do not dereference a NULL pointer.

2016-11-23  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/78297
* gfortran.dg/pr78297.f90: New test.

From-SVN: r242802

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

index adeb08da896b0e53cd206609ac6e62014c82d81b..e468a4928814f8b0e77621ac04387c84f308d529 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-23  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78297
+       * trans-common.c (finish_equivalences): Do not dereference a NULL pointer.
+
 2016-11-23  Martin Jambor  <mjambor@suse.cz>
 
        * f95-lang.c (DEF_HSA_BUILTIN): New macro.
index 3207105505d2c1f82fc37a05c90e0e1c4d8eae1f..7706809b4a241c07ae671ffc6cdf3d4c48e6b2a1 100644 (file)
@@ -1246,8 +1246,12 @@ finish_equivalences (gfc_namespace *ns)
          {
            c = gfc_get_common_head ();
            /* We've lost the real location, so use the location of the
-              enclosing procedure.  */
-           c->where = ns->proc_name->declared_at;
+              enclosing procedure.  If we're in a BLOCK DATA block, then
+              use the location in the sym_root.  */
+           if (ns->proc_name)
+             c->where = ns->proc_name->declared_at;
+           else if (ns->is_block_data)
+             c->where = ns->sym_root->n.sym->declared_at;
            strcpy (c->name, z->module);
          }
        else
index 6954431779ba3322d64435382f20697aaf5a3e2a..77ada38e93bba4181a4791729ec48ab8252949f7 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-23  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/78297
+       * gfortran.dg/pr78297.f90: New test.
+
 2016-11-23  David Edelsohn  <dje.gcc@gmail.com>
 
        * gcc.target/powerpc/builtins-3.c: Add -maltivec and -mvsx options.
diff --git a/gcc/testsuite/gfortran.dg/pr78297.f90 b/gcc/testsuite/gfortran.dg/pr78297.f90
new file mode 100644 (file)
index 0000000..9c3d1aa
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+module m
+   real :: a(2), b(2)
+   real :: c(2), d(2)
+   equivalence (a, b)
+   equivalence (c, d)
+   common /xcom/ a
+end
+block data
+   use m
+end block data