public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR32613 - [4.3 regression] Different results depending on unnecessary variable declaration
@ 2007-07-04 22:49 Paul Richard Thomas
  0 siblings, 0 replies; only message in thread
From: Paul Richard Thomas @ 2007-07-04 22:49 UTC (permalink / raw)
  To: fortran, gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]

:ADDPATCH fortran:

This is another regression that I set off.  I take it to be urgent,
since it came up on comp.lang.fortran.

The PR and the patch speak for themselves. The testcase is the reporter's.

Regtested on Cygwin_NT/amd64.

I will commit this at the same time as PR32526, as obvious, unless
there are any objections overnight.

Now to get on with the character patches that I promised I would:-)

Paul

PS I realise that I am telling a lie.  The PR and the patch do not
speak for temselves completely.  I should have said that the do-loop
index in the contained function 'internal' was the cause of the
trouble, since it was getting labeled as an implicit do loop iterator
variable. This led the reference to 'i' in the call of the statement
function to generate a local declaration.

2007-07-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/32613
	* match.c (gfc_match_do): Reset the implied_index attribute.

2007-07-04  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/32613
	* gfortran.dg/do_iterator_2.f90: New test.

[-- Attachment #2: pr32613.diff --]
[-- Type: application/octet-stream, Size: 1551 bytes --]

Index: gcc/fortran/match.c
===================================================================
*** gcc/fortran/match.c	(revision 126318)
--- gcc/fortran/match.c	(working copy)
*************** gfc_match_do (void)
*** 1500,1505 ****
--- 1500,1506 ----
    if (m == MATCH_ERROR)
      goto cleanup;
  
+   iter.var->symtree->n.sym->attr.implied_index = 0;
    gfc_check_do_variable (iter.var->symtree);
  
    if (gfc_match_eos () != MATCH_YES)
Index: gcc/testsuite/gfortran.dg/do_iterator_2.f90
===================================================================
*** gcc/testsuite/gfortran.dg/do_iterator_2.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/do_iterator_2.f90	(revision 0)
***************
*** 0 ****
--- 1,32 ----
+ ! { dg-do run }
+ ! Tests the fix for pr32613 - see:
+ ! http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/495c154ee188d7f1/ea292134fe68b1d0#ea292134fe68b1d0
+ !
+ ! Contributed by Al Greynolds <awgreynolds@earthlink.net>
+ !
+ program main
+   call something
+ end
+ 
+ subroutine something
+ !  integer i !correct results from gfortran depend on this statement (before fix)
+   integer :: m = 0
+   character lit*1, line*100
+   lit(i) = line(i:i)
+   i = 1
+   n = 5
+   line = 'PZ0R1'
+   if (internal (0)) call abort ()
+   if (m .ne. 5) call abort ()
+ contains
+   logical function internal (j)
+     intent(in) j
+     do i = j, n
+       k = index ('RE', lit (i))
+       m = m + 1
+       if (k == 0) cycle
+       if (i+1 == n) exit
+     enddo
+     internal = (k == 0)
+   end function
+ end

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-07-04 20:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-04 22:49 [Patch, fortran] PR32613 - [4.3 regression] Different results depending on unnecessary variable declaration Paul Richard Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).