Commit 1d146030 by Janus Weil

re PR fortran/39414 (PROCEDURE statement double declaration bug)

2009-04-06  Janus Weil  <janus@gcc.gnu.org>

       PR fortran/39414
       * decl.c (match_procedure_decl): Fix double declaration problems with
       PROCEDURE statements.
       * symbol.c (gfc_add_type): Ditto.


2009-04-06  Janus Weil  <janus@gcc.gnu.org>

       PR fortran/39414
       * gfortran.dg/proc_decl_21.f90: New.

From-SVN: r145583
parent 7d253f6e
2009-04-06 Janus Weil <janus@gcc.gnu.org>
PR fortran/39414
* decl.c (match_procedure_decl): Fix double declaration problems with
PROCEDURE statements.
* symbol.c (gfc_add_type): Ditto.
2009-04-06 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36091
......
......@@ -4207,12 +4207,20 @@ got_ts:
/* Set interface. */
if (proc_if != NULL)
{
if (sym->ts.type != BT_UNKNOWN)
{
gfc_error ("Procedure '%s' at %L already has basic type of %s",
sym->name, &gfc_current_locus,
gfc_basic_typename (sym->ts.type));
return MATCH_ERROR;
}
sym->ts.interface = proc_if;
sym->attr.untyped = 1;
}
else if (current_ts.type != BT_UNKNOWN)
{
sym->ts = current_ts;
if (gfc_add_type (sym, &current_ts, &gfc_current_locus) == FAILURE)
return MATCH_ERROR;
sym->ts.interface = gfc_new_symbol ("", gfc_current_ns);
sym->ts.interface->ts = current_ts;
sym->ts.interface->attr.function = 1;
......
......@@ -1555,8 +1555,7 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
if (sym->ts.type != BT_UNKNOWN)
{
const char *msg = "Symbol '%s' at %L already has basic type of %s";
if (!(sym->ts.type == ts->type
&& (sym->attr.flavor == FL_PROCEDURE || sym->attr.result))
if (!(sym->ts.type == ts->type && sym->attr.result)
|| gfc_notification_std (GFC_STD_GNU) == ERROR
|| pedantic)
{
......@@ -1570,6 +1569,13 @@ gfc_add_type (gfc_symbol *sym, gfc_typespec *ts, locus *where)
gfc_warning (msg, sym->name, where, gfc_basic_typename (sym->ts.type));
}
if (sym->attr.procedure && sym->ts.interface)
{
gfc_error ("Procedure '%s' at %L may not have basic type of %s", sym->name, where,
gfc_basic_typename (ts->type));
return FAILURE;
}
flavor = sym->attr.flavor;
if (flavor == FL_PROGRAM || flavor == FL_BLOCK_DATA || flavor == FL_MODULE
......
2009-04-06 Paul Thomas <pault@gcc.gnu.org
2009-04-06 Janus Weil <janus@gcc.gnu.org>
PR fortran/39414
* gfortran.dg/proc_decl_21.f90: New.
2009-04-06 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36091
* gfortran.dg/forall_13.f90: Add -fbounds-check option.
......
! { dg-do compile }
!
! PR fortran/39414: PROCEDURE statement double declaration bug
!
! Discovered by Paul Thomas <pault@gcc.gnu.org>
! Modified by Janus Weil <janus@gcc.gnu.org>
! forbidden
procedure(integer) :: a
integer :: a ! { dg-error "already has basic type of" }
integer :: b
procedure(integer) :: b ! { dg-error "already has basic type of" }
procedure(iabs) :: c
integer :: c ! { dg-error "may not have basic type of" }
integer :: d
procedure(iabs) :: d ! { dg-error "already has basic type of" }
! allowed
integer :: e
procedure() :: e
procedure() :: f
integer :: f
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment