re PR fortran/33626 (Parentheses get wrong kind during matching)
authorTobias Schlüter <tobi@gcc.gnu.org>
Thu, 4 Oct 2007 07:34:38 +0000 (09:34 +0200)
committerTobias Schlüter <tobi@gcc.gnu.org>
Thu, 4 Oct 2007 07:34:38 +0000 (09:34 +0200)
PR fortran/33626
fortran/
* resolve.c (resolve_operator): Always copy the type for
expressions in parentheses.
testsuite/
* gfortran.dg/parens_6.f90: New.

From-SVN: r129002

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

index 327d9a5c0b17d876fb717a4d46974065a8eb71d2..0ebb27cfb2776aaa6734e64c5a3c85eb3b66c0fe 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-04  Tobias Schlüter  <tobi@gcc.gnu.org>
+
+       PR fortran/33626
+       * resolve.c (resolve_operator): Always copy the type for
+       expressions in parentheses.
+
 2007-10-04  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/33542
index 82b50a35a76eb2c2d2cffaa059b78c83a9ec8b34..82c990d9a9d9c57981e8eabff6e7cc4504504144 100644 (file)
@@ -2942,6 +2942,9 @@ resolve_operator (gfc_expr *e)
       goto bad_op;
 
     case INTRINSIC_PARENTHESES:
+      e->ts = op1->ts;
+      if (e->ts.type == BT_CHARACTER)
+       e->ts.cl = op1->ts.cl;
       break;
 
     default:
@@ -3026,14 +3029,6 @@ resolve_operator (gfc_expr *e)
       break;
 
     case INTRINSIC_PARENTHESES:
-
-      /*  This is always correct and sometimes necessary!  */
-      if (e->ts.type == BT_UNKNOWN)
-       e->ts = op1->ts;
-
-      if (e->ts.type == BT_CHARACTER && !e->ts.cl)
-       e->ts.cl = op1->ts.cl;
-
     case INTRINSIC_NOT:
     case INTRINSIC_UPLUS:
     case INTRINSIC_UMINUS:
index 6a493633916884c044500ddb2821bf274c079ba7..dc740322949c962ddceabf2a07cce7f9dd5bc0c8 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-04  Tobias Schlüter  <tobi@gcc.gnu.org>
+
+       PR fortran/33626
+       * gfortran.dg/parens_6.f90: New.
+
 2007-10-04  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/33542
diff --git a/gcc/testsuite/gfortran.dg/parens_6.f90 b/gcc/testsuite/gfortran.dg/parens_6.f90
new file mode 100644 (file)
index 0000000..5a888a6
--- /dev/null
@@ -0,0 +1,11 @@
+! { dg-do run }
+! PR fortran/33626
+! Types were not always propagated correctly
+  logical(kind=1) :: i, j
+  integer(kind=1) :: a, b
+  character*1 :: c, d
+  if (any( (/ kind(i .and. j), kind(.not. (i .and. j)), kind((a + b)), &
+              kind((42_1)), kind((j .and. i)), kind((.true._1)), &
+              kind(c // d), kind((c) // d), kind((c//d)) /) /= 1 )) call abort()
+  if (any( (/ len(c // d), len((c) // d), len ((c // d)) /) /= 2)) call abort()
+end