This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran] PR39334 - recursive parameter declaration


This is a simple fix for something of a corner case.  The error
message is not the best but it should more than suffice.

Bootstrapped and regtested on FC9/x86_64 - OK for 4.5?

Paul

2009-03-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39334
	* primary.c (match_kind_param): Return MATCH_NO if the symbol
	has no value.

2009-03-01  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/39334
	* gfortran.dg/recursive_parameter_1.f90: New test.
Index: gcc/testsuite/gfortran.dg/recursive_parameter_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/recursive_parameter_1.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/recursive_parameter_1.f90	(revision 0)
@@ -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
Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c	(revision 144448)
+++ gcc/fortran/primary.c	(working copy)
@@ -57,6 +57,9 @@
   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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]