[flang-commits] [flang] change exitstat and cmsstat from AnyInt to DefaultInt (PR #78286)
via flang-commits
flang-commits at lists.llvm.org
Tue Jan 16 06:16:16 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Yi Wu (yi-wu-arm)
<details>
<summary>Changes</summary>
When testing on gcc, both exitstat and cmdstat must be a kind=4 integer, e.g. DefaultInt. This patch change the input arg requirement from AnyInt to DefaultInt.
The standard stated in 16.9.73
- EXITSTAT (optional) shall be a scalar of type integer with a decimal exponent range of at least nine.
- CMDSTAT (optional) shall be a scalar of type integer with a decimal exponent range of at least four.
```fortran
program bug
implicit none
integer(kind = 2) :: exitstatvar
integer(kind = 4) :: cmdstatvar
character(len=256) :: msg
character(len=:), allocatable :: command
command='echo hello'
call execute_command_line(command, exitstat=exitstatvar, cmdstat=cmdstatvar)
end program
```
When testing the above program with kind != 4, an error would occur:
```
$ ../build-release/bin/flang-new test.f90
error: Semantic errors in test.f90
./test.f90:8:47: error: Actual argument for 'exitstat=' has bad type or kind 'INTEGER(2)'
call execute_command_line(command, exitstat=exitstatvar, cmdstat=cmdstatvar)
```
Fixes: https://github.com/llvm/llvm-project/issues/77990
---
Full diff: https://github.com/llvm/llvm-project/pull/78286.diff
1 Files Affected:
- (modified) flang/lib/Evaluate/intrinsics.cpp (+2-2)
``````````diff
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index da6d5970089884c..0b9bdac88a78dcf 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1314,9 +1314,9 @@ static const IntrinsicInterface intrinsicSubroutine[]{
{"execute_command_line",
{{"command", DefaultChar, Rank::scalar},
{"wait", AnyLogical, Rank::scalar, Optionality::optional},
- {"exitstat", AnyInt, Rank::scalar, Optionality::optional,
+ {"exitstat", DefaultInt, Rank::scalar, Optionality::optional,
common::Intent::InOut},
- {"cmdstat", AnyInt, Rank::scalar, Optionality::optional,
+ {"cmdstat", DefaultInt, Rank::scalar, Optionality::optional,
common::Intent::Out},
{"cmdmsg", DefaultChar, Rank::scalar, Optionality::optional,
common::Intent::InOut}},
``````````
</details>
https://github.com/llvm/llvm-project/pull/78286
More information about the flang-commits
mailing list