This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH, Fortran] DEC Compatibility: Logical operations on integers become bitwise ops with -fdec


All-

Proposed here is another compatibility extension to the GNU Fortran
frontend which allows logical operations on integer operands with the
-fdec flag. In this case the logical operator is replaced with its
bitwise equivalent.

For example, GNU Fortran by default (correctly) produces an error for
the expression "A .AND. B" when A and/or B are integers. With this
patch when the -fdec legacy compatibility flag is asserted, GNU
Fortran instead silently replaces the expression with "IAND(A, B)",
performing a bitwise-and on the integers A and B. This behavior is to
match the behavior of legacy compilers, and expectations of some
legacy code.

This extension was originally implemented under its own flag
"-fdec-bitwise-ops", but following the recent trend I have just rolled
it into "-fdec". I thought the behavior might be too drastic for
-std=legacy, but if anyone has a different opinion I can certainly do
this with -std=legacy instead of -fdec.

Bootstraps and regtests on x86_64-redhat-linux, OK for trunk?

---
Fritz Reese

From: Fritz Reese <fritzoreese@gmail.com>
Date: Mon, 24 Oct 2016 13:47:38 -0400
Subject: [PATCH] Logical operations on integers become bitwise ops with -fdec.

        gcc/fortran/
        * gfortran.texi: Document.
        * resolve.c (logical_to_bitwise): New function.
        * resolve.c (resolve_operator): Wrap operands with logical_to_bitwise.

        gcc/testsuite/gfortran.dg/
        * dec_bitwise_ops_1.f90, dec_bitwise_ops_2.f90: New testcases.
---
 gcc/fortran/gfortran.texi                       |   38 ++++++
 gcc/fortran/resolve.c                           |  105 +++++++++++++++
 gcc/testsuite/gfortran.dg/dec_bitwise_ops_1.f90 |  106 ++++++++++++++++
 gcc/testsuite/gfortran.dg/dec_bitwise_ops_2.f90 |  155 +++++++++++++++++++++++
 4 files changed, 404 insertions(+), 0 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/dec_bitwise_ops_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/dec_bitwise_ops_2.f90

Attachment: dec_bitwise_ops.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]