From: Paul Thomas Date: Fri, 23 Feb 2018 16:22:28 +0000 (+0000) Subject: re PR fortran/83149 ([6- and 7-branches] Missing test for sym->ns->proc_name: crash_s... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6869c12de3dacfec29bbe662904b8343831e94bd;p=gcc.git 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-decl.c (gfc_finish_var_decl): Test sym->ns->proc_name before accessing its components. 2018-02-23 Paul Thomas PR fortran/83149 * gfortran.dg/pr83149_1.f90: New test. * gfortran.dg/pr83149.f90: Additional source for previous. From-SVN: r257934 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c26c67f52ce..60469d08eaa 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-02-23 Paul Thomas + + PR fortran/83149 + * trans-decl.c (gfc_finish_var_decl): Test sym->ns->proc_name + before accessing its components. + 2018-02-23 Paul Thomas PR fortran/83148 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index c233a0ee81f..6742d2e16b0 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -609,10 +609,12 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym) function scope. */ if (current_function_decl != NULL_TREE) { - if (sym->ns->proc_name->backend_decl == current_function_decl - || sym->result == sym) + if (sym->ns->proc_name + && (sym->ns->proc_name->backend_decl == current_function_decl + || sym->result == sym)) gfc_add_decl_to_function (decl); - else if (sym->ns->proc_name->attr.flavor == FL_LABEL) + else if (sym->ns->proc_name + && sym->ns->proc_name->attr.flavor == FL_LABEL) /* This is a BLOCK construct. */ add_decl_as_local (decl); else @@ -704,7 +706,8 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym) } /* Keep variables larger than max-stack-var-size off stack. */ - if (!sym->ns->proc_name->attr.recursive && !sym->attr.automatic + if (!(sym->ns->proc_name && sym->ns->proc_name->attr.recursive) + && !sym->attr.automatic && INTEGER_CST_P (DECL_SIZE_UNIT (decl)) && !gfc_can_put_var_on_stack (DECL_SIZE_UNIT (decl)) /* Put variable length auto array pointers always into stack. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cbd0160288a..dfe208d7fdd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-02-23 Paul Thomas + + PR fortran/83149 + * gfortran.dg/pr83149_1.f90: New test. + * gfortran.dg/pr83149.f90: Additional source for previous. + 2018-02-23 Segher Boessenkool PR testsuite/80551 diff --git a/gcc/testsuite/gfortran.dg/pr83149.f90 b/gcc/testsuite/gfortran.dg/pr83149.f90 new file mode 100644 index 00000000000..fc0607e1369 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr83149.f90 @@ -0,0 +1,14 @@ +! Compiled with pr83149_1.f90 +! +module mod1 + integer :: ncells +end module + +module mod2 +contains + function get() result(array) + use mod1 + real array(ncells) + array = 1.0 + end function +end module diff --git a/gcc/testsuite/gfortran.dg/pr83149_1.f90 b/gcc/testsuite/gfortran.dg/pr83149_1.f90 new file mode 100644 index 00000000000..3a8f5d55d9b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr83149_1.f90 @@ -0,0 +1,24 @@ +! Compiled with pr83149.f90 +! { dg-do run } +! { dg-options "-fno-whole-file" } +! { dg-compile-aux-modules "pr83149.f90" } +! { dg-additional-sources pr83149.f90 } +! +! Contributed by Neil Carlson +! +subroutine sub(s) + use mod2 + real :: s + s = sum(get()) +end + + use mod1 + real :: s + ncells = 2 + call sub (s) + if (int (s) .ne. ncells) stop 1 + ncells = 10 + call sub (s) + if (int (s) .ne. ncells) stop 2 +end +