public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Paul Richard Thomas" <paul.richard.thomas@gmail.com>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
	 	"gcc-patches List" <gcc-patches@gcc.gnu.org>
Subject: [Patch, fortran] PR32613 - [4.3 regression] Different results depending on unnecessary variable declaration
Date: Wed, 04 Jul 2007 22:49:00 -0000	[thread overview]
Message-ID: <339c37f20707041329y24b811a6wab1f9a3508d4ad1e@mail.gmail.com> (raw)

[-- 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

                 reply	other threads:[~2007-07-04 20:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=339c37f20707041329y24b811a6wab1f9a3508d4ad1e@mail.gmail.com \
    --to=paul.richard.thomas@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).