From: Martin Liska Date: Tue, 10 Dec 2019 18:57:30 +0000 (+0100) Subject: Bail out in gfc_dep_compare_expr for a NULL argument. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=42aed35797ad46c1c98fcddf6a29ecb45b45ea9d;p=gcc.git Bail out in gfc_dep_compare_expr for a NULL argument. 2019-12-10 Martin Liska PR fortran/92874 * dependency.c (gfc_dep_compare_expr): Bail out when one of the arguments is null. 2019-12-10 Martin Liska PR fortran/92874 * gfortran.dg/pr92874.f90: New test. From-SVN: r279181 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b34a684a3b5..bcc821806e5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-12-10 Martin Liska + + PR fortran/92874 + * dependency.c (gfc_dep_compare_expr): Bail out + when one of the arguments is null. + 2019-12-10 Thomas Koenig PR fortran/92863 diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c index 394d85b48a2..eb741137d60 100644 --- a/gcc/fortran/dependency.c +++ b/gcc/fortran/dependency.c @@ -319,6 +319,8 @@ gfc_dep_compare_expr (gfc_expr *e1, gfc_expr *e2) if (e1 == NULL && e2 == NULL) return 0; + else if (e1 == NULL || e2 == NULL) + return -2; e1 = gfc_discard_nops (e1); e2 = gfc_discard_nops (e2); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 39e5366c366..06ffc521bcf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-10 Martin Liska + + PR fortran/92874 + * gfortran.dg/pr92874.f90: New test. + 2019-12-10 Thomas Koenig PR fortran/92863 diff --git a/gcc/testsuite/gfortran.dg/pr92874.f90 b/gcc/testsuite/gfortran.dg/pr92874.f90 new file mode 100644 index 00000000000..a1fca3d7718 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr92874.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! { dg-options "-O2" } +! PR fortran/92874 +program p + call s('a') + call s('abc') +end +subroutine s(x) + character(*) :: x + print *, (x(1:1) == x(1:)) +end