gcc/fortran:
authordfranke <dfranke@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Dec 2009 17:32:29 +0000 (17:32 +0000)
committerdfranke <dfranke@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Dec 2009 17:32:29 +0000 (17:32 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155049 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/allocate_scalar_with_shape.f90 [new file with mode: 0644]

index 9d0506e..49f6b8f 100644 (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
index 9e76818..c67427c 100644 (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;
 
index edd2b46..da73c1e 100644 (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
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 (file)
index 0000000..1f4f9d5
--- /dev/null
@@ -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
+