From 1d8e1d5d9f87473eb7cae2c3b4109beeb87ce3da Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Fri, 10 Jul 2009 04:37:19 +0000 Subject: [PATCH] re PR fortran/39334 (Recusive parameter kind produces segfault) 2009-07-10 Paul Thomas PR fortran/39334 * primary.c (match_kind_param): Return MATCH_NO if the symbol has no value. 2009-07-10 Paul Thomas PR fortran/39334 * gfortran.dg/recursive_parameter_1.f90: New test. From-SVN: r149456 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/primary.c | 3 +++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/recursive_parameter_1.f90 | 11 +++++++++++ 4 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/recursive_parameter_1.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5b1ed772829..20894cb2870 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2009-07-10 Paul Thomas + + PR fortran/39334 + * primary.c (match_kind_param): Return MATCH_NO if the symbol + has no value. + 2008-07-09 Paul Thomas PR fortran/40629 diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 4a84aedbc30..8013cc86d1e 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -57,6 +57,9 @@ match_kind_param (int *kind) if (sym->attr.flavor != FL_PARAMETER) return MATCH_NO; + if (sym->value == NULL) + return MATCH_NO; + p = gfc_extract_int (sym->value, kind); if (p != NULL) return MATCH_NO; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 333544c0fd1..48711da3da0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-07-10 Paul Thomas + + PR fortran/39334 + * gfortran.dg/recursive_parameter_1.f90: New test. + 2009-07-09 Steven G. Kargl * gfortran.dg/c_kind_tests_2.f03: clean-up leftover module(s). diff --git a/gcc/testsuite/gfortran.dg/recursive_parameter_1.f90 b/gcc/testsuite/gfortran.dg/recursive_parameter_1.f90 new file mode 100644 index 00000000000..8a13d254f49 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/recursive_parameter_1.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! Tests the fix for PR39334 in which the recursive parameter declaration +! caused a sgfault. +! +! Reported by James van Buskirk on comp.lang.fortran +! +program recursive_parameter + implicit none + integer, parameter :: dp = kind(1.0_dp) ! { dg-error "Missing kind-parameter" } + write(*,*) dp ! { dg-error "has no IMPLICIT type" } +end program recursive_parameter -- 2.30.2