From 1996c75efdf29aad3f9910207cc900ff621748ba Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Fri, 23 Feb 2018 17:55:13 +0000 Subject: [PATCH] re PR fortran/83149 ([6- and 7-branches] Missing test for sym->ns->proc_name: crash_signal in toplev.c:325) 2018-02-23 Paul Thomas PR fortran/83149 * trans-types.c (gfc_sym_type): Test sym->ns->proc_name before accessing its components. 2018-02-23 Paul Thomas 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 | 6 ++++++ gcc/fortran/trans-types.c | 1 + gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/pr83149_a.f90 | 11 +++++++++++ gcc/testsuite/gfortran.dg/pr83149_b.f90 | 16 ++++++++++++++++ 5 files changed, 40 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr83149_a.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr83149_b.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 60469d08eaa..528d294b4e1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-02-23 Paul Thomas + + PR fortran/83149 + * trans-types.c (gfc_sym_type): Test sym->ns->proc_name before + accessing its components. + 2018-02-23 Paul Thomas PR fortran/83149 diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index 697b7354e1b..20de203e607 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6cfcb116742..d68abc56b06 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-02-23 Paul Thomas + + PR fortran/83149 + * gfortran.dg/pr83149_b.f90: New test. + * gfortran.dg/pr83149_a.f90: Additional source for previous. + 2018-02-23 Carl Love * 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 index 00000000000..3f15198bfe9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr83149_a.f90 @@ -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 index 00000000000..f67ffd95159 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr83149_b.f90 @@ -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 +! + use mod + string = 'fubar' + select case (get_string()) + case ('fubar') + case default + stop 1 + end select +end -- 2.30.2