Skip to content

[flang] pseudopositive warning to function result that is set, pseudonegative warning to subroutine INTENT(OUT) parameter that is not set #144453

Open
@e-kwsm

Description

@e-kwsm
$ flang --version
flang version 20.1.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Prepare the following file:

program main
  implicit none
  logical :: x0, x1

  print *, f0(), f1()
  call s0(x0)
  call s1(x1)
  print *, x0, x1

contains

  function f0()
    ! "Function result is never defined", as expected
    logical :: f0
  end function

  function f1()
    ! "Function result is never defined", but f1 is definitely set
    logical :: f1
    INQUIRE(file="/usr/bin/flang", EXIST=f1)
  end function f1

  subroutine s0(x)
    ! NO warning, but x is NOT set
    logical, INTENT(OUT) :: x
  end subroutine

  subroutine s1(x)
    ! no warning as expected, but inconsistent with f1
    logical, INTENT(OUT) :: x
    INQUIRE(file="/usr/bin/flang", EXIST=x)
  end subroutine

end program

INQUIRE assigns the EXIST= specifier to T or F, so the result of f1 is set. Also, s0 does not set a value to x that is specified as intent(out), but no warning is issued.

$ flang a.F90
./a.F90:12:12: warning: Function result is never defined
    function f0()
             ^^
./a.F90:17:12: warning: Function result is never defined
    function f1()
             ^^

Expected:

$ flang a.F90
./a.F90:12:12: warning: Function result is never defined
    function f0()
             ^^
./a.F90:23:17: warning: Subroutine parameter x specified as INTENT(OUT) is never defined
  subroutine s0(x)
                ^

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions