re PR fortran/88902 (ICE: Segmentation fault (in DFS::DFS_write_tree_body))
authorJakub Jelinek <jakub@gcc.gnu.org>
Sat, 19 Jan 2019 08:43:12 +0000 (09:43 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 19 Jan 2019 08:43:12 +0000 (09:43 +0100)
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: r268091

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

index 0d04224a71b0a3610ebfd4b6e2829f8fb5a50be8..675ce39e21b27fef4504a5d5ac7d478e39135247 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2019-01-15  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/43136
@@ -26,7 +32,7 @@
 2019-01-13  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/57992
-       * trans-array.c (gfc_conv_array_parameter):  Do not pack/unpack
+       * trans-array.c (gfc_conv_array_parameter): Do not pack/unpack
        functions with contiguous results.
 
 2019-01-13  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
 2019-01-12  Paul Thomas  <pault@gcc.gnu.org>
 
-       * gfortran.texi : Add description in sections on TS 29113 and
+       * gfortran.texi: Add description in sections on TS 29113 and
        further interoperability with C.
        * trans-array.c (gfc_conv_descriptor_attribute): New function.
        (gfc_get_dataptr_offset): Remove static function attribute.
-       * trans-array.h : Add prototypes for above functions.
-       * trans-decl.c : Add declarations for the library functions
+       * trans-array.h: Add prototypes for above functions.
+       * trans-decl.c: Add declarations for the library functions
        cfi_desc_to_gfc_desc and gfc_desc_to_cfi_desc.
        * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): New function.
        (gfc_conv_procedure_call): Call it for scalar and array actual
        arguments, when the formal arguments are bind_c with assumed
        shape or assumed rank.
-       * trans.h : External declarations for gfor_fndecl_cfi_to_gfc
+       * trans.h: External declarations for gfor_fndecl_cfi_to_gfc
        and gfor_fndecl_gfc_to_cfi.
 
 2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>
index c4cdcd681935b65f53ec7c30cb7962438222cfd5..1fe1165181612e0435c93c7a0531693f803af851 100644 (file)
@@ -1572,13 +1572,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 15abf4c6bb5565624106b92295ee07dc8d17452f..0e4a7784a5199e4760f6565f3ad43769977b3bb7 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/88902
+       * gfortran.dg/pr88902.f90: New test.
+
 2019-01-18  Martin Sebor  <msebor@redhat.com>
 
        * c-c++-common/attr-nonstring-3.c: Remove an xfail.
 
 2019-01-15  Paul Thomas  <pault@gcc.gnu.org>
 
-       * gfortran.dg/ISO_Fortran_binding_2.c : Change reference to
+       * gfortran.dg/ISO_Fortran_binding_2.c: Change reference to
        ISO_Fortran_binding_2.h.
 
 2019-01-15  Marek Polacek  <polacek@redhat.com>
 
 2019-01-12  Paul Thomas  <pault@gcc.gnu.org>
 
-       * gfortran.dg/ISO_Fortran_binding_2.f90 : Remove because of
+       * gfortran.dg/ISO_Fortran_binding_2.f90: Remove because of
        reports of ICEs.
-       * gfortran.dg/ISO_Fortran_binding_2.c : Ditto.
+       * gfortran.dg/ISO_Fortran_binding_2.c: Ditto.
 
 2019-01-12  Paul Thomas  <pault@gcc.gnu.org>
 
-       * gfortran.dg/ISO_Fortran_binding_1.f90 : New test.
-       * gfortran.dg/ISO_Fortran_binding_1.c : Auxilliary file for test.
-       * gfortran.dg/ISO_Fortran_binding_2.f90 : New test.
-       * gfortran.dg/ISO_Fortran_binding_2.c : Auxilliary file for test.
-       * gfortran.dg/bind_c_array_params_2.f90 : Change search string
+       * gfortran.dg/ISO_Fortran_binding_1.f90: New test.
+       * gfortran.dg/ISO_Fortran_binding_1.c: Auxilliary file for test.
+       * gfortran.dg/ISO_Fortran_binding_2.f90: New test.
+       * gfortran.dg/ISO_Fortran_binding_2.c: Auxilliary file for test.
+       * gfortran.dg/bind_c_array_params_2.f90: Change search string
        for dump tree scan.
 
 2019-01-11  Steven G. Kargl  <kargl@gcc.gnu.org>
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'