[flang-commits] [flang] change exitstat and cmsstat from AnyInt to DefaultInt (PR #78286)
Yi Wu via flang-commits
flang-commits at lists.llvm.org
Tue Jan 16 06:15:39 PST 2024
https://github.com/yi-wu-arm created https://github.com/llvm/llvm-project/pull/78286
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
>From d56eca56c8e4c64e649febc43e2c48b6e5146680 Mon Sep 17 00:00:00 2001
From: Yi Wu <yi.wu2 at arm.com>
Date: Tue, 16 Jan 2024 14:08:00 +0000
Subject: [PATCH] change exitstat and cmsstat from AnyInt to DefaultInt
---
flang/lib/Evaluate/intrinsics.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index da6d5970089884..0b9bdac88a78dc 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}},
More information about the flang-commits
mailing list