+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
/* 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, ¤t_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;
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)
{
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.
--- /dev/null
+! { 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
+