public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55593] New: Bogus error on passing DO LOOP variable
@ 2012-12-04 13:10 sfilippone at uniroma2 dot it
  2012-12-04 14:50 ` [Bug fortran/55593] [4.8 Regression] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: sfilippone at uniroma2 dot it @ 2012-12-04 13:10 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55593

             Bug #: 55593
           Summary: Bogus error on passing DO LOOP variable
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sfilippone@uniroma2.it
                CC: tkoenig@gcc.gnu.org


Created attachment 28877
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28877
test case

Hi, 
I get the following bogus error:
=========================================================================== 
[sfilippo@localhost bug34]$ gfortran -v 
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/local/gnu48/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/usr/local/gnu48
--enable-languages=c,c++,fortran --with-gmp=/home/travel/GCC/BUILDS/gmp
--with-mpfr=/home/travel/GCC/BUILDS/mpfr --with-mpc=/home/travel/GCC/BUILDS/mpc
: (reconfigured) ../gcc/configure --prefix=/usr/local/gnu48
--enable-languages=c,c++,fortran --with-gmp=/home/travel/GCC/BUILDS/gmp
--with-mpfr=/home/travel/GCC/BUILDS/mpfr --with-mpc=/home/travel/GCC/BUILDS/mpc
: (reconfigured) ../gcc/configure --prefix=/usr/local/gnu48
--with-gmp=/home/travel/GCC/BUILDS/gmp --with-mpfr=/home/travel/GCC/BUILDS/mpfr
--with-mpc=/home/travel/GCC/BUILDS/mpc --enable-languages=c,c++,fortran,lto
--no-create --no-recursion
Thread model: posix
gcc version 4.8.0 20121204 (experimental) (GCC) 
[sfilippo@localhost bug34]$ gfortran -c bug34.f90 
bug34.f90:95.21:

    call loc_to_glob(i,idx,desc_a,info)
                     1
bug34.f90:94.14:

  do i=1, nrow
              2
Error: Variable 'i' at (1) not definable inside loop beginning at (2) as
INTENT(INOUT) argument to subroutine 'loc_to_glob'

===========================================================

The error is bogus because the proper specific subroutine should be
"loc_to_glob2s" and it gets I as the actual argument corresponding to an
INTENT(IN) dummy (x).

The compiler appears to be confused by the generic name being the same as one
of the specifics; indeed, if I change the second specific name to
"loc_to_glob1v" on line 49, the error goes away. Note that having one of the
specific names the same as the generic is allowed by the standard. 
(even though it's not a very good idea, and I'll probably change it anyway)

This sure looks like having been caused by the fix for PR30146.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/55593] [4.8 Regression] Bogus error on passing DO LOOP variable
  2012-12-04 13:10 [Bug fortran/55593] New: Bogus error on passing DO LOOP variable sfilippone at uniroma2 dot it
@ 2012-12-04 14:50 ` burnus at gcc dot gnu.org
  2012-12-06 22:02 ` tkoenig at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-12-04 14:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55593

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |diagnostic, rejects-valid
   Last reconfirmed|                            |2012-12-04
                 CC|                            |burnus at gcc dot gnu.org
     Ever Confirmed|0                           |1
            Summary|Bogus error on passing DO   |[4.8 Regression] Bogus
                   |LOOP variable               |error on passing DO LOOP
                   |                            |variable
   Target Milestone|---                         |4.8.0

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-12-04 14:49:14 UTC ---
>From frontend-passes.c's doloop_code

    case EXEC_CALL:
      f = co->symtree->n.sym->formal;

I think one should use in this case
  co->value.function.esym

I believe co->value.function.* should always exist, given that it comes after
resolution (if not, the symtree can be used as fall back). In any case, one
needs to be careful if it isn't an "isym" instead.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/55593] [4.8 Regression] Bogus error on passing DO LOOP variable
  2012-12-04 13:10 [Bug fortran/55593] New: Bogus error on passing DO LOOP variable sfilippone at uniroma2 dot it
  2012-12-04 14:50 ` [Bug fortran/55593] [4.8 Regression] " burnus at gcc dot gnu.org
@ 2012-12-06 22:02 ` tkoenig at gcc dot gnu.org
  2012-12-09  9:15 ` tkoenig at gcc dot gnu.org
  2012-12-09  9:17 ` tkoenig at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-12-06 22:02 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55593

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-12-06 22:02:01 UTC ---
(In reply to comment #1)
> From frontend-passes.c's doloop_code
> 
>     case EXEC_CALL:
>       f = co->symtree->n.sym->formal;
> 
> I think one should use in this case
>   co->value.function.esym
> 
> I believe co->value.function.* should always exist,

Not for a subroutine call ;-)

The following patch seems to work:

Index: frontend-passes.c
===================================================================
--- frontend-passes.c   (Revision 193793)
+++ frontend-passes.c   (Arbeitskopie)
@@ -1277,8 +1277,12 @@ doloop_code (gfc_code **c, int *walk_subtrees ATTR
       break;

     case EXEC_CALL:
-      f = co->symtree->n.sym->formal;

+      if (co->resolved_sym == NULL)
+       break;
+
+      f = co->resolved_sym->formal;
+
       /* Withot a formal arglist, there is only unknown INTENT,
         which we don't check for.  */
       if (f == NULL)

> given that it comes after
> resolution (if not, the symtree can be used as fall back). In any case, one
> needs to be careful if it isn't an "isym" instead.

This is checked for in the code already.

I could not come up with a test case which fails for a function, so I don't
think this regression also applies to generic function calls.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/55593] [4.8 Regression] Bogus error on passing DO LOOP variable
  2012-12-04 13:10 [Bug fortran/55593] New: Bogus error on passing DO LOOP variable sfilippone at uniroma2 dot it
  2012-12-04 14:50 ` [Bug fortran/55593] [4.8 Regression] " burnus at gcc dot gnu.org
  2012-12-06 22:02 ` tkoenig at gcc dot gnu.org
@ 2012-12-09  9:15 ` tkoenig at gcc dot gnu.org
  2012-12-09  9:17 ` tkoenig at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-12-09  9:15 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55593

--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-12-09 09:15:42 UTC ---
Author: tkoenig
Date: Sun Dec  9 09:15:36 2012
New Revision: 194329

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194329
Log:
2012-12-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/55593
    * frontend-passes.c (doloop_code):  Use resolved_sym
    instead of n.sym->formal for formal argument list
    to get the correct version for all generic subroutines.

2012-12-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

    PR fortran/55593
    * gfortran.dg/do_check_8.f90:  New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/do_check_8.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/frontend-passes.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/55593] [4.8 Regression] Bogus error on passing DO LOOP variable
  2012-12-04 13:10 [Bug fortran/55593] New: Bogus error on passing DO LOOP variable sfilippone at uniroma2 dot it
                   ` (2 preceding siblings ...)
  2012-12-09  9:15 ` tkoenig at gcc dot gnu.org
@ 2012-12-09  9:17 ` tkoenig at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-12-09  9:17 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55593

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-12-09 09:17:07 UTC ---
Fixed on trunk, closing.

Thanks a lot for the bug report!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-12-09  9:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-04 13:10 [Bug fortran/55593] New: Bogus error on passing DO LOOP variable sfilippone at uniroma2 dot it
2012-12-04 14:50 ` [Bug fortran/55593] [4.8 Regression] " burnus at gcc dot gnu.org
2012-12-06 22:02 ` tkoenig at gcc dot gnu.org
2012-12-09  9:15 ` tkoenig at gcc dot gnu.org
2012-12-09  9:17 ` tkoenig at gcc dot gnu.org

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).