diff options
author | Fritz Reese <fritzoreese@gmail.com> | 2016-10-25 15:30:51 +0000 |
---|---|---|
committer | Fritz Reese <foreese@gcc.gnu.org> | 2016-10-25 15:30:51 +0000 |
commit | 1cf1719bc07ade2e96d47c7bae00d1203c847ee0 (patch) | |
tree | 4168fa510d949da5efd576836059e0d1cea0bb96 | |
parent | cd714e1e56c53aeda0fe365a1daebf217731b42a (diff) | |
download | gcc-1cf1719bc07ade2e96d47c7bae00d1203c847ee0.zip gcc-1cf1719bc07ade2e96d47c7bae00d1203c847ee0.tar.gz gcc-1cf1719bc07ade2e96d47c7bae00d1203c847ee0.tar.bz2 |
Enable .XOR. operator with -std=legacy.
gcc/fortran/
* match.c (gfc_match_intrinsic_op): Match ".XOR." with -std=legacy.
* gfortran.texi: Document.
gcc/testsuite/gfortran.dg/
* dec_logical_xor_1.f90: New.
* dec_logical_xor_2.f90: New.
* dec_logical_xor_3.f03: New.
From-SVN: r241520
-rw-r--r-- | gcc/fortran/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/fortran/gfortran.texi | 10 | ||||
-rw-r--r-- | gcc/fortran/match.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/dec_logical_xor_1.f90 | 40 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/dec_logical_xor_2.f90 | 12 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/dec_logical_xor_3.f03 | 12 |
7 files changed, 100 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 9bd1d80..c6a07e9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,7 +1,12 @@ 2016-10-25 Fritz Reese <fritzoreese@gmail.com> - * primary.c (gfc_match_rvalue): Match %LOC as LOC with -std=legacy. - * gfortran.texi: Document. + * match.c (gfc_match_intrinsic_op): Match ".XOR." with -std=legacy. + * gfortran.texi: Document. + +2016-10-25 Fritz Reese <fritzoreese@gmail.com> + + * primary.c (gfc_match_rvalue): Match %LOC as LOC with -std=legacy. + * gfortran.texi: Document. 2016-10-25 Fritz Reese <fritzoreese@gmail.com> diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi index e1256bd..60b619f 100644 --- a/gcc/fortran/gfortran.texi +++ b/gcc/fortran/gfortran.texi @@ -1468,6 +1468,7 @@ compatibility extensions along with those enabled by @option{-std=legacy}. * Form feed as whitespace:: * TYPE as an alias for PRINT:: * %LOC as an rvalue:: +* .XOR. operator:: @end menu @node Old-style kind specifications @@ -2558,6 +2559,14 @@ integer :: i call sub(%loc(i)) @end smallexample +@node .XOR. operator +@subsection .XOR. operator +@cindex operators, xor + +GNU Fortran supports @code{.XOR.} as a logical operator with @code{-std=legacy} +for compatibility with legacy code. @code{.XOR.} is equivalent to +@code{.NEQV.}. That is, the output is true if and only if the inputs differ. + @node Extensions not implemented in GNU Fortran @section Extensions not implemented in GNU Fortran @@ -2582,7 +2591,6 @@ code that uses them running with the GNU Fortran compiler. * Variable FORMAT expressions:: @c * Q edit descriptor:: @c * TYPE and ACCEPT I/O Statements:: -@c * .XOR. operator:: @c * CARRIAGECONTROL, DEFAULTFILE, DISPOSE and RECORDTYPE I/O specifiers:: @c * Omitted arguments in procedure call:: * Alternate complex function syntax:: diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 236231e..94aa830 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -960,6 +960,19 @@ gfc_match_intrinsic_op (gfc_intrinsic_op *result) } break; + case 'x': + if (gfc_next_ascii_char () == 'o' + && gfc_next_ascii_char () == 'r' + && gfc_next_ascii_char () == '.') + { + if (!gfc_notify_std (GFC_STD_LEGACY, ".XOR. operator at %C")) + return MATCH_ERROR; + /* Matched ".xor." - equivalent to ".neqv.". */ + *result = INTRINSIC_NEQV; + return MATCH_YES; + } + break; + default: break; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 33a9913..78a9bda 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,8 +1,14 @@ 2016-10-25 Fritz Reese <fritzoreese@gmail.com> + * gfortran.dg/dec_logical_xor_1.f90: New test. + * gfortran.dg/dec_logical_xor_2.f90: New test. + * gfortran.dg/dec_logical_xor_3.f03: New test. + +2016-10-25 Fritz Reese <fritzoreese@gmail.com> + * gfortran.dg/dec_loc_rval_1.f90: New test. * gfortran.dg/dec_loc_rval_2.f90: New test. - * gfortran.dg/dec_loc_rval_3.f90: New test. + * gfortran.dg/dec_loc_rval_3.f03: New test. 2016-10-25 Fritz Reese <fritzoreese@gmail.com> diff --git a/gcc/testsuite/gfortran.dg/dec_logical_xor_1.f90 b/gcc/testsuite/gfortran.dg/dec_logical_xor_1.f90 new file mode 100644 index 0000000..d10fa19 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_logical_xor_1.f90 @@ -0,0 +1,40 @@ +! { dg-do run } +! { dg-options "-std=legacy" } +! +! Test logical .XOR. operator. +! + +implicit none + +logical :: in1, in2, neqv_out, lxor_out, truth_table(2) +integer :: i, j, ixor_out, ieor_out + +truth_table(1) = .true. +truth_table(2) = .false. +do i = 1,2 + do j = 1,2 + in1 = truth_table(j) + in2 = truth_table(i) + + ! make sure logical xor works + neqv_out = in1 .neqv. in2 + lxor_out = in1 .xor. in2 + + if ( neqv_out .neqv. lxor_out ) then + print *, "(",in1,in2,") .neqv.: ",neqv_out," .xor.: ",lxor_out + call abort() + endif + + ! make sure we didn't break xor() intrinsic + ixor_out = xor(i*7, j*5) + ieor_out = ieor(i*7, j*5) + + if ( ixor_out .ne. ieor_out ) then + print *, "(",in1,in2,") ieor(): ",ieor_out," xor(): ",ixor_out + call abort() + endif + + enddo +enddo + +end diff --git a/gcc/testsuite/gfortran.dg/dec_logical_xor_2.f90 b/gcc/testsuite/gfortran.dg/dec_logical_xor_2.f90 new file mode 100644 index 0000000..4e43179 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_logical_xor_2.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-std=gnu" } +! +! Test warnings for logical .XOR. operator without -std=legacy. +! + +implicit none + +logical, volatile :: in1, in2, xor_out +xor_out = in1 .xor. in2 ! { dg-warning ".XOR. operator" } + +end diff --git a/gcc/testsuite/gfortran.dg/dec_logical_xor_3.f03 b/gcc/testsuite/gfortran.dg/dec_logical_xor_3.f03 new file mode 100644 index 0000000..ff029fc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/dec_logical_xor_3.f03 @@ -0,0 +1,12 @@ +! { dg-do compile } +! { dg-options "-std=f2003" } +! +! Test errors for logical .XOR. operator with a real standard. +! + +implicit none + +logical, volatile :: in1, in2, xor_out +xor_out = in1 .xor. in2 ! { dg-error ".XOR. operator" } + +end |