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] PR41940 - allocating scalars with shape


gcc/fortran:
2009-12-06  Daniel Franke  <franke.daniel@gmail.com>

        PR fortran/41940
	* match.c (gfc_match_allocate): Improved error message for
	allocatable scalars that are allocated with a shape.

gcc/testsuite:
2009-12-06  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/41940
	* gfortran.dg/allocate_scalar_with_shape.f90: New.


Regression tested on i686-pc-linux-gnu. Ok for trunk?

Cheers

	Daniel
! { dg-do "compile" }
! PR fortran/41940

integer, allocatable :: a
TYPE :: x
  integer, allocatable :: a
END TYPE
TYPE (x) :: y

allocate(a(4))     ! { dg-error "Shape specifiation for allocatable scalar" }
allocate(y%a(4))   ! { dg-error "Shape specifiation for allocatable scalar" }
end

Index: match.c
===================================================================
--- match.c	(revision 155020)
+++ match.c	(working copy)
@@ -2502,6 +2502,12 @@ gfc_match_allocate (void)
 	  goto cleanup;
 	}
 
+      if (gfc_peek_ascii_char () == '(' && !sym->attr.dimension)
+	{
+	  gfc_error ("Shape specifiation for allocatable scalar at %C");
+	  goto cleanup;
+	}
+
       if (gfc_match_char (',') != MATCH_YES)
 	break;
 

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