[PATCH] Support .XOR. as a -std=legacy extension

Tobias Burnus burnus@net-b.de
Wed Sep 5 08:05:00 GMT 2007


Roger Sayle wrote:
> The following patch adds support for ".xor." as an intrinsic operator.
I'm not sure whether it is a problem or not; assume the following program:

----------------------
module x
  implicit none
  private
  public :: operator(.xor.)
  interface operator(.xor.)
    module procedure xor_logic
 end interface
contains
  function xor_logic(a,b)
    logical, intent(in) :: a, b
    logical :: xor_logic
    if ((a .neqv. b).and. (a .or. b)) then
      xor_logic = .true.
    else
      xor_logic = .false.
    end if
  end function xor_logic
end module x

program main
  use x, only: operator(.xor.)
  implicit none
  print *, (.false. .xor. .false.)
  print *, (.false. .xor. .true. )
  print *, (.true.  .xor. .false.)
  print *, (.true.  .xor. .true. )
end program main
----------------------

If I compile it with -std=f2003 or -std=f95 it works as expected,
however, with -std=gnu I get:

Error: Operator interface at (1) conflicts with intrinsic interface

Using sunf95 or ifort (default options) I can compile the program
without any errors.
If I use the intrinsic opterator with sunf95 and ifort (also default
options) it also works.
(ifort has also proper diagnostics, which one sees if one tries to
define .or. instead of .xor.; this gives "The type/rank for the
arguments of this specific function for a defined OPERATOR redefines
intrinsic expression operations.")

Tobias



More information about the Fortran mailing list