+2007-07-12 Daniel Franke <franke.daniel@gmail.com>
+
+ PR fortran/31639
+ * decl.c (gfc_match_suffix): Removed surplus general error that hides
+ a more specific message.
+ * resolve.c (resolve_fl_variable): Reject illegal initializiers only
+ if not already done.
+ (resolve_fl_procedure): Added check for initializers of functions.
+
2007-07-12 Daniel Franke <franke.daniel@gmail.com>
PR fortran/32704
break;
}
- if (is_result == MATCH_ERROR || is_bind_c == MATCH_ERROR)
- {
- gfc_error ("Error in function suffix at %C");
- return MATCH_ERROR;
- }
-
if (is_bind_c == MATCH_YES)
if (gfc_add_is_bind_c (&(sym->attr), sym->name, &gfc_current_locus, 1)
== FAILURE)
}
/* Reject illegal initializers. */
- if (sym->value && flag)
+ if (!sym->mark && sym->value && flag)
{
if (sym->attr.allocatable)
gfc_error ("Allocatable '%s' at %L cannot have an initializer",
}
}
+ if (sym->attr.function && sym->value && sym->attr.proc != PROC_ST_FUNCTION)
+ {
+ gfc_error ("Function '%s' at %L cannot have an initializer",
+ sym->name, &sym->declared_at);
+ return FAILURE;
+ }
+
/* An external symbol may not have an initializer because it is taken to be
a procedure. */
if (sym->attr.external && sym->value)
+2007-07-12 Daniel Franke <franke.daniel@gmail.com>
+
+ PR fortran/31639
+ * gfortran.dg/func_decl_4.f90: New test.
+
2007-07-12 Paul Thomas <pault@gcc.gnu.org>
PR fortran/32727
--- /dev/null
+! { dg-do compile }
+! { dg-options "-c" }
+!
+! Functions shall not have an initializer.
+!
+
+function f1() ! { dg-error "cannot have an initializer" }
+ integer :: f1 = 42
+end function
+
+function f2() RESULT (r) ! { dg-error "cannot have an initializer" }
+ integer :: r = 42
+end function
+
+function f3() RESULT (f3) ! { dg-error "must be different than function name" }
+ integer :: f3 = 42
+end function ! { dg-excess-errors "" }