Commit 2c54eab5 by Mark Eggleston

fortran : ICE in gfc_resolve_findloc PR93498

ICE occurs when findloc is used with character arguments of different
kinds.  If the character kinds are different reject the code.

Original patch provided by Steven G. Kargl  <kargl@gcc.gnu.org>.

gcc/fortran/ChangeLog:

	PR fortran/93498
	* check.c (gfc_check_findloc):  If the kinds of the arguments
	differ goto label "incompat".

gcc/testsuite/ChangeLog:

	PR fortran/93498
	* gfortran.dg/pr93498_1.f90:  New test.
	* gfortran.dg/pr93498_2.f90:  New test.
parent bf1f6d88
2020-04-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/93498
* check.c (gfc_check_findloc): If the kinds of the arguments
differ goto label "incompat".
2020-04-02 Steven G. Kargl <kargl@gcc.gnu.org> 2020-04-02 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/94030 PR fortran/94030
......
...@@ -3947,6 +3947,10 @@ gfc_check_findloc (gfc_actual_arglist *ap) ...@@ -3947,6 +3947,10 @@ gfc_check_findloc (gfc_actual_arglist *ap)
v1 = v->ts.type == BT_CHARACTER; v1 = v->ts.type == BT_CHARACTER;
if ((a1 && !v1) || (!a1 && v1)) if ((a1 && !v1) || (!a1 && v1))
goto incompat; goto incompat;
/* Check the kind of the characters argument match. */
if (a1 && v1 && a->ts.kind != v->ts.kind)
goto incompat;
d = ap->next->next->expr; d = ap->next->next->expr;
m = ap->next->next->next->expr; m = ap->next->next->next->expr;
......
2020-04-02 Mark Eggleston <mark.eggleston@codethink.com> 2020-04-02 Mark Eggleston <mark.eggleston@codethink.com>
PR fortran/93498
* gfortran.dg/pr93498_1.f90: New test.
* gfortran.dg/pr93498_2.f90: New test.
2020-04-02 Mark Eggleston <mark.eggleston@codethink.com>
Steven G. Kargl <kargl@gcc.gnu.org> Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/94030 PR fortran/94030
......
! { dg-do compile }
!
! Test case by G. Steinmetz
program p
character(len=1, kind=1) :: x(3) = ['a', 'b', 'c']
character(len=1, kind=4) :: y = 4_'b'
print *, findloc(x, y) ! { dg-error " must be in type conformance" }
print *, findloc(x, y, 1) ! { dg-error " must be in type conformance" }
end
! { dg-do compile }
!
! Test case by G. Steinmetz
program p
character(len=1, kind=4) :: x(3) = [4_'a', 4_'b', 4_'c']
character(len=1, kind=1) :: y = 'b'
print *, findloc(x, y) ! { dg-error " must be in type conformance" }
print *, findloc(x, y, 1) ! { dg-error " must be in type conformance" }
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