re PR fortran/41940 (Improve error message for allocating scalar with shape)

gcc/fortran:
2009-12-07  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-07  Daniel Franke  <franke.daniel@gmail.com>

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

From-SVN: r155049
This commit is contained in:
Daniel Franke 2009-12-07 12:32:29 -05:00 committed by Daniel Franke
parent b3a00b5034
commit d59b1dcb19
4 changed files with 30 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2009-12-07 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.
2009-12-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR other/40302

View File

@ -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;

View File

@ -1,3 +1,8 @@
2009-12-07 Daniel Franke <franke.daniel@gmail.com>
PR fortran/41940
* gfortran.dg/allocate_scalar_with_shape.f90: New.
2009-12-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR other/40302

View File

@ -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