]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/69544 (Internal compiler error with -Wall and where)
authorThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 6 Nov 2016 20:30:31 +0000 (20:30 +0000)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 6 Nov 2016 20:30:31 +0000 (20:30 +0000)
2016-11-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

Backport from trunk
PR fortran/69544
PR fortran/78178
* gfortran.dg/where_5.f90:  New test.
* gfortran.dg/where_6.f90:  New test.

2016-11-06  Thomas Koenig  <tkoenig@gcc.gnu.org>

Backport from trunk
PR fortran/69544
PR fortran/78178
* match.c (match_simple_where):  Fill in locus for assigment
in simple WHERE statement.
(gfc_match_where):  Likewise.

From-SVN: r241886

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

index 0cb900e9e92084ab0b917634aeb7225cc8ad5644..17e1d00326472042cbf2e7f948e1e7b2505d2d0b 100644 (file)
@@ -1,3 +1,12 @@
+2016-11-06  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       Backport from trunk
+       PR fortran/69544
+       PR fortran/78178
+       * match.c (match_simple_where):  Fill in locus for assigment
+       in simple WHERE statement.
+       (gfc_match_where):  Likewise.
+
 2016-11-01  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        Backport from trunk
index 7262b399a07d6876cc4828c80ff34a24c2144400..c32eef7881d6d8d890ed7a7c525d7298ca50fd69 100644 (file)
@@ -5930,6 +5930,7 @@ match_simple_where (void)
 
   c->next = XCNEW (gfc_code);
   *c->next = new_st;
+  c->next->loc = gfc_current_locus;
   gfc_clear_new_st ();
 
   new_st.op = EXEC_WHERE;
@@ -5986,8 +5987,12 @@ gfc_match_where (gfc_statement *st)
   c = gfc_get_code (EXEC_WHERE);
   c->expr1 = expr;
 
+  /* Put in the assignment.  It will not be processed by add_statement, so we
+     need to copy the location here. */
+
   c->next = XCNEW (gfc_code);
   *c->next = new_st;
+  c->next->loc = gfc_current_locus;
   gfc_clear_new_st ();
 
   new_st.op = EXEC_WHERE;
index ddabb4a264bf9e840329fc2f4d07b1e8930a3599..79afa96bd386ed990ebabf41f94134aab8dae946 100644 (file)
@@ -1,3 +1,11 @@
+2016-11-06  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       Backport from trunk
+       PR fortran/69544
+       PR fortran/78178
+       * gfortran.dg/where_5.f90:  New test.
+       * gfortran.dg/where_6.f90:  New test.
+
 2016-11-05  Martin Sebor  <msebor@redhat.com>
 
        Backport from trunk.
diff --git a/gcc/testsuite/gfortran.dg/where_5.f90 b/gcc/testsuite/gfortran.dg/where_5.f90
new file mode 100644 (file)
index 0000000..5ada63d
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! { dg-options "-Wcharacter-truncation" }
+subroutine where_ice (i,j)
+     
+  implicit none
+
+  character(8)  :: y(10,10,2)
+
+  integer       :: i
+  integer       :: j
+
+  character(12) :: txt(5)
+  where (txt(1:3) /= ''   )  y(1:3,i,j) = txt(1:3) ! { dg-warning "CHARACTER expression will be truncated" }
+
+end subroutine where_ice
diff --git a/gcc/testsuite/gfortran.dg/where_6.f90 b/gcc/testsuite/gfortran.dg/where_6.f90
new file mode 100644 (file)
index 0000000..c7c43db
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! { dg-options "-Wcharacter-truncation" }
+subroutine where_ice (i,j)
+     
+  implicit none
+
+  character(8)  :: y(10,10,2)
+
+  integer       :: i
+  integer       :: j
+
+  character(12) :: txt(5)
+  if (.true.) where (txt(1:3) /= ''   )  y(1:3,i,j) = txt(1:3) ! { dg-warning "CHARACTER expression will be truncated" }
+
+end subroutine where_ice