]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/88902 (ICE: Segmentation fault (in DFS::DFS_write_tree_body))
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:28:22 +0000 (13:28 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:28:22 +0000 (13:28 +0200)
Backported from mainline
2019-01-19  Jakub Jelinek  <jakub@redhat.com>

PR fortran/88902
* trans-decl.c (gfc_get_symbol_decl): Don't add length to function
or parent function if it has been added there already.

* gfortran.dg/pr88902.f90: New test.

From-SVN: r275088

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

index 478a95c5900dfcf734103866edff9cd247317558..60effb3f86e7f0484a449a15dc55f7b2d0467f37 100644 (file)
@@ -1,6 +1,12 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-01-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/88902
+       * trans-decl.c (gfc_get_symbol_decl): Don't add length to function
+       or parent function if it has been added there already.
+
        2018-12-07  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/88377
index ba9fde9161c881e320c9f2a6b7d5d4d95019cff5..b266a8efee3a3bf2a8c56772c0b44b4947c06501 100644 (file)
@@ -1598,13 +1598,17 @@ gfc_get_symbol_decl (gfc_symbol * sym)
          if (VAR_P (length) && DECL_FILE_SCOPE_P (length))
            {
              /* Add the string length to the same context as the symbol.  */
-             if (DECL_CONTEXT (sym->backend_decl) == current_function_decl)
-               gfc_add_decl_to_function (length);
-             else
-               gfc_add_decl_to_parent_function (length);
+             if (DECL_CONTEXT (length) == NULL_TREE)
+               {
+                 if (DECL_CONTEXT (sym->backend_decl)
+                     == current_function_decl)
+                   gfc_add_decl_to_function (length);
+                 else
+                   gfc_add_decl_to_parent_function (length);
+               }
 
-             gcc_assert (DECL_CONTEXT (sym->backend_decl) ==
-                           DECL_CONTEXT (length));
+             gcc_assert (DECL_CONTEXT (sym->backend_decl)
+                         == DECL_CONTEXT (length));
 
              gfc_defer_symbol_init (sym);
            }
index 253f7c5e8cecd34b480802827e7d0ca64909c5f3..7f228b8e7a84dc6a21e0fe39f08e9a4fdedcaef6 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-01-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/88902
+       * gfortran.dg/pr88902.f90: New test.
+
        2019-01-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/88870
diff --git a/gcc/testsuite/gfortran.dg/pr88902.f90 b/gcc/testsuite/gfortran.dg/pr88902.f90
new file mode 100644 (file)
index 0000000..9e99b1b
--- /dev/null
@@ -0,0 +1,6 @@
+! PR fortran/88902
+! { dg-do compile }
+! { dg-require-effective-target lto }
+! { dg-options "-flto --param ggc-min-heapsize=0" }
+
+include 'pr50069_2.f90'