This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] PR41940 - allocating scalars with shape
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 6 Dec 2009 15:13:25 +0100
- Subject: [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;