[PATCH, fortran] Fix constant folding of VERIFY()

Steve Kargl sgk@troutmask.apl.washington.edu
Sun Mar 5 21:46:00 GMT 2006


It appears the gfortran had the conditions backwards
in the case of an empty SET (ie second argument to
verify).  For VERIFY('AB',''), gfortran returned 2
instead of 1, and in VERIFY('ABC','',.TRUE.) gfortran
would return 1 instead of 3.

I'll commit this sometime tomorrow afternoon.

2006-03-05  Steven G. Kargl  <kargls@comcast.net>

	* simplify.c (gfc_simplify_verify):  Fix return when SET=''.

	* gfortran.dg/verify_2.f90:  New test.

-- 
Steve
-------------- next part --------------
Index: simplify.c
===================================================================
--- simplify.c	(revision 111718)
+++ simplify.c	(working copy)
@@ -3759,7 +3759,7 @@ gfc_simplify_verify (gfc_expr * s, gfc_e
     {
       if (lenset == 0)
 	{
-	  mpz_set_ui (result->value.integer, len);
+	  mpz_set_ui (result->value.integer, 1);
 	  return result;
 	}
 
@@ -3773,7 +3773,7 @@ gfc_simplify_verify (gfc_expr * s, gfc_e
     {
       if (lenset == 0)
 	{
-	  mpz_set_ui (result->value.integer, 1);
+	  mpz_set_ui (result->value.integer, len);
 	  return result;
 	}
       for (index = len; index > 0; index --)
-------------- next part --------------
! { dg-do run }
program verify_2
  character(len=3) s1, s2
  s1 = 'abc'
  s2 = ''
  if (verify('ab', '') /= 1) call abort
  if (verify(s1, s2)   /= 1) call abort
  if (verify('abc', '', .true.) /= 3) call abort
  if (verify(s1, s2, .true.) /= 3) call abort
end program verify_2



More information about the Fortran mailing list