Commit 9b15893c by Steven G. Kargl

re PR fortran/67884 (Missing error message on required allocatable attribute)

2019-06-21  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/67884
	* resolve.c (deferred_requirements) : Check only the result variable.
	(resolve_fl_procedure): Check deferred requirements on functions.

2019-06-21  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/67884
	* gfortran.dg/dummy_procedure_8.f90: Remove a test that is ...
	* gfortran.dg/pr67884.f90: ... covered here.  New test.

From-SVN: r272569
parent 4c60db9a
2019-06-21 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/67884
* resolve.c (deferred_requirements) : Check only the result variable.
(resolve_fl_procedure): Check deferred requirements on functions.
2019-06-21 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/51991
* decl.c (gfc_match_save): If SAVE was not seen, return MATCH_NO
instead issuing an error message and returning MATCH_ERROR.
......
......@@ -12388,6 +12388,10 @@ deferred_requirements (gfc_symbol *sym)
|| sym->attr.associate_var
|| sym->attr.omp_udr_artificial_var))
{
/* If a function has a result variable, only check the variable. */
if (sym->result && sym->name != sym->result->name)
return true;
gfc_error ("Entity %qs at %L has a deferred type parameter and "
"requires either the POINTER or ALLOCATABLE attribute",
sym->name, &sym->declared_at);
......@@ -12598,6 +12602,10 @@ resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
&& !resolve_fl_var_and_proc (sym, mp_flag))
return false;
/* Constraints on deferred type parameter. */
if (!deferred_requirements (sym))
return false;
if (sym->ts.type == BT_CHARACTER)
{
gfc_charlen *cl = sym->ts.u.cl;
......
2019-06-21 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/67884
* gfortran.dg/dummy_procedure_8.f90: Remove a test that is ...
* gfortran.dg/pr67884.f90: ... covered here. New test.
2019-06-21 Marek Polacek <polacek@redhat.com>
PR c++/90490 - fix decltype issues in noexcept-specifier.
......
......@@ -7,7 +7,6 @@
implicit none
call call_a(a1) ! { dg-error "Character length mismatch in function result" }
call call_a(a2) ! { dg-error "Character length mismatch in function result" }
call call_b(b1) ! { dg-error "Shape mismatch" }
call call_c(c1) ! { dg-error "POINTER attribute mismatch in function result" }
call call_d(c1) ! { dg-error "ALLOCATABLE attribute mismatch in function result" }
......@@ -19,9 +18,6 @@ contains
character(1) function a1()
end function
character(:) function a2()
end function
subroutine call_a(a3)
interface
character(2) function a3()
......
! { dg-do compile }
! PR fortran/67884
! Original code contribute by Gerhard Steinmetz
program p
integer i
print *, [(f(i), i=1,3)]
print *, [(g(i), i=1,3)]
contains
function f(n) ! { dg-error "has a deferred type parameter" }
integer :: n
character(:) :: f
character(3) :: c = 'abc'
f = c(n:n)
end
function g(n) result(z) ! { dg-error "has a deferred type parameter" }
integer :: n
character(:) :: z
character(3) :: c = 'abc'
z = c(n:n)
end
end program p
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