From c20f6223a41539918368677b4a79ad6c1ae674bb Mon Sep 17 00:00:00 2001 From: Jerry DeLisle Date: Mon, 4 Jul 2016 19:14:54 +0000 Subject: [PATCH] re PR fortran/35849 ("wrong" line shown in error message for parameter) 2016-07-04 Jerry DeLisle Steven G. Kargl PR fortran/35849 * simplify.c (gfc_simplify_ishftc): Check that absolute value of SHIFT is less than or equal to SIZE. * gfortran.dg: pr35849.f90: New test. Co-Authored-By: Steven G. Kargl From-SVN: r237993 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/simplify.c | 6 ++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr35849.f90 | 9 +++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr35849.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9ecdc82e455..37481e566cf 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2016-07-04 Jerry DeLisle + Steven G. Kargl + + PR fortran/35849 + * simplify.c (gfc_simplify_ishftc): Check that absolute value of + SHIFT is less than or equal to SIZE. + 2016-07-01 Jakub Jelinek PR fortran/71687 diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index a63101072f1..4c8bb830808 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -3280,7 +3280,6 @@ gfc_simplify_ishftc (gfc_expr *e, gfc_expr *s, gfc_expr *sz) return NULL; gfc_extract_int (sz, &ssize); - } else ssize = isize; @@ -3294,7 +3293,10 @@ gfc_simplify_ishftc (gfc_expr *e, gfc_expr *s, gfc_expr *sz) { if (sz == NULL) gfc_error ("Magnitude of second argument of ISHFTC exceeds " - "BIT_SIZE of first argument at %L", &s->where); + "BIT_SIZE of first argument at %C"); + else + gfc_error ("Absolute value of SHIFT shall be less than or equal " + "to SIZE at %C"); return &gfc_bad_expr; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9e819ac4ed2..1c6ff51c4e8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-04 Jerry DeLisle + + PR fortran/35849 + * gfortran.dg: pr35849.f90: New test. + 2016-07-04 Jakub Jelinek PR c++/71739 diff --git a/gcc/testsuite/gfortran.dg/pr35849.f90 b/gcc/testsuite/gfortran.dg/pr35849.f90 new file mode 100644 index 00000000000..39ba48cb3e5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr35849.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR35849 +INTEGER, PARAMETER :: j = 15 +INTEGER, PARAMETER, DIMENSION(10) :: A = [(i, i = 1,10)] +INTEGER, PARAMETER, DIMENSION(10) :: B = ISHFTC(j, A, -20) ! { dg-error "must be positive" } +INTEGER, PARAMETER, DIMENSION(10) :: C = ISHFTC(1_1, A, j) ! { dg-error "less than or equal to BIT_SIZE" } +INTEGER, PARAMETER, DIMENSION(10) :: D = ISHFTC(3, A, 5) ! { dg-error "Absolute value of SHIFT shall be less than or equal" } +INTEGER, PARAMETER, DIMENSION(10) :: E = ISHFTC(3_1, A) ! { dg-error "second argument of ISHFTC exceeds BIT_SIZE of first argument" } +end -- 2.30.2