From: Janus Weil <janus@gcc.gnu.org>
To: gfortran <fortran@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [Patch, Fortran, F03] PROCEDURE w/ interface: Bogus "EXTERNAL attribute conflicts with FUNCTION attribute"
Date: Mon, 16 Jul 2012 09:09:00 -0000 [thread overview]
Message-ID: <CAKwh3qjcNBnVvoCC1R8nGtqaYEvKZ-srX61L8PE-Yw6b2=FBrg@mail.gmail.com> (raw)
[-- 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
next reply other threads:[~2012-07-16 9:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-16 9:09 Janus Weil [this message]
2012-07-16 9:23 ` Tobias Burnus
2012-07-16 10:15 ` Janus Weil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKwh3qjcNBnVvoCC1R8nGtqaYEvKZ-srX61L8PE-Yw6b2=FBrg@mail.gmail.com' \
--to=janus@gcc.gnu.org \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).