From: Daniel Franke Date: Mon, 7 Dec 2009 17:32:29 +0000 (-0500) Subject: re PR fortran/41940 (Improve error message for allocating scalar with shape) X-Git-Tag: releases/gcc-4.5.0~1754 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d59b1dcb19d9d8c6b69d00463ab7b4f5d5cd45a6;p=thirdparty%2Fgcc.git re PR fortran/41940 (Improve error message for allocating scalar with shape) gcc/fortran: 2009-12-07 Daniel Franke PR fortran/41940 * match.c (gfc_match_allocate): Improved error message for allocatable scalars that are allocated with a shape. gcc/testsuite: 2009-12-07 Daniel Franke PR fortran/41940 * gfortran.dg/allocate_scalar_with_shape.f90: New. From-SVN: r155049 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9d0506e1d53e..49f6b8fb6915 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2009-12-07 Daniel Franke + + PR fortran/41940 + * match.c (gfc_match_allocate): Improved error message for + allocatable scalars that are allocated with a shape. + 2009-12-07 Kaveh R. Ghazi PR other/40302 diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 9e76818badca..c67427cbf14a 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -2502,6 +2502,12 @@ gfc_match_allocate (void) goto cleanup; } + if (gfc_peek_ascii_char () == '(' && !sym->attr.dimension) + { + gfc_error ("Shape specification for allocatable scalar at %C"); + goto cleanup; + } + if (gfc_match_char (',') != MATCH_YES) break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index edd2b462065a..da73c1ef4a4b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-12-07 Daniel Franke + + PR fortran/41940 + * gfortran.dg/allocate_scalar_with_shape.f90: New. + 2009-12-07 Kaveh R. Ghazi PR other/40302 diff --git a/gcc/testsuite/gfortran.dg/allocate_scalar_with_shape.f90 b/gcc/testsuite/gfortran.dg/allocate_scalar_with_shape.f90 new file mode 100644 index 000000000000..1f4f9d52a2ee --- /dev/null +++ b/gcc/testsuite/gfortran.dg/allocate_scalar_with_shape.f90 @@ -0,0 +1,13 @@ +! { 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 specification for allocatable scalar" } +allocate(y%a(4)) ! { dg-error "Shape specification for allocatable scalar" } +end +