[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 kargl at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED Target Milestone|--- |6.5 --- Comment #18 from kargl at gcc dot gnu.org --- Fixed on 6-branch, 7-branch, and trunk.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #17 from kargl at gcc dot gnu.org --- Author: kargl Date: Mon Feb 12 18:25:41 2018 New Revision: 257596 URL: https://gcc.gnu.org/viewcvs?rev=257596=gcc=rev Log: 2018-02-12 Steven G. KarglPR fortran/54223 PR fortran/84276 * interface.c (compare_actual_formal): Add in_statement_function bool parameter. Skip check of INTENT attribute for statement functions. Arguments to a statement function cannot be optional, issue error for missing argument. (gfc_procedure_use, gfc_ppc_use, gfc_arglist_matches_symbol): Use in_statement_function. 2018-02-12 Steven G. Kargl PR fortran/54223 PR fortran/84276 * gfortran.dg/statement_function_1.f90: New test. * gfortran.dg/statement_function_2.f90: New test. Added: branches/gcc-6-branch/gcc/testsuite/gfortran.dg/statement_function_1.f90 branches/gcc-6-branch/gcc/testsuite/gfortran.dg/statement_function_2.f90 Modified: branches/gcc-6-branch/gcc/fortran/ChangeLog branches/gcc-6-branch/gcc/fortran/interface.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #16 from kargl at gcc dot gnu.org --- Author: kargl Date: Mon Feb 12 18:04:33 2018 New Revision: 257593 URL: https://gcc.gnu.org/viewcvs?rev=257593=gcc=rev Log: 2018-02-12 Steven G. KarglPR fortran/54223 PR fortran/84276 * interface.c (compare_actual_formal): Add in_statement_function bool parameter. Skip check of INTENT attribute for statement functions. Arguments to a statement function cannot be optional, issue error for missing argument. (gfc_procedure_use, gfc_ppc_use, gfc_arglist_matches_symbol): Use in_statement_function. 2018-02-12 Steven G. Kargl PR fortran/54223 PR fortran/84276 * gfortran.dg/statement_function_1.f90: New test. * gfortran.dg/statement_function_2.f90: New test. Added: branches/gcc-7-branch/gcc/testsuite/gfortran.dg/statement_function_1.f90 branches/gcc-7-branch/gcc/testsuite/gfortran.dg/statement_function_2.f90 Modified: branches/gcc-7-branch/gcc/fortran/ChangeLog branches/gcc-7-branch/gcc/fortran/interface.c branches/gcc-7-branch/gcc/testsuite/ChangeLog
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #15 from kargl at gcc dot gnu.org --- Author: kargl Date: Sun Feb 11 18:44:05 2018 New Revision: 257565 URL: https://gcc.gnu.org/viewcvs?rev=257565=gcc=rev Log: 2018-02-11 Steven G. KarglPR fortran/54223 PR fortran/84276 * interface.c (compare_actual_formal): Add in_statement_function bool parameter. Skip check of INTENT attribute for statement functions. Arguments to a statement function cannot be optional, issue error for missing argument. (gfc_procedure_use, gfc_ppc_use, gfc_arglist_matches_symbol): Use in_statement_function. 2018-02-11 Steven G. Kargl PR fortran/54223 PR fortran/84276 * gfortran.dg/statement_function_1.f90: New test. * gfortran.dg/statement_function_2.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/statement_function_1.f90 trunk/gcc/testsuite/gfortran.dg/statement_function_2.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/interface.c trunk/gcc/testsuite/ChangeLog
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #14 from Steve Kargl --- On Sat, Feb 10, 2018 at 02:20:20AM +, mecej4 at outlook dot com wrote: > > Will keyword arguments in statement function references be retained as a GNU > extension? > The extension will remain, but I intend to hope a new bug report about the issue.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #13 from mecej4 --- Thanks for locating the relevant clauses. With your extracts serving as a roadmap, I can find essentially the same wording in F2003, but with different numbers for rules and constraints, in section 12.4. R1217 function-reference is procedure-designator ( [ actual-arg-spec-list ] ) C1220 (R1217) The procedure-designator shall designate a function. R1220 actual-arg-spec is [ keyword = ] actual-arg C1225 (R1220) The keyword = shall not appear if the interface of the procedure is implicit in the 9 scoping unit. It struck me as odd that, since statement functions were marked "obsolescent" even in F95, references to them would be given features that were not available in F77, such as keyword arguments. Will keyword arguments in statement function references be retained as a GNU extension?
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #12 from Steve Kargl --- On Fri, Feb 09, 2018 at 09:15:00PM +, mecej4 at outlook dot com wrote: > > > > I cannot find a prohibition in F2018 standard. > > AFAICT, gfortran always supported keywords, and > > I've developed a patch to retain that behavior. > > I cannot find an explicit prohibition, either, but please consider these > related statements from F2003: > I found where the prohibition occurs in F95, F2003, and F2018. If you want to get a headache, read F2018, 15.5. It's a little convoluted to chase down all the terms because of the wonderful OOP language, but one has R1520 function-reference is procedure-designator ( [ actual-arg-spec-list ] ) C1523 (R1520) The procedure-designator shall designate a function. ... R1523 actual-arg-spec is [ keyword = ] actual-arg ... C1530 (R1523) The 'keyword =' shall not appear if the interface of the procedure is implicit. The first thing to chase down is 'procedure' in C1530 means 'function or subroutine'. Then one needs to chase down that 'function' means 'function (in a Fortran subprogram sense) or statement function.'
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #11 from Steve Kargl --- On Fri, Feb 09, 2018 at 09:15:00PM +, mecej4 at outlook dot com wrote: > --- Comment #10 from mecej4 --- > (In reply to Steve Kargl from comment #9) > > On Fri, Feb 09, 2018 at 01:52:03PM +, mecej4 at outlook dot com wrote: > > > (In reply to Steve Kargl from comment #7) > > > > ... > > > > w = qofs(i = i, s = hh) > > > > ... > > > > > > Keyword argument lists are not allowed for statement > > > functions, are they? I realize that the compiler will > > > have to detect and flag attempts to use keyword > > > arguments as disallowed, but no code generation is needed. > > > > I cannot find a prohibition in F2018 standard. > > AFAICT, gfortran always supported keywords, and > > I've developed a patch to retain that behavior. > > I cannot find an explicit prohibition, either, but please consider > these related statements from F2003: > > Section 12.3.1: ..."The interface of a statement function is always > implicit". Yep, I found that. > Section 12.3.1.1: ..."A procedure other than a statement function > shall have an explicit interface if it is referenced and a reference > to the procedure appears with an argument keyword" Yep, I found that, too. This contains requirements for procedures that aren't statement functions. As a statement functions is an exception and a compiler builds its interface at compile time, I do not see why the standard would prohibit the use of keywords. Although I don't recall ever seeing a bug report about keywords and statement functions, over the years, I have come to expect that users can find new and unique ways to break gfortran. My patch is keeping gfortran's historical behavior. A side benefit is that an additional line of code fixes PR 54223. Unfortunately, getting expert input on c.l.f has become too much drama.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #10 from mecej4 --- (In reply to Steve Kargl from comment #9) > On Fri, Feb 09, 2018 at 01:52:03PM +, mecej4 at outlook dot com wrote: > > (In reply to Steve Kargl from comment #7) > > > ... > > > w = qofs(i = i, s = hh) > > > ... > > > > Keyword argument lists are not allowed for statement functions, are they? I > > realize that the compiler will have to detect and flag attempts to use > > keyword > > arguments as disallowed, but no code generation is needed. > > > > I cannot find a prohibition in F2018 standard. > AFAICT, gfortran always supported keywords, and > I've developed a patch to retain that behavior. I cannot find an explicit prohibition, either, but please consider these related statements from F2003: Section 12.3.1: ..."The interface of a statement function is always implicit". Section 12.3.1.1: ..."A procedure other than a statement function shall have an explicit interface if it is referenced and a reference to the procedure appears with an argument keyword" That still leaves the prohibition unstated. However, I find the following in the Fortran 2003 Handbook (Adams et al), p. 451: 14. A statement function is referenced in the same manner as any other function, except that because statement function interfaces are implicit, the keyword form of actual arguments is not allowed; the argument association rules are the same.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #9 from Steve Kargl --- On Fri, Feb 09, 2018 at 01:52:03PM +, mecej4 at outlook dot com wrote: > (In reply to Steve Kargl from comment #7) > > Ugh. Statement functions should be removed from the Standard. > > The simply fix, of course, does not work if someone is clever > > and uses keywords in a reference that involves a statement > > function. > > > > ... > > w = qofs(i = i, s = hh) > > ... > > Keyword argument lists are not allowed for statement functions, are they? I > realize that the compiler will have to detect and flag attempts to use keyword > arguments as disallowed, but no code generation is needed. > I cannot find a prohibition in F2018 standard. AFAICT, gfortran always supported keywords, and I've developed a patch to retain that behavior.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 mecej4 changed: What|Removed |Added CC||mecej4 at outlook dot com --- Comment #8 from mecej4 --- (In reply to Steve Kargl from comment #7) > Ugh. Statement functions should be removed from the Standard. > The simply fix, of course, does not work if someone is clever > and uses keywords in a reference that involves a statement > function. > > ... > w = qofs(i = i, s = hh) > ... Keyword argument lists are not allowed for statement functions, are they? I realize that the compiler will have to detect and flag attempts to use keyword arguments as disallowed, but no code generation is needed.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #7 from Steve Kargl --- Ugh. Statement functions should be removed from the Standard. The simply fix, of course, does not work if someone is clever and uses keywords in a reference that involves a statement function. subroutine step(hh, h, s, w) real, intent(inout) :: h, hh, s real, intent(out) :: w real :: qofs integer i qofs(s, i) = i * s i = 42 w = qofs(hh, i) w = qofs(i = i, s = hh) end subroutine step
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #6 from Steve Kargl --- On Thu, Feb 08, 2018 at 06:53:00PM +, kargl at gcc dot gnu.org wrote: > > I have a patch. > The patch is incomplete. If the actual and dummy arguments type and type parameter match then, everything works ok. If there is a mismatch, then we get an ICE. I'm working on it. subroutine stepns(hh,h,s,w) real, intent(inout) :: h,hh,s real, intent(out) :: w real :: qofs integer i qofs(s)=s w=qofs(hh+h) ! OK i = 42 w = qofs(i) ! Causes ICE, but should issue error. end subroutine stepns
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 kargl at gcc dot gnu.org changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |kargl at gcc dot gnu.org --- Comment #5 from kargl at gcc dot gnu.org --- I have a patch.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 Dominique d'Humieres changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2018-02-08 Ever confirmed|0 |1 Known to fail||4.3.1 --- Comment #4 from Dominique d'Humieres --- Confirmed.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 Richard Biener changed: What|Removed |Added Keywords||rejects-valid Status|NEW |UNCONFIRMED Last reconfirmed|2018-02-08 00:00:00 | Ever confirmed|1 |0
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 Dominique d'Humieres changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2018-02-08 Ever confirmed|0 |1 --- Comment #3 from Dominique d'Humieres --- Confirmed.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #2 from Steve Kargl --- On Thu, Feb 08, 2018 at 02:26:50AM +, sgk at troutmask dot apl.washington.edu wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 > > --- Comment #1 from Steve Kargl --- > Reduced testcase. > > subroutine stepns(hh,h,s,w) > real, intent(inout) :: h,hh,s > real, intent(out) :: w > real :: qofs > qofs(s)=s > w=qofs(hh+h) > end subroutine stepns > > Problem occurs with interface.c:3219. > So, the problem appears to boil down to gfortran acquiring not only the type and type parameters from the declaration statements, but also the attributes. Statement functions should not inherit the attributes.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 --- Comment #1 from Steve Kargl --- Reduced testcase. subroutine stepns(hh,h,s,w) real, intent(inout) :: h,hh,s real, intent(out) :: w real :: qofs qofs(s)=s w=qofs(hh+h) end subroutine stepns Problem occurs with interface.c:3219.
[Bug fortran/84276] Invalid error for valid statement function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84276 kargl at gcc dot gnu.org changed: What|Removed |Added Priority|P3 |P4 Known to fail||6.4.1, 7.3.1, 8.0