]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/24789 ([gfortran] ICE when assigning to array of strings)
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 1 Dec 2005 06:58:04 +0000 (06:58 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 1 Dec 2005 06:58:04 +0000 (06:58 +0000)
2005-12-01  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/24789
* trans-decl.c (gfc_get_symbol_decl):  Move the expression for
unit size of automatic character length, dummy pointer array
elements down a few lines from the version that fixed PR15809.

2005-12-01  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/24789
*  gfortran.dg/auto_char_dummy_array_2.f90: New test.

From-SVN: r107805

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

index f787fb76e57e028110ff5bf52eec290a4a7fafaf..f9fd567e785208529b836040f368f0bdc94eb01c 100644 (file)
@@ -1,3 +1,10 @@
+2005-12-01  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/24789
+       * trans-decl.c (gfc_get_symbol_decl):  Move the expression for
+       unit size of automatic character length, dummy pointer array
+       elements down a few lines from the version that fixed PR15809.
+
 2005-11-30  Bernhard Fischer <rep.nop@aon.at>
 
        PR fortran/21302
index 63320ae6dd443652816e2a7e3ed206b5d6b36b5e..ea127d090f8a5cdba8a4ff35964f7152d2229247 100644 (file)
@@ -847,25 +847,24 @@ gfc_get_symbol_decl (gfc_symbol * sym)
              if (TREE_CODE (length) != INTEGER_CST)
                {
                  gfc_finish_var_decl (length, sym);
-
-                 /* Set the element size of automatic character length
-                    length, dummy, pointer arrays.  */
-                 if (sym->attr.pointer && sym->attr.dummy
-                       && sym->attr.dimension)
-                   {
-                     tmp = gfc_build_indirect_ref (sym->backend_decl);
-                     etype = gfc_get_element_type (TREE_TYPE (tmp));
-                     if (TYPE_SIZE_UNIT (etype) == NULL_TREE)
-                       {
-                         tmp = TYPE_SIZE_UNIT (gfc_character1_type_node);
-                         tmp = fold_convert (TREE_TYPE (tmp), length);
-                         TYPE_SIZE_UNIT (etype) = tmp;
-                       }
-                   }
-
                  gfc_defer_symbol_init (sym);
                }
            }
+
+         /* Set the element size of automatic and assumed character length
+            length, dummy, pointer arrays.  */
+         if (sym->attr.pointer && sym->attr.dummy
+               && sym->attr.dimension)
+           {
+             tmp = gfc_build_indirect_ref (sym->backend_decl);
+             etype = gfc_get_element_type (TREE_TYPE (tmp));
+             if (TYPE_SIZE_UNIT (etype) == NULL_TREE)
+               {
+                 tmp = TYPE_SIZE_UNIT (gfc_character1_type_node);
+                 tmp = fold_convert (TREE_TYPE (tmp), sym->ts.cl->backend_decl);
+                 TYPE_SIZE_UNIT (etype) = tmp;
+               }
+           }
        }
 
       /* Use a copy of the descriptor for dummy arrays.  */
index d55401dd796d88dc0f8516feeb4c9843441138eb..d0d6b5283f8abf50a7447d05b460bec69b4b13fd 100644 (file)
@@ -1,3 +1,8 @@
+2005-12-01  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/24789
+       *  gfortran.dg/auto_char_dummy_array_2.f90: New test.
+
 2005-12-01  Uros Bizjak  <uros@kss-loka.si>
 
        PR target/24475
diff --git a/gcc/testsuite/gfortran.dg/auto_char_dummy_array_2.f90 b/gcc/testsuite/gfortran.dg/auto_char_dummy_array_2.f90
new file mode 100644 (file)
index 0000000..6664183
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! Test fix for pr24789 - would segfault on the assignment
+! because the array descriptor size was not set.
+!
+! This is the example submitted by Martin Reineke  <martin@mpa-garching.mpg.de>
+
+subroutine foo(vals)
+  character(len = *), pointer :: vals(:)
+  vals = ''
+end subroutine
+