* [Patch, Fortran, F03] PROCEDURE w/ interface: Bogus "EXTERNAL attribute conflicts with FUNCTION attribute"
@ 2012-07-16 9:09 Janus Weil
2012-07-16 9:23 ` Tobias Burnus
0 siblings, 1 reply; 3+ messages in thread
From: Janus Weil @ 2012-07-16 9:09 UTC (permalink / raw)
To: gfortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]
Hi all,
the attached patch is the solution that I came up with for this PR
(after two simpler but wrong attempts, see PR). The issue addressed
here is the setting of the if_source attribute for dummy procedures.
When declaring a procedure (pointer) with the PROCEDURE statement, the
attributes of the dummies (including if_source) should be copied from
the source interface (cf. gfc_copy_formal_args).
The patch was successfully regtested on x86_64-unknown-linux-gnu. Ok for trunk?
Cheers,
Janus
2012-07-16 Janus Weil <janus@gcc.gnu.org>
PR fortran/53956
* gfortran.h (gfc_copy_formal_args,gfc_copy_formal_args_ppc): Modified
prototypes.
* symbol.c (gfc_copy_formal_args): New argument 'if_src'. Copy if_source
of dummy procedures.
(gfc_copy_formal_args_ppc): Ditto.
* resolve.c (resolve_procedure_interface): Pass IFSRC_DECL to
gfc_copy_formal_args.
(resolve_fl_derived0): Pass IFSRC_DECL to gfc_copy_formal_args_ppc.
2012-07-16 Janus Weil <janus@gcc.gnu.org>
PR fortran/53956
* gfortran.dg/proc_decl_28.f90: New.
[-- Attachment #2: pr53956_v3.diff --]
[-- Type: application/octet-stream, Size: 4412 bytes --]
Index: gcc/fortran/symbol.c
===================================================================
--- gcc/fortran/symbol.c (revision 189470)
+++ gcc/fortran/symbol.c (working copy)
@@ -4049,8 +4049,7 @@ gen_shape_param (gfc_formal_arglist **head,
reference to the list of formal arguments). */
static void
-add_proc_interface (gfc_symbol *sym, ifsrc source,
- gfc_formal_arglist *formal)
+add_proc_interface (gfc_symbol *sym, ifsrc source, gfc_formal_arglist *formal)
{
sym->formal = formal;
@@ -4066,7 +4065,7 @@ static void
args based on the args of a given named interface. */
void
-gfc_copy_formal_args (gfc_symbol *dest, gfc_symbol *src)
+gfc_copy_formal_args (gfc_symbol *dest, gfc_symbol *src, ifsrc if_src)
{
gfc_formal_arglist *head = NULL;
gfc_formal_arglist *tail = NULL;
@@ -4090,7 +4089,8 @@ void
formal_arg->sym->attr = curr_arg->sym->attr;
formal_arg->sym->ts = curr_arg->sym->ts;
formal_arg->sym->as = gfc_copy_array_spec (curr_arg->sym->as);
- gfc_copy_formal_args (formal_arg->sym, curr_arg->sym);
+ gfc_copy_formal_args (formal_arg->sym, curr_arg->sym,
+ curr_arg->sym->attr.if_source);
/* If this isn't the first arg, set up the next ptr. For the
last arg built, the formal_arg->next will never get set to
@@ -4110,7 +4110,7 @@ void
}
/* Add the interface to the symbol. */
- add_proc_interface (dest, IFSRC_DECL, head);
+ add_proc_interface (dest, if_src, head);
/* Store the formal namespace information. */
if (dest->formal != NULL)
@@ -4183,7 +4183,7 @@ gfc_copy_formal_args_intr (gfc_symbol *dest, gfc_i
void
-gfc_copy_formal_args_ppc (gfc_component *dest, gfc_symbol *src)
+gfc_copy_formal_args_ppc (gfc_component *dest, gfc_symbol *src, ifsrc if_src)
{
gfc_formal_arglist *head = NULL;
gfc_formal_arglist *tail = NULL;
@@ -4207,7 +4207,8 @@ void
formal_arg->sym->attr = curr_arg->sym->attr;
formal_arg->sym->ts = curr_arg->sym->ts;
formal_arg->sym->as = gfc_copy_array_spec (curr_arg->sym->as);
- gfc_copy_formal_args (formal_arg->sym, curr_arg->sym);
+ gfc_copy_formal_args (formal_arg->sym, curr_arg->sym,
+ curr_arg->sym->attr.if_source);
/* If this isn't the first arg, set up the next ptr. For the
last arg built, the formal_arg->next will never get set to
@@ -4229,7 +4230,7 @@ void
/* Add the interface to the symbol. */
gfc_free_formal_arglist (dest->formal);
dest->formal = head;
- dest->attr.if_source = IFSRC_DECL;
+ dest->attr.if_source = if_src;
/* Store the formal namespace information. */
if (dest->formal != NULL)
Index: gcc/fortran/gfortran.h
===================================================================
--- gcc/fortran/gfortran.h (revision 189470)
+++ gcc/fortran/gfortran.h (working copy)
@@ -2638,9 +2638,9 @@ gfc_symbol* gfc_get_ultimate_derived_super_type (g
bool gfc_type_is_extension_of (gfc_symbol *, gfc_symbol *);
bool gfc_type_compatible (gfc_typespec *, gfc_typespec *);
-void gfc_copy_formal_args (gfc_symbol *, gfc_symbol *);
+void gfc_copy_formal_args (gfc_symbol *, gfc_symbol *, ifsrc);
void gfc_copy_formal_args_intr (gfc_symbol *, gfc_intrinsic_sym *);
-void gfc_copy_formal_args_ppc (gfc_component *, gfc_symbol *);
+void gfc_copy_formal_args_ppc (gfc_component *, gfc_symbol *, ifsrc);
void gfc_free_finalizer (gfc_finalizer *el); /* Needed in resolve.c, too */
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 189470)
+++ gcc/fortran/resolve.c (working copy)
@@ -173,7 +173,7 @@ resolve_procedure_interface (gfc_symbol *sym)
sym->ts.interface = ifc;
sym->attr.function = ifc->attr.function;
sym->attr.subroutine = ifc->attr.subroutine;
- gfc_copy_formal_args (sym, ifc);
+ gfc_copy_formal_args (sym, ifc, IFSRC_DECL);
sym->attr.allocatable = ifc->attr.allocatable;
sym->attr.pointer = ifc->attr.pointer;
@@ -11790,7 +11790,7 @@ resolve_fl_derived0 (gfc_symbol *sym)
c->ts.interface = ifc;
c->attr.function = ifc->attr.function;
c->attr.subroutine = ifc->attr.subroutine;
- gfc_copy_formal_args_ppc (c, ifc);
+ gfc_copy_formal_args_ppc (c, ifc, IFSRC_DECL);
c->attr.pure = ifc->attr.pure;
c->attr.elemental = ifc->attr.elemental;
[-- Attachment #3: proc_decl_28.f90 --]
[-- Type: application/octet-stream, Size: 301 bytes --]
! { dg-do compile }
!
! PR 53956: [F03] PROCEDURE w/ interface: Bogus "EXTERNAL attribute conflicts with FUNCTION attribute"
!
! Contributed by James van Buskirk
interface
subroutine sub (a)
integer, external :: a
end subroutine
end interface
procedure(sub) :: proc
end
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, Fortran, F03] PROCEDURE w/ interface: Bogus "EXTERNAL attribute conflicts with FUNCTION attribute"
2012-07-16 9:09 [Patch, Fortran, F03] PROCEDURE w/ interface: Bogus "EXTERNAL attribute conflicts with FUNCTION attribute" Janus Weil
@ 2012-07-16 9:23 ` Tobias Burnus
2012-07-16 10:15 ` Janus Weil
0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2012-07-16 9:23 UTC (permalink / raw)
To: Janus Weil; +Cc: gfortran, gcc-patches
On 07/16/2012 11:09 AM, Janus Weil wrote:
> the attached patch is the solution that I came up with for this PR
> (after two simpler but wrong attempts, see PR). The issue addressed
> here is the setting of the if_source attribute for dummy procedures.
> When declaring a procedure (pointer) with the PROCEDURE statement, the
> attributes of the dummies (including if_source) should be copied from
> the source interface (cf. gfc_copy_formal_args).
>
> The patch was successfully regtested on x86_64-unknown-linux-gnu. Ok for trunk?
The patch looks fine. Thanks!
Tobias
> 2012-07-16 Janus Weil <janus@gcc.gnu.org>
>
> PR fortran/53956
> * gfortran.h (gfc_copy_formal_args,gfc_copy_formal_args_ppc): Modified
> prototypes.
> * symbol.c (gfc_copy_formal_args): New argument 'if_src'. Copy if_source
> of dummy procedures.
> (gfc_copy_formal_args_ppc): Ditto.
> * resolve.c (resolve_procedure_interface): Pass IFSRC_DECL to
> gfc_copy_formal_args.
> (resolve_fl_derived0): Pass IFSRC_DECL to gfc_copy_formal_args_ppc.
>
>
> 2012-07-16 Janus Weil <janus@gcc.gnu.org>
>
> PR fortran/53956
> * gfortran.dg/proc_decl_28.f90: New.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, Fortran, F03] PROCEDURE w/ interface: Bogus "EXTERNAL attribute conflicts with FUNCTION attribute"
2012-07-16 9:23 ` Tobias Burnus
@ 2012-07-16 10:15 ` Janus Weil
0 siblings, 0 replies; 3+ messages in thread
From: Janus Weil @ 2012-07-16 10:15 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gfortran, gcc-patches
>> the attached patch is the solution that I came up with for this PR
>> (after two simpler but wrong attempts, see PR). The issue addressed
>> here is the setting of the if_source attribute for dummy procedures.
>> When declaring a procedure (pointer) with the PROCEDURE statement, the
>> attributes of the dummies (including if_source) should be copied from
>> the source interface (cf. gfc_copy_formal_args).
>>
>> The patch was successfully regtested on x86_64-unknown-linux-gnu. Ok for
>> trunk?
>
>
> The patch looks fine. Thanks!
Thanks for the review, Tobias. Committed as r189514.
Cheers,
Janus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-07-16 10:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-16 9:09 [Patch, Fortran, F03] PROCEDURE w/ interface: Bogus "EXTERNAL attribute conflicts with FUNCTION attribute" Janus Weil
2012-07-16 9:23 ` Tobias Burnus
2012-07-16 10:15 ` Janus Weil
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).