public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/39850]  New: Too strict checking for procedures as actual argument
@ 2009-04-22 14:56 burnus at gcc dot gnu dot org
  2009-04-22 16:56 ` [Bug fortran/39850] " janus at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-04-22 14:56 UTC (permalink / raw)
  To: gcc-bugs

Issue came up when testing/rewiewing proc pointers, cf.
http://gcc.gnu.org/ml/fortran/2009-04/msg00214.html

The following program is believed to be correct and it runs with g95, NAG f95,
sunf95, openf95, and ifort, but not with gfortran:
  Error: Type/rank mismatch in argument 'a'

real function func()
 func = 42.0
end function func

program test
  external func  ! subroutine or implicitly typed real function
  call sub(func) ! Error: Type/rank mismatch in argument 'a'
contains
  subroutine sub(a)
   real, external :: a
   print *, a(0.4)
  end subroutine sub
end


-- 
           Summary: Too strict checking for procedures as actual argument
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
@ 2009-04-22 16:56 ` janus at gcc dot gnu dot org
  2009-06-20 14:12 ` janus at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-04-22 16:56 UTC (permalink / raw)
  To: gcc-bugs



-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janus at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-04-22 16:55:59
               date|                            |


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
  2009-04-22 16:56 ` [Bug fortran/39850] " janus at gcc dot gnu dot org
@ 2009-06-20 14:12 ` janus at gcc dot gnu dot org
  2009-06-20 14:41 ` janus at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-06-20 14:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from janus at gcc dot gnu dot org  2009-06-20 14:11 -------
After the improvement of error messages, the test case gives:

Error: Interface mismatch in dummy procedure 'a' at (1): 'func' is not a
function

Mine.


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |janus at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-04-22 16:55:59         |2009-06-20 14:11:51
               date|                            |


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
  2009-04-22 16:56 ` [Bug fortran/39850] " janus at gcc dot gnu dot org
  2009-06-20 14:12 ` janus at gcc dot gnu dot org
@ 2009-06-20 14:41 ` janus at gcc dot gnu dot org
  2009-06-20 15:17 ` janus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-06-20 14:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from janus at gcc dot gnu dot org  2009-06-20 14:41 -------
Btw, if comment #0 is correct, then the test case 'interface_21.f90' is wrong
(that is: the test case itself is legal, but the dg-error is wrong). It was
added by Jerry DeLisle in r129799, in connection with PR33162.


-- 


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-06-20 14:41 ` janus at gcc dot gnu dot org
@ 2009-06-20 15:17 ` janus at gcc dot gnu dot org
  2009-06-20 17:44 ` burnus at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-06-20 15:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from janus at gcc dot gnu dot org  2009-06-20 15:17 -------
(In reply to comment #2)
> Btw, if comment #0 is correct, then the test case 'interface_21.f90' is wrong

Same goes for proc_decl_8.f90.


-- 


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-06-20 15:17 ` janus at gcc dot gnu dot org
@ 2009-06-20 17:44 ` burnus at gcc dot gnu dot org
  2009-06-21 19:06 ` janus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-06-20 17:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2009-06-20 17:44 -------
Regarding comment 0: I believe the program is valid

Regarding proc_decl_8.f90 and interface_21.f90: The programs are obviously
invalid - and the error message is OK.

 * * *

In case of proc_decl_8.f90/interface_21.f90: The actual argument "foo" can only
be a SUBROUTINE as "IMPLICIT NONE; external foo" has been used, but the dummy
argument requires a FUNCTION.

That violates (12.4.1.3): "If the interface of the dummy argument is explicit,
the characteristics listed in 12.2 shall be the same for the associated actual
argument" as 12.2 has "The characteristics of a procedure are the
classification of the procedure as a function or subroutine"

 * * *

In case of comment 0: The dummy argument is a function (with an implicit
interface) and the actual argument is a procedure (with an implicit interface),
which can _either_ be a subroutine _or_ an implicitly as real typed function.

If the actual procedure is a function, this fulfilled and the program is valid.

(As the call makes clear that "func" is a function, a subsequent use of "func"
as subroutine is invalid.)

 * * *

For completeness: Passing an actual argument with an implicitly defined
interface to a procedure with has an explicit interface: That is valid as long
a) as the standard does not mandate the use of an explicit interface
b) and the procedure which is associated with the dummy argument has an
interface which is conform with the dummy.

[One has to be careful whether "actual argument" refers to the entity in the
procedure reference or the entity that is associated with the dummy argument.
They can be split as in the following case: When the dummy is not a pointer:
Here, the entity used in the procedure reference can be a pointer, but the
entity associated with the dummy is then not the pointer but the target of the
pointer (cf. p.473 in The Fortran 2003 Handbook).
Something related applies here: The entity associated with the dummy argument
needs to have a conforming interface, but the entity used in the procedure
reference can have an implicit interface.]


