[flang] emit warning when encountering a non-variable actual argument when its corres...
authorCabrera, Anthony <cabreraam@ornl.gov>
Tue, 13 Dec 2022 19:48:25 +0000 (14:48 -0500)
committercabreraam <cabreraam33@gmail.com>
Tue, 13 Dec 2022 20:28:15 +0000 (15:28 -0500)
commit9c87746de7cdbb2b60a3fc274831aee43ddd9b7c
tree1d88cf09c3ad9ec3924765e6e82a66d62740b1cc
parent9144ee6edf41acdfdf5912b26ad66c4953276528
[flang] emit warning when encountering a non-variable actual argument when its corresponding dummy argument expects a VOLATILE variable

This patch implements @klausler's suggestion in `llvm-project` [issue #58973](https://github.com/llvm/llvm-project/issues/58973); encountering the `VOLATILE` attribute should produce a __warning__, not a __fatal error__.

When tested on the following Fortran program `snem0601_012_.f90`:
```fortran
  module mod
    contains
    subroutine sub(m6,error)
    integer,intent(inout) :: error

    integer,volatile :: m6

    if (any ((/m6/).ne.(/6/))) &
   & then
       error = 1
    end if
    end subroutine
  end module

  program fe1nvol12

    use mod
    integer :: error = 0

    call sub(6,error)

    if (error .ne. 0) then
      print *,'NG: snem0601_012'
    end if

    print *,'pass: snem0601_012'

  end program fe1nvol12
```

the following output is produced:

```bash
$ flang-new -fc1 snem0601_012_.f90
/noback/93u/Sandbox/issue_58973_volatile_dummy_arg/snem0601_012_.f90:21:12: warning: actual argument associated with VOLATILE dummy argument 'm6=' is not a variable
    call sub(6,error)
             ^
```

Reviewed By: clementval, klausler

Differential Revision: https://reviews.llvm.org/D139134
flang/lib/Semantics/check-call.cpp
flang/test/Semantics/call30.f90 [new file with mode: 0644]