]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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 22:48:54 +0000 (22:48 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Wed, 23 Nov 2016 22:48:54 +0000 (22:48 +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: r242811

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

index c39d134f15f4a96b050f6b34fc1eae023149fb4d..4931f51c8076264091ea89194d7f4c2d5e9c2bef 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  Janus Weil  <janus@gcc.gnu.org>
 
        Backport from trunk
index 509f18bf6390d7b73c23bead62714bdea4ea1d5d..f393419db5ef5f0d107600f540493bef3aa08afc 100644 (file)
@@ -1247,8 +1247,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 9c1ca2e21bda953aa15bab084d8de2226485a029..af3dc9839c7551d739e571de403e0a8af9ccaf3e 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  Janus Weil  <janus@gcc.gnu.org>
 
        Backport from trunk
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