]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/54225 (fortran compiler segfault processing ' print *, A(1,*) ')
authorTobias Burnus <burnus@gcc.gnu.org>
Wed, 12 Sep 2012 10:05:19 +0000 (12:05 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Wed, 12 Sep 2012 10:05:19 +0000 (12:05 +0200)
2012-09-12  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-12  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: r191213

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 f0e6cad64650c047535c2eab88b1240408fb360b..45f1c9fd48d94339290bfd89a92100a837836c02 100644 (file)
@@ -1,3 +1,10 @@
+2012-09-12  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-07  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/54208
index 07fecd8aaf387dcb1075922c1ed2d3d7b9a5aab7..44ec72eb87c58a17210d04ed4943d8cc89962ee7 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;
 
@@ -255,6 +253,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 04d912b4b7a68bfb110683765bb7bd4db6c47ba2..a72e8efcdc651a32cf78ab69cc729c61264dc6af 100644 (file)
@@ -1,3 +1,11 @@
+2012-09-12  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-11  Christophe Lyon  <christophe.lyon@linaro.org>
 
        gcc/testsuite/
 
 2012-09-11  Marc Glisse  <marc.glisse@inria.fr>
 
-        * gcc.dg/tree-ssa/forwprop-22.c: New testcase.
+       * gcc.dg/tree-ssa/forwprop-22.c: New testcase.
 
 2012-09-11  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
-           Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>
-
-       * gcc.target/arm/neon-vfma-1.c: New testcase.
-       * gcc.target/arm/neon-vfms-1.c: Likewise.
-       * gcc.target/arm/neon-vmla-1.c: Update test to use int instead
-       of float.
-       * gcc.target/arm/neon-vmls-1.c: Likewise.
-       * lib/target-supports.exp (add_options_for_arm_neonv2): New
-       function.
-       (check_effective_target_arm_neonv2_ok_nocache): Likewise.
-       (check_effective_target_arm_neonv2_ok): Likewise.
-       (check_effective_target_arm_neonv2_hw): Likewise.
-       (check_effective_target_arm_neonv2): Likewise.
+           Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>
+
+       * gcc.target/arm/neon-vfma-1.c: New testcase.
+       * gcc.target/arm/neon-vfms-1.c: Likewise.
+       * gcc.target/arm/neon-vmla-1.c: Update test to use int instead
+       of float.
+       * gcc.target/arm/neon-vmls-1.c: Likewise.
+       * lib/target-supports.exp (add_options_for_arm_neonv2): New
+       function.
+       (check_effective_target_arm_neonv2_ok_nocache): Likewise.
+       (check_effective_target_arm_neonv2_ok): Likewise.
+       (check_effective_target_arm_neonv2_hw): Likewise.
+       (check_effective_target_arm_neonv2): Likewise.
 
 2012-09-11  Richard Guenther  <rguenther@suse.de>
 
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 99f5782e35b2a81ecd279cd3ddbb94be8f1ae9b2..78abb5ad1912a643199fe048b58cd6537d7534f4 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" }
@@ -48,5 +48,5 @@ end subroutine rank_mismatch
 subroutine rank_mismatch2()
   implicit none
   integer, allocatable:: A(:)[:,:,:]
-  allocate(A(1)[7:8,4:*]) ! { dg-error "Unexpected .*. for codimension 2 of 3" }
+  allocate(A(1)[7:8,4:*]) ! { dg-error "Too few codimensions" }
 end subroutine rank_mismatch2
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