-- 


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-06-20 17:44 ` burnus at gcc dot gnu dot org
@ 2009-06-21 19:06 ` janus at gcc dot gnu dot org
  2009-06-21 19:16 ` janus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-06-21 19:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from janus at gcc dot gnu dot org  2009-06-21 19:05 -------
Subject: Bug 39850

Author: janus
Date: Sun Jun 21 19:05:35 2009
New Revision: 148767

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148767
Log:
2009-06-21  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/39850
        * interface.c (gfc_compare_interfaces): Take care of implicit typing
        when checking the function attribute. Plus another bugfix.
        (compare_parameter): Set attr.function and attr.subroutine according
        to the usage of a procedure as actual argument.


2009-06-21  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/39850
        * gfortran.dg/interface_19.f90: Add 'cleanup-modules'.
        * gfortran.dg/interface_20.f90: Ditto.
        * gfortran.dg/interface_21.f90: Ditto.
        * gfortran.dg/interface_22.f90: Ditto.
        * gfortran.dg/interface_30.f90: New.
        * gfortran.dg/proc_ptr_11.f90: Fix invalid test case.


Added:
    trunk/gcc/testsuite/gfortran.dg/interface_30.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/interface_19.f90
    trunk/gcc/testsuite/gfortran.dg/interface_20.f90
    trunk/gcc/testsuite/gfortran.dg/interface_21.f90
    trunk/gcc/testsuite/gfortran.dg/interface_22.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_11.f90


-- 


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-06-21 19:06 ` janus at gcc dot gnu dot org
@ 2009-06-21 19:16 ` janus at gcc dot gnu dot org
  2009-06-22  8:29 ` dominiq at lps dot ens dot fr
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-06-21 19:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from janus at gcc dot gnu dot org  2009-06-21 19:16 -------
Fixed with r148767. Closing.


-- 

janus at gcc dot gnu dot org changed:

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


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2009-06-21 19:16 ` janus at gcc dot gnu dot org
@ 2009-06-22  8:29 ` dominiq at lps dot ens dot fr
  2009-06-22  9:04 ` janus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-06-22  8:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from dominiq at lps dot ens dot fr  2009-06-22 08:28 -------
At revision 148777, compiling the code in comment #0 gives:

[ibook-dhum] f90/bug% gfc pr39850.f90
pr39850.f90: In function 'test':
pr39850.f90:12:0: internal compiler error: in gfc_typenode_for_spec, at
fortran/trans-types.c:995


-- 


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2009-06-22  8:29 ` dominiq at lps dot ens dot fr
@ 2009-06-22  9:04 ` janus at gcc dot gnu dot org
  2009-06-22 14:18 ` dominiq at lps dot ens dot fr
  2009-06-22 21:03 ` janus at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-06-22  9:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from janus at gcc dot gnu dot org  2009-06-22 09:04 -------

> pr39850.f90:12:0: internal compiler error: in gfc_typenode_for_spec, at
> fortran/trans-types.c:995

Yeah, the same happens for the examples in PR37254. I didn't notice it before,
since I changed the test case slightly in my commit. Here is a patch which
fixes it:

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c     (revision 148778)
+++ gcc/fortran/interface.c     (working copy)
@@ -1407,9 +1407,14 @@
        }

       if (formal->attr.function && !act_sym->attr.function)
-       gfc_add_function (&act_sym->attr, act_sym->name,
&act_sym->declared_at);
-
-      if (formal->attr.subroutine && !act_sym->attr.subroutine)
+       {
+         gfc_add_function (&act_sym->attr, act_sym->name,
+         &act_sym->declared_at);
+         if (act_sym->ts.type == BT_UNKNOWN
+             && gfc_set_default_type (act_sym, 1, act_sym->ns) == FAILURE)
+           return 0;
+       }
+      else if (formal->attr.subroutine && !act_sym->attr.subroutine)
        gfc_add_subroutine (&act_sym->attr, act_sym->name,
                            &act_sym->declared_at);


-- 


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2009-06-22  9:04 ` janus at gcc dot gnu dot org
@ 2009-06-22 14:18 ` dominiq at lps dot ens dot fr
  2009-06-22 21:03 ` janus at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-06-22 14:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from dominiq at lps dot ens dot fr  2009-06-22 14:17 -------
The patch in comment #8 fixes the ICEs reported in comment #7 and #8.

> Yeah, the same happens for the examples in PR37254.

I also so it, but I preferred to report against this pr.

Thanks for the quick patch.


-- 


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


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

* [Bug fortran/39850] Too strict checking for procedures as actual argument
  2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2009-06-22 14:18 ` dominiq at lps dot ens dot fr
@ 2009-06-22 21:03 ` janus at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-06-22 21:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from janus at gcc dot gnu dot org  2009-06-22 21:02 -------
Subject: Bug 39850

Author: janus
Date: Mon Jun 22 21:02:19 2009
New Revision: 148816

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148816
Log:
2009-06-22  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/37254
        PR fortran/39850
        * interface.c (compare_parameter): Set implicit type for function
        actual arguments with BT_UNKNOWN.


2009-06-22  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/37254
        PR fortran/39850
        * gfortran.dg/interface_30.f90: Modified error message.
        * gfortran.dg/proc_decl_22.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/proc_decl_22.f90   (with props)
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/interface_30.f90

Propchange: trunk/gcc/testsuite/gfortran.dg/proc_decl_22.f90
            ('svn:executable' added)


-- 


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


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

end of thread, other threads:[~2009-06-22 21:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-22 14:56 [Bug fortran/39850] New: Too strict checking for procedures as actual argument burnus at gcc dot gnu dot org
2009-04-22 16:56 ` [Bug fortran/39850] " janus at gcc dot gnu dot org
2009-06-20 14:12 ` janus at gcc dot gnu dot org
2009-06-20 14:41 ` janus at gcc dot gnu dot org
2009-06-20 15:17 ` janus at gcc dot gnu dot org
2009-06-20 17:44 ` burnus at gcc dot gnu dot org
2009-06-21 19:06 ` janus at gcc dot gnu dot org
2009-06-21 19:16 ` janus at gcc dot gnu dot org
2009-06-22  8:29 ` dominiq at lps dot ens dot fr
2009-06-22  9:04 ` janus at gcc dot gnu dot org
2009-06-22 14:18 ` dominiq at lps dot ens dot fr
2009-06-22 21:03 ` janus at gcc dot gnu dot 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).