From 2cf76fe5fe8a2efdd5f4fe4ff879e7ee31850afd Mon Sep 17 00:00:00 2001 From: dfranke Date: Mon, 7 Dec 2009 17:32:29 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155049 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/match.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/allocate_scalar_with_shape.f90 | 13 +++++++++++++ 4 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/allocate_scalar_with_shape.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9d0506e1d53..49f6b8fb691 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 9e76818badc..c67427cbf14 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 edd2b462065..da73c1ef4a4 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 00000000000..1f4f9d52a2e --- /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 + -- 2.11.0