]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/54225 (fortran compiler segfault processing ' print *, A(1,*) ')
authorTobias Burnus <burnus@net-b.de>
Thu, 13 Sep 2012 18:19:22 +0000 (20:19 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 13 Sep 2012 18:19:22 +0000 (20:19 +0200)
2012-09-13  Tobias Burnus  <burnus@net-b.de>

        PR fortran/54225
        PR fortran/53306
        * array.c (match_subscript, gfc_match_array_ref): Fix
        diagnostic of coarray's '*'.

2012-09-13  Tobias Burnus  <burnus@net-b.de>

        PR fortran/54225
        PR fortran/53306
        * gfortran.dg/coarray_10.f90: Update dg-error.
        * gfortran.dg/coarray_28.f90: New.
        * gfortran.dg/array_section_3.f90: New.

From-SVN: r191277

gcc/fortran/ChangeLog
gcc/fortran/array.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/array_section_3.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/coarray_10.f90
gcc/testsuite/gfortran.dg/coarray_28.f90 [new file with mode: 0644]

index 9dcc9a38f5a96d13e7dac70d17d66a27c59e6fd7..bbe781294f849c60b4ef795a569914a68ebeb185 100644 (file)
@@ -1,3 +1,10 @@
+2012-09-13  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/54225
+       PR fortran/53306
+       * array.c (match_subscript, gfc_match_array_ref): Fix
+       diagnostic of coarray's '*'.
+
 2012-09-13  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54556
index 8d431f2f7476d0c045f89f67a91e79f31b78cb95..a5ad7507e0f6fa3307b753ae29ed9cec002d1af1 100644 (file)
@@ -91,9 +91,7 @@ match_subscript (gfc_array_ref *ar, int init, bool match_star)
   else if (!star)
     m = gfc_match_expr (&ar->start[i]);
 
-  if (m == MATCH_NO && gfc_match_char ('*') == MATCH_YES)
-    return MATCH_NO;
-  else if (m == MATCH_NO)
+  if (m == MATCH_NO)
     gfc_error ("Expected array subscript at %C");
   if (m != MATCH_YES)
     return MATCH_ERROR;
@@ -224,7 +222,7 @@ coarray:
 
   for (ar->codimen = 0; ar->codimen + ar->dimen < GFC_MAX_DIMENSIONS; ar->codimen++)
     {
-      m = match_subscript (ar, init, ar->codimen == (corank - 1));
+      m = match_subscript (ar, init, true);
       if (m == MATCH_ERROR)
        return MATCH_ERROR;
 
@@ -249,6 +247,13 @@ coarray:
            gfc_error ("Invalid form of coarray reference at %C");
          return MATCH_ERROR;
        }
+      else if (ar->dimen_type[ar->codimen + ar->dimen] == DIMEN_STAR)
+       {
+         gfc_error ("Unexpected '*' for codimension %d of %d at %C",
+                    ar->codimen + 1, corank);
+         return MATCH_ERROR;
+       }
+
       if (ar->codimen >= corank)
        {
          gfc_error ("Invalid codimension %d at %C, only %d codimensions exist",
index 9228d323428abd09f21a78c1f621eb5e2d8ae797..52de1f5acca8ea1ff3001a9f82fb43ea320bae14 100644 (file)
@@ -1,3 +1,11 @@
+2012-09-13  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/54225
+       PR fortran/53306
+       * gfortran.dg/coarray_10.f90: Update dg-error.
+       * gfortran.dg/coarray_28.f90: New.
+       * gfortran.dg/array_section_3.f90: New.
+
 2012-09-13  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54556
diff --git a/gcc/testsuite/gfortran.dg/array_section_3.f90 b/gcc/testsuite/gfortran.dg/array_section_3.f90
new file mode 100644 (file)
index 0000000..d3093d1
--- /dev/null
@@ -0,0 +1,17 @@
+! { dg-do compile }
+!
+! PR fortran/54225
+!
+! Contributed by robb wu
+!
+program test
+  implicit none
+  real :: A(2,3)
+
+  print *, A(1, *)  ! { dg-error "Expected array subscript" }
+end program
+
+subroutine test2
+integer, dimension(2) :: a
+a(*) = 1  ! { dg-error "Expected array subscript" }
+end
index 6ee425d7bf98d6bdcec8e1e75cc83505a71669b6..61cafa9265ddfa2d835e62b9678dadbc81dacf54 100644 (file)
@@ -30,12 +30,12 @@ end subroutine this_image_check
 subroutine rank_mismatch()
   implicit none
   integer,allocatable :: A(:)[:,:,:,:]
-  allocate(A(1)[1,1,1:*])     ! { dg-error "Unexpected ... for codimension" }
+  allocate(A(1)[1,1,1:*])     ! { dg-error "Too few codimensions" }
   allocate(A(1)[1,1,1,1,1,*]) ! { dg-error "Invalid codimension 5" }
   allocate(A(1)[1,1,1,*])
   allocate(A(1)[1,1])     ! { dg-error "Too few codimensions" }
   allocate(A(1)[1,*])     ! { dg-error "Too few codimensions" }
-  allocate(A(1)[1,1:*])   ! { dg-error "Unexpected ... for codimension" }
+  allocate(A(1)[1,1:*])   ! { dg-error "Too few codimensions" }
 
   A(1)[1,1,1] = 1       ! { dg-error "Too few codimensions" }
   A(1)[1,1,1,1,1,1] = 1 ! { dg-error "Invalid codimension 5" }
diff --git a/gcc/testsuite/gfortran.dg/coarray_28.f90 b/gcc/testsuite/gfortran.dg/coarray_28.f90
new file mode 100644 (file)
index 0000000..ca6f863
--- /dev/null
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+! PR fortran/54225
+!
+
+integer, allocatable :: a[:,:]
+
+allocate (a[*,4]) ! { dg-error "Unexpected '.' for codimension 1 of 2" }
+end