* [PATCH, Fortran] Re-fix PR 31292
@ 2009-08-29 0:31 Steve Kargl
2009-08-29 0:42 ` Jerry DeLisle
2009-08-31 15:22 ` Tobias Burnus
0 siblings, 2 replies; 7+ messages in thread
From: Steve Kargl @ 2009-08-29 0:31 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 432 bytes --]
The attached patch was built and regression tested
on x86_64-*-freebsd. This patch partially un-fixes
the patch applied to fix PR fortran/31292. I've
re-open that PR to track this change.
2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
* gfortran.dg/module_procedure_1.f90: New test.
2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
* fortran/decl.c: Module procedure can appear in PROGRAM and
subprogram scope.
--
Steve
[-- Attachment #2: modproc.diff --]
[-- Type: text/x-diff, Size: 2088 bytes --]
Index: gcc/testsuite/gfortran.dg/module_procedure_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/module_procedure_1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/module_procedure_1.f90 (revision 0)
@@ -0,0 +1,53 @@
+! { dg-do run }
+! Modified program from http://groups.google.com/group/\
+! comp.lang.fortran/browse_frm/thread/423e4392dc965ab7#
+!
+module myoperator
+ contains
+ function dadd(arg1,arg2)
+ integer ::dadd(2)
+ integer, intent(in) :: arg1(2), arg2(2)
+ dadd(1)=arg1(1)+arg2(1)
+ dadd(2)=arg1(2)+arg2(2)
+ end function dadd
+end module myoperator
+
+program test_interface
+
+ use myoperator
+
+ implicit none
+
+ interface operator (.myadd.)
+ module procedure dadd
+ end interface
+
+ integer input1(2), input2(2), mysum(2)
+
+ input1 = (/0,1/)
+ input2 = (/3,3/)
+ mysum = input1 .myadd. input2
+ if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort
+
+ call test_sub(input1, input2)
+
+end program test_interface
+
+subroutine test_sub(input1, input2)
+
+ use myoperator
+
+ implicit none
+
+ interface operator (.myadd.)
+ module procedure dadd
+ end interface
+
+ integer, intent(in) :: input1(2), input2(2)
+ integer mysum(2)
+
+ mysum = input1 .myadd. input2
+ if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort
+
+end subroutine test_sub
+! { dg-final { cleanup-modules "myoperator" } }
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 151144)
+++ gcc/fortran/decl.c (working copy)
@@ -6481,7 +6481,10 @@ gfc_match_modproc (void)
module_ns = gfc_current_ns->parent;
for (; module_ns; module_ns = module_ns->parent)
- if (module_ns->proc_name->attr.flavor == FL_MODULE)
+ if (module_ns->proc_name->attr.flavor == FL_MODULE
+ || module_ns->proc_name->attr.flavor == FL_PROGRAM
+ || (module_ns->proc_name->attr.flavor == FL_PROCEDURE
+ && !module_ns->proc_name->attr.contained))
break;
if (module_ns == NULL)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH, Fortran] Re-fix PR 31292
2009-08-29 0:31 [PATCH, Fortran] Re-fix PR 31292 Steve Kargl
@ 2009-08-29 0:42 ` Jerry DeLisle
2009-09-10 21:22 ` Steve Kargl
2009-08-31 15:22 ` Tobias Burnus
1 sibling, 1 reply; 7+ messages in thread
From: Jerry DeLisle @ 2009-08-29 0:42 UTC (permalink / raw)
To: Steve Kargl; +Cc: fortran, gcc-patches
Steve Kargl wrote:
> The attached patch was built and regression tested
> on x86_64-*-freebsd. This patch partially un-fixes
> the patch applied to fix PR fortran/31292. I've
> re-open that PR to track this change.
ok if passes regression testing
Jerry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH, Fortran] Re-fix PR 31292
2009-08-29 0:31 [PATCH, Fortran] Re-fix PR 31292 Steve Kargl
2009-08-29 0:42 ` Jerry DeLisle
@ 2009-08-31 15:22 ` Tobias Burnus
2009-08-31 22:55 ` Steve Kargl
2009-09-10 21:26 ` Steve Kargl
1 sibling, 2 replies; 7+ messages in thread
From: Tobias Burnus @ 2009-08-31 15:22 UTC (permalink / raw)
To: Steve Kargl; +Cc: fortran, gcc-patches
Am 28.08.2009 23:34, schrieb Steve Kargl:
> 2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
>
> * gfortran.dg/module_procedure_1.f90: New test.
>
> 2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
>
> * fortran/decl.c: Module procedure can appear in PROGRAM and
> subprogram scope.
>
I think your patch is OK, however, one needs to add a bit more to fully
fix the problem, see test case below.
Tobias
module m
contains
subroutine modSub()
end subroutine modSub
end module m
use m
implicit none
intrinsic sin
interface gen2
module procedure sin ! Invalid per C1208, but not detected
! procedure sin ! OK - valid and accepted
end interface gen2
interface gen
module procedure modSub ! OK (valid and now accepted)
module procedure intSub ! Invalid per C1208, gives
! misleading error "INTERNAL-PROC procedure at (1) is already
! declared as MODULE-PROC procedure"
! procedure intSub ! OK - valid and accepted
end interface
contains
subroutine intSub(a)
integer :: a
end subroutine intSub
end
C1208 (R1206) If MODULE appears in a procedure-stmt, each procedure-name
in that statement shall be accessible in the current scope as a
module procedure.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH, Fortran] Re-fix PR 31292
2009-08-31 15:22 ` Tobias Burnus
@ 2009-08-31 22:55 ` Steve Kargl
2009-08-31 23:08 ` Steve Kargl
2009-09-10 21:26 ` Steve Kargl
1 sibling, 1 reply; 7+ messages in thread
From: Steve Kargl @ 2009-08-31 22:55 UTC (permalink / raw)
To: Tobias Burnus; +Cc: fortran, gcc-patches
On Mon, Aug 31, 2009 at 08:00:10AM +0200, Tobias Burnus wrote:
> Am 28.08.2009 23:34, schrieb Steve Kargl:
> > 2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
> >
> > * gfortran.dg/module_procedure_1.f90: New test.
> >
> > 2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
> >
> > * fortran/decl.c: Module procedure can appear in PROGRAM and
> > subprogram scope.
> >
>
> I think your patch is OK, however, one needs to add a bit more to fully
> fix the problem, see test case below.
>
I'll hold off on committing my patch until I investigate
some the issues you point out below.
> module m
> contains
> subroutine modSub()
> end subroutine modSub
> end module m
>
> use m
> implicit none
> intrinsic sin
If the above explicit 'intrinsic sin' statement is missing, then ...
> interface gen2
> module procedure sin ! Invalid per C1208, but not detected
is this still invalid? I would assume the answer is "yes"
because sin is implicitly given the intrinsic attribute.
>
> C1208 (R1206) If MODULE appears in a procedure-stmt, each procedure-name
> in that statement shall be accessible in the current scope as a
> module procedure.
--
Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH, Fortran] Re-fix PR 31292
2009-08-31 22:55 ` Steve Kargl
@ 2009-08-31 23:08 ` Steve Kargl
0 siblings, 0 replies; 7+ messages in thread
From: Steve Kargl @ 2009-08-31 23:08 UTC (permalink / raw)
To: Tobias Burnus; +Cc: fortran, gcc-patches
On Mon, Aug 31, 2009 at 02:58:18PM -0700, Steve Kargl wrote:
> On Mon, Aug 31, 2009 at 08:00:10AM +0200, Tobias Burnus wrote:
> > Am 28.08.2009 23:34, schrieb Steve Kargl:
> > > 2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
> > >
> > > * gfortran.dg/module_procedure_1.f90: New test.
> > >
> > > 2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
> > >
> > > * fortran/decl.c: Module procedure can appear in PROGRAM and
> > > subprogram scope.
> > >
> >
> > I think your patch is OK, however, one needs to add a bit more to fully
> > fix the problem, see test case below.
> >
>
> I'll hold off on committing my patch until I investigate
> some the issues you point out below.
>
> > module m
> > contains
> > subroutine modSub()
> > end subroutine modSub
> > end module m
> >
> > use m
> > implicit none
> > intrinsic sin
>
> If the above explicit 'intrinsic sin' statement is missing, then ...
>
> > interface gen2
> > module procedure sin ! Invalid per C1208, but not detected
>
> is this still invalid? I would assume the answer is "yes"
> because sin is implicitly given the intrinsic attribute.
>
> >
> > C1208 (R1206) If MODULE appears in a procedure-stmt, each procedure-name
> > in that statement shall be accessible in the current scope as a
> > module procedure.
>
How's this
troutmask:sgk[213] gfc4x -c t2.f90
t2.f90:8.23:
module procedure sin ! Invalid per C1208, but not detected
1
Error: Intrinsic procedure at (1) cannot be a MODULE PROCEDURE
--
Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH, Fortran] Re-fix PR 31292
2009-08-29 0:42 ` Jerry DeLisle
@ 2009-09-10 21:22 ` Steve Kargl
0 siblings, 0 replies; 7+ messages in thread
From: Steve Kargl @ 2009-09-10 21:22 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 924 bytes --]
On Fri, Aug 28, 2009 at 02:50:13PM -0700, Jerry DeLisle wrote:
> Steve Kargl wrote:
> >The attached patch was built and regression tested
> >on x86_64-*-freebsd. This patch partially un-fixes
> >the patch applied to fix PR fortran/31292. I've
> >re-open that PR to track this change.
> ok if passes regression testing
>
Here's the patch that I've committed.
2009-09-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/31292
* gfortran.dg/module_procedure_1.f90: New test.
* gfortran.dg/module_procedure_2.f90: Ditto.
* gfortran.dg/generic_14.f90: Move dg-error to new location.
2009-09-10 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/31292
* fortran/decl.c(gfc_match_modproc): Check that module procedures
from a module can USEd in module procedure statements in other
program units. Update locus for better error message display.
Detect intrinsic procedures in module procedure statements.
--
Steve
[-- Attachment #2: modproc2.diff --]
[-- Type: text/x-diff, Size: 4191 bytes --]
Index: testsuite/gfortran.dg/module_procedure_2.f90
===================================================================
--- testsuite/gfortran.dg/module_procedure_2.f90 (revision 0)
+++ testsuite/gfortran.dg/module_procedure_2.f90 (revision 0)
@@ -0,0 +1,8 @@
+! { dg-do compile }
+program test
+ implicit none
+ intrinsic sin
+ interface gen2
+ module procedure sin ! { dg-error "cannot be a MODULE PROCEDURE" }
+ end interface gen2
+end program test
Index: testsuite/gfortran.dg/module_procedure_1.f90
===================================================================
--- testsuite/gfortran.dg/module_procedure_1.f90 (revision 0)
+++ testsuite/gfortran.dg/module_procedure_1.f90 (revision 0)
@@ -0,0 +1,53 @@
+! { dg-do run }
+! Modified program from http://groups.google.com/group/\
+! comp.lang.fortran/browse_frm/thread/423e4392dc965ab7#
+!
+module myoperator
+ contains
+ function dadd(arg1,arg2)
+ integer ::dadd(2)
+ integer, intent(in) :: arg1(2), arg2(2)
+ dadd(1)=arg1(1)+arg2(1)
+ dadd(2)=arg1(2)+arg2(2)
+ end function dadd
+end module myoperator
+
+program test_interface
+
+ use myoperator
+
+ implicit none
+
+ interface operator (.myadd.)
+ module procedure dadd
+ end interface
+
+ integer input1(2), input2(2), mysum(2)
+
+ input1 = (/0,1/)
+ input2 = (/3,3/)
+ mysum = input1 .myadd. input2
+ if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort
+
+ call test_sub(input1, input2)
+
+end program test_interface
+
+subroutine test_sub(input1, input2)
+
+ use myoperator
+
+ implicit none
+
+ interface operator (.myadd.)
+ module procedure dadd
+ end interface
+
+ integer, intent(in) :: input1(2), input2(2)
+ integer mysum(2)
+
+ mysum = input1 .myadd. input2
+ if (mysum(1) /= 3 .and. mysum(2) /= 4) call abort
+
+end subroutine test_sub
+! { dg-final { cleanup-modules "myoperator" } }
Index: testsuite/gfortran.dg/generic_14.f90
===================================================================
--- testsuite/gfortran.dg/generic_14.f90 (revision 151602)
+++ testsuite/gfortran.dg/generic_14.f90 (working copy)
@@ -85,18 +85,18 @@ end module f
module g
implicit none
- external wrong_b ! { dg-error "has no explicit interface" }
+ external wrong_b
interface gen_wrong_5
- module procedure wrong_b ! wrong, see above
+ module procedure wrong_b ! { dg-error "has no explicit interface" }
end interface gen_wrong_5
end module g
module h
implicit none
- external wrong_c ! { dg-error "has no explicit interface" }
+ external wrong_c
real wrong_c
interface gen_wrong_6
- module procedure wrong_c ! wrong, see above
+ module procedure wrong_c ! { dg-error "has no explicit interface" }
end interface gen_wrong_6
end module h
Index: fortran/decl.c
===================================================================
--- fortran/decl.c (revision 151602)
+++ fortran/decl.c (working copy)
@@ -6485,7 +6485,10 @@ gfc_match_modproc (void)
module_ns = gfc_current_ns->parent;
for (; module_ns; module_ns = module_ns->parent)
- if (module_ns->proc_name->attr.flavor == FL_MODULE)
+ if (module_ns->proc_name->attr.flavor == FL_MODULE
+ || module_ns->proc_name->attr.flavor == FL_PROGRAM
+ || (module_ns->proc_name->attr.flavor == FL_PROCEDURE
+ && !module_ns->proc_name->attr.contained))
break;
if (module_ns == NULL)
@@ -6497,6 +6500,7 @@ gfc_match_modproc (void)
for (;;)
{
+ locus old_locus = gfc_current_locus;
bool last = false;
m = gfc_match_name (name);
@@ -6517,6 +6521,13 @@ gfc_match_modproc (void)
if (gfc_get_symbol (name, module_ns, &sym))
return MATCH_ERROR;
+ if (sym->attr.intrinsic)
+ {
+ gfc_error ("Intrinsic procedure at %L cannot be a MODULE "
+ "PROCEDURE", &old_locus);
+ return MATCH_ERROR;
+ }
+
if (sym->attr.proc != PROC_MODULE
&& gfc_add_procedure (&sym->attr, PROC_MODULE,
sym->name, NULL) == FAILURE)
@@ -6526,6 +6537,7 @@ gfc_match_modproc (void)
return MATCH_ERROR;
sym->attr.mod_proc = 1;
+ sym->declared_at = old_locus;
if (last)
break;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH, Fortran] Re-fix PR 31292
2009-08-31 15:22 ` Tobias Burnus
2009-08-31 22:55 ` Steve Kargl
@ 2009-09-10 21:26 ` Steve Kargl
1 sibling, 0 replies; 7+ messages in thread
From: Steve Kargl @ 2009-09-10 21:26 UTC (permalink / raw)
To: Tobias Burnus; +Cc: fortran, gcc-patches
On Mon, Aug 31, 2009 at 08:00:10AM +0200, Tobias Burnus wrote:
> Am 28.08.2009 23:34, schrieb Steve Kargl:
> > 2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
> >
> > * gfortran.dg/module_procedure_1.f90: New test.
> >
> > 2009-08-28 Steven G. Kargl <kargl@gcc.gnu.org>
> >
> > * fortran/decl.c: Module procedure can appear in PROGRAM and
> > subprogram scope.
> >
>
> I think your patch is OK, however, one needs to add a bit more to fully
> fix the problem, see test case below.
>
> Tobias
>
> module m
> contains
> subroutine modSub()
> end subroutine modSub
> end module m
>
> use m
> implicit none
> intrinsic sin
> interface gen2
> module procedure sin ! Invalid per C1208, but not detected
> ! procedure sin ! OK - valid and accepted
> end interface gen2
The patch and one of the testcases that I committed now
catches the C1208 problem mentioned above.
> interface gen
> module procedure modSub ! OK (valid and now accepted)
> module procedure intSub ! Invalid per C1208, gives
> ! misleading error "INTERNAL-PROC procedure at (1) is already
> ! declared as MODULE-PROC procedure"
> ! procedure intSub ! OK - valid and accepted
> end interface
> contains
> subroutine intSub(a)
> integer :: a
> end subroutine intSub
> end
I did not try to fix this problem because it can't lead to
wrong-code. That is, an error message is generated although
it is somewhat difficult to untangle its meaning. If you
feel strongly that this needs some additional attention, then
submit a new PR.
--
Steve
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-09-10 21:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-29 0:31 [PATCH, Fortran] Re-fix PR 31292 Steve Kargl
2009-08-29 0:42 ` Jerry DeLisle
2009-09-10 21:22 ` Steve Kargl
2009-08-31 15:22 ` Tobias Burnus
2009-08-31 22:55 ` Steve Kargl
2009-08-31 23:08 ` Steve Kargl
2009-09-10 21:26 ` Steve Kargl
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).