From: Harald Anlauf Date: Mon, 24 Jan 2022 20:40:41 +0000 (+0100) Subject: Fortran: optional argument DIM for intrinsics NORM2, PARITY must be scalar X-Git-Tag: upstream/12.2.0~1833 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=34e8dafb76240f69c729c11cfc8c8fc4f717bc17;p=platform%2Fupstream%2Fgcc.git Fortran: optional argument DIM for intrinsics NORM2, PARITY must be scalar gcc/fortran/ChangeLog: PR fortran/104212 * check.cc (gfc_check_norm2): Check that optional argument DIM is scalar. (gfc_check_parity): Likewise. gcc/testsuite/ChangeLog: PR fortran/104212 * gfortran.dg/argument_checking_26.f90: New test. --- diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 5fe8d45..4fa05ee 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -4338,6 +4338,9 @@ gfc_check_norm2 (gfc_expr *array, gfc_expr *dim) if (!array_check (array, 0)) return false; + if (!dim_check (dim, 1, false)) + return false; + if (!dim_rank_check (dim, array, false)) return false; @@ -4476,6 +4479,9 @@ gfc_check_parity (gfc_expr *mask, gfc_expr *dim) if (!array_check (mask, 0)) return false; + if (!dim_check (dim, 1, false)) + return false; + if (!dim_rank_check (dim, mask, false)) return false; diff --git a/gcc/testsuite/gfortran.dg/argument_checking_26.f90 b/gcc/testsuite/gfortran.dg/argument_checking_26.f90 new file mode 100644 index 0000000..2b765c5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/argument_checking_26.f90 @@ -0,0 +1,14 @@ +! { dg-do compile } +! PR fortran/104212 - ICE in transformational_result +! Contributed by G.Steinmetz + +program p + logical, parameter :: a(*,*) = reshape([.true.,.false.], shape=[1,2]) + real, parameter :: r(*,*) = reshape([1.,2.], shape=[1,2]) + print *, parity(a) + print *, parity(a, dim=1) + print *, parity(a, dim=[1]) ! { dg-error "must be a scalar" } + print *, norm2 (r) + print *, norm2 (r, dim=1) + print *, norm2 (r, dim=[1]) ! { dg-error "must be a scalar" } +end