re PR fortran/83149 ([6- and 7-branches] Missing test for sym->ns->proc_name: crash_s...
authorPaul Thomas <pault@gcc.gnu.org>
Fri, 23 Feb 2018 17:55:13 +0000 (17:55 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Fri, 23 Feb 2018 17:55:13 +0000 (17:55 +0000)
2018-02-23  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/83149
* trans-types.c (gfc_sym_type): Test sym->ns->proc_name before
accessing its components.

2018-02-23  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/83149
* gfortran.dg/pr83149_b.f90: New test.
* gfortran.dg/pr83149_a.f90: Additional source for previous.

From-SVN: r257938

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

index 60469d08eaacb2a560434f4a7a6222f4c067bf52..528d294b4e167cdb5df3e245bc4be1ec1b6d0b70 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-23  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/83149
+       * trans-types.c (gfc_sym_type): Test sym->ns->proc_name before
+       accessing its components.
+
 2018-02-23  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/83149
index 697b7354e1bd3ded76384d37bed52340fa11890a..20de203e6074fbb8e1ef0d1944f1af47988400cd 100644 (file)
@@ -2251,6 +2251,7 @@ gfc_sym_type (gfc_symbol * sym)
   if (sym->attr.result
       && sym->ts.type == BT_CHARACTER
       && sym->ts.u.cl->backend_decl == NULL_TREE
+      && sym->ns->proc_name
       && sym->ns->proc_name->ts.u.cl->backend_decl != NULL_TREE)
     sym->ts.u.cl->backend_decl = sym->ns->proc_name->ts.u.cl->backend_decl;
 
index 6cfcb116742292979925812d41489491c23c28ef..d68abc56b0630a1a9cf9bff8539c1d2bfe3348a6 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-23  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/83149
+       * gfortran.dg/pr83149_b.f90: New test.
+       * gfortran.dg/pr83149_a.f90: Additional source for previous.
+
 2018-02-23  Carl Love  <cel@us.ibm.com>
 
        * gcc.target/powerpc/builtins-3-runnable.c: Move tests for vec_float2,
diff --git a/gcc/testsuite/gfortran.dg/pr83149_a.f90 b/gcc/testsuite/gfortran.dg/pr83149_a.f90
new file mode 100644 (file)
index 0000000..3f15198
--- /dev/null
@@ -0,0 +1,11 @@
+! Compiled with pr83149_b.f90
+!
+module mod
+  character(8) string
+contains
+  function get_string() result(s)
+    character(len_trim(string)) s
+    s = string
+  end function
+end module
+
diff --git a/gcc/testsuite/gfortran.dg/pr83149_b.f90 b/gcc/testsuite/gfortran.dg/pr83149_b.f90
new file mode 100644 (file)
index 0000000..f67ffd9
--- /dev/null
@@ -0,0 +1,16 @@
+! Compiled with pr83149_a.f90
+! { dg-do run }
+! { dg-options "-fno-whole-file" }
+! { dg-compile-aux-modules "pr83149_a.f90" }
+! { dg-additional-sources pr83149_a.f90 }
+!
+! Contributed by Neil Carlson  <neil.n.carlson@gmail.com>
+!
+  use mod
+  string = 'fubar'
+  select case (get_string())
+    case ('fubar')
+    case default
+      stop 1
+  end select
+end