Commit f8faa85e by Daniel Franke

re PR fortran/31639 ([4.1/4.2/4.3] ICE in gfc_conv_constant, at fortran/trans-const.c:348 with len)

gcc/fortran:
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.

gcc/testsuite:
2007-07-12  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/31639
	* gfortran.dg/func_decl_4.f90: New test.

From-SVN: r126605
parent 19e723f4
2007-07-12 Daniel Franke <franke.daniel@gmail.com> 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 PR fortran/32704
* invoke.texi (-static-libgfortran): Document new option. * invoke.texi (-static-libgfortran): Document new option.
......
...@@ -3578,12 +3578,6 @@ gfc_match_suffix (gfc_symbol *sym, gfc_symbol **result) ...@@ -3578,12 +3578,6 @@ gfc_match_suffix (gfc_symbol *sym, gfc_symbol **result)
break; 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 (is_bind_c == MATCH_YES)
if (gfc_add_is_bind_c (&(sym->attr), sym->name, &gfc_current_locus, 1) if (gfc_add_is_bind_c (&(sym->attr), sym->name, &gfc_current_locus, 1)
== FAILURE) == FAILURE)
......
...@@ -6547,7 +6547,7 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag) ...@@ -6547,7 +6547,7 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag)
} }
/* Reject illegal initializers. */ /* Reject illegal initializers. */
if (sym->value && flag) if (!sym->mark && sym->value && flag)
{ {
if (sym->attr.allocatable) if (sym->attr.allocatable)
gfc_error ("Allocatable '%s' at %L cannot have an initializer", gfc_error ("Allocatable '%s' at %L cannot have an initializer",
...@@ -6745,6 +6745,13 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag) ...@@ -6745,6 +6745,13 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
} }
} }
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 /* An external symbol may not have an initializer because it is taken to be
a procedure. */ a procedure. */
if (sym->attr.external && sym->value) 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> 2007-07-12 Paul Thomas <pault@gcc.gnu.org>
PR fortran/32727 PR fortran/32727
! { 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 "" }
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