From 083cc29303cc3d27b400b8af8125db3f3ceb930f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Schl=C3=BCter?= Date: Fri, 10 Feb 2006 19:08:27 +0100 Subject: [PATCH] re PR fortran/14771 (frontend doesn't record parentheses) fortran/ PR fortran/14771 * arith.c (eval_intrinsic): Accept INTRINSIC_PARENTHESES. * expr.c (check_intrinsic_op): Likewise. * module.c (mio_expr): Likewise. testsuite/ PR fortran/14771 * gfortran.dg/parens_4.f90: New. * gfortran.dg/parens_5.f90: New. From-SVN: r110840 --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/arith.c | 6 ++++++ gcc/fortran/expr.c | 3 +++ gcc/fortran/module.c | 1 + gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/parens_4.f90 | 12 ++++++++++++ gcc/testsuite/gfortran.dg/parens_5.f90 | 19 +++++++++++++++++++ 7 files changed, 54 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/parens_4.f90 create mode 100644 gcc/testsuite/gfortran.dg/parens_5.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 2d71f428a49..115e3c28291 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2006-02-10 Tobias Schlüter + + PR fortran/14771 + * arith.c (eval_intrinsic): Accept INTRINSIC_PARENTHESES. + * expr.c (check_intrinsic_op): Likewise. + * module.c (mio_expr): Likewise. + 2006-02-09 Tobias Schlüter * dump-parse-tree.c: Update copyright years. diff --git a/gcc/fortran/arith.c b/gcc/fortran/arith.c index aac3cb4f390..a65447a9233 100644 --- a/gcc/fortran/arith.c +++ b/gcc/fortran/arith.c @@ -1507,6 +1507,12 @@ eval_intrinsic (gfc_intrinsic_op operator, unary = 1; break; + case INTRINSIC_PARENTHESES: + temp.ts = op1->ts; + + unary = 1; + break; + case INTRINSIC_GE: case INTRINSIC_LT: /* Additional restrictions */ case INTRINSIC_LE: /* for ordering relations. */ diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index c72281c6758..28a2fc81a90 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1344,6 +1344,9 @@ check_intrinsic_op (gfc_expr * e, try (*check_function) (gfc_expr *)) break; + case INTRINSIC_PARENTHESES: + break; + default: gfc_error ("Only intrinsic operators can be used in expression at %L", &e->where); diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index b2505cc4b57..c32fe0bbd03 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -2514,6 +2514,7 @@ mio_expr (gfc_expr ** ep) case INTRINSIC_UPLUS: case INTRINSIC_UMINUS: case INTRINSIC_NOT: + case INTRINSIC_PARENTHESES: mio_expr (&e->value.op.op1); break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d28ecef43fd..9862bdb75e9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-02-10 Tobias Schlüter + + PR fortran/14771 + * gfortran.dg/parens_4.f90: New. + * gfortran.dg/parens_5.f90: New. + 2006-02-10 Richard Guenther * testsuite/gcc.dg/pr23372-1.c: Remove empty file. diff --git a/gcc/testsuite/gfortran.dg/parens_4.f90 b/gcc/testsuite/gfortran.dg/parens_4.f90 new file mode 100644 index 00000000000..1678ce74af5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/parens_4.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! Fallout from the patch for PR 14771 +! Testcase by Erik Zeek +program test + call bob(5) +contains + subroutine bob(n) + integer, intent(in) :: n + character(len=n) :: temp1 + character(len=(n)) :: temp2 ! Fails here + end subroutine bob +end program test diff --git a/gcc/testsuite/gfortran.dg/parens_5.f90 b/gcc/testsuite/gfortran.dg/parens_5.f90 new file mode 100644 index 00000000000..36bba8a0849 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/parens_5.f90 @@ -0,0 +1,19 @@ +! { dg-do run } +! Another case of fallout from the original patch for PR14771 +! Testcase by Erik Zeek +module para +contains + function bobo(n) + integer, intent(in) :: n + character(len=(n)) :: bobo ! Used to fail here + bobo = "1234567890" + end function bobo +end module para + +program test + use para + implicit none + character*5 c + c = bobo(5) + if (c .ne. "12345") call abort +end program test