From f16be16d2d4d48fb918bf8996f5fa0727b1ab1e3 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Tue, 30 Jul 2019 20:02:27 +0000 Subject: [PATCH] re PR fortran/91296 (ICE when passing complex number %re/%im as a procedure argument with -Waliasing.) 2019-07-30 Steven G. Kargl PR fortran/91296 * interface.c (compare_actual_expr): When checking for aliasing, add a case to handle REF_INQUIRY (e.g., foo(x%re, x%im) do not alias). 2019-07-30 Steven G. Kargl PR fortran/91296 * gfortran.dg/pr91296.f90: New test. From-SVN: r273914 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/interface.c | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr91296.f90 | 27 +++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr91296.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index dc965eae61b..fd55ca72bd3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-07-30 Steven G. Kargl + + PR fortran/91296 + * interface.c (compare_actual_expr): When checking for aliasing, add + a case to handle REF_INQUIRY (e.g., foo(x%re, x%im) do not alias). + 2019-07-29 Thomas Koenig PR fortran/90813 diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index f9715866c95..1d14f83057e 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -3489,6 +3489,13 @@ compare_actual_expr (gfc_expr *e1, gfc_expr *e2) case REF_SUBSTRING: return false; + case REF_INQUIRY: + if (e1->symtree->n.sym->ts.type == BT_COMPLEX + && e1->ts.type == BT_REAL && e2->ts.type == BT_REAL + && r1->u.i != r2->u.i) + return false; + break; + default: gfc_internal_error ("compare_actual_expr(): Bad component code"); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bad56871823..6afc2f05bfb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-07-30 Steven G. Kargl + + PR fortran/91296 + * gfortran.dg/pr91296.f90: New test. + 2019-07-30 Martin Liska PR tree-optimization/91270 diff --git a/gcc/testsuite/gfortran.dg/pr91296.f90 b/gcc/testsuite/gfortran.dg/pr91296.f90 new file mode 100644 index 00000000000..5f7bb0e70d3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr91296.f90 @@ -0,0 +1,27 @@ +! { dg-do compile } +! { dg-options "-Waliasing" } +! PR fortran/91296 +! Code contributed by Chinoune Mehdi +module m + implicit none + integer, parameter :: sp = selected_real_kind(6) + +contains + pure subroutine s(a,b,c) + real(sp), intent(in) :: a, b + real(sp), intent(out) :: c + c = a + b + end subroutine s +end module m + +program test + use m + implicit none + real(sp) :: a + complex(sp) :: c + + c = (1._sp,1._sp) + call s(c%re,c%im,a) ! *** This use to cause an ICE. *** + print*,a + +end program test -- 2.30.2