This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran PR 33626] Make sure parenthesized expression is correctly typed



I've committed the attached patch for this buglet as r129002. FX tested it with a --enable-checking=types compiler and approved it in bugzilla. I built and tested it on i386-darwin.


The patch simply makes sure that the types of parenthesized expressions are always propagated, as they should.

Cheers,
- Tobi
2007-10-04  Tobias Schlüter  <tobi@gcc.gnu.org>

	PR fortran/33626
fortran/
	* resolve.c (resolve_operator): Always copy the type for
	expressions in parentheses.
testsuite/
	* gfortran.dg/parens_6.f90: New.

Index: gcc/testsuite/gfortran.dg/parens_6.f90
===================================================================
--- gcc/testsuite/gfortran.dg/parens_6.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/parens_6.f90	(revision 0)
@@ -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
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 129001)
+++ gcc/fortran/resolve.c	(working copy)
@@ -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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]