From 8bae3cefebfc940f629c0353ca345252844c0865 Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Mon, 16 Jul 2012 12:13:19 +0200 Subject: [PATCH] re PR fortran/53956 ([F03] PROCEDURE w/ interface: Bogus "EXTERNAL attribute conflicts with FUNCTION attribute") 2012-07-16 Janus Weil 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 PR fortran/53956 * gfortran.dg/proc_decl_28.f90: New. From-SVN: r189514 --- gcc/fortran/ChangeLog | 12 ++++++++++++ gcc/fortran/gfortran.h | 4 ++-- gcc/fortran/resolve.c | 4 ++-- gcc/fortran/symbol.c | 17 +++++++++-------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/proc_decl_28.f90 | 15 +++++++++++++++ 6 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/proc_decl_28.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f6be5bde2cc..3cfa4bab507 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,15 @@ +2012-07-16 Janus Weil + + 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-12 Tobias Burnus * trans-expr.c (conv_isocbinding_procedure): Generate c_f_pointer code diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index 6d75e632088..fa06883123e 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2638,9 +2638,9 @@ gfc_symbol* gfc_get_ultimate_derived_super_type (gfc_symbol*); 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 */ diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 5be1857ef79..03f74df88fa 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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; diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 378f83c23dd..99fa27d700e 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -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 @@ add_proc_interface (gfc_symbol *sym, ifsrc source, 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 @@ gfc_copy_formal_args (gfc_symbol *dest, gfc_symbol *src) 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 @@ gfc_copy_formal_args (gfc_symbol *dest, gfc_symbol *src) } /* 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_intrinsic_sym *src) 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 @@ gfc_copy_formal_args_ppc (gfc_component *dest, gfc_symbol *src) 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 @@ gfc_copy_formal_args_ppc (gfc_component *dest, gfc_symbol *src) /* 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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 21a10499b0c..45f45317a02 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-07-16 Janus Weil + + PR fortran/53956 + * gfortran.dg/proc_decl_28.f90: New. + 2012-07-16 Andrew Pinski * gcc.dg/torture/builtins-1.c: New testcase. diff --git a/gcc/testsuite/gfortran.dg/proc_decl_28.f90 b/gcc/testsuite/gfortran.dg/proc_decl_28.f90 new file mode 100644 index 00000000000..b3a557b1494 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/proc_decl_28.f90 @@ -0,0 +1,15 @@ +! { 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 -- 2.30.2