1 Star 0 Fork 14

ticat_fp/ocs_spec_gcc

forked from OpenCloudOS Stream/gcc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
gcc12-fortran-fdec-ichar.patch 2.62 KB
一键复制 编辑 原始数据 按行查看 历史
nilusyi 提交于 2022-10-25 14:34 . init repo
From f883ac209b0feea860354cb4ef7ff06dc8063fab Mon Sep 17 00:00:00 2001
From: Mark Eggleston <[email protected]>
Date: Fri, 22 Jan 2021 12:53:35 +0000
Subject: [PATCH 03/10] Allow more than one character as argument to ICHAR
Use -fdec to enable.
---
gcc/fortran/check.cc | 2 +-
gcc/fortran/simplify.cc | 4 ++--
.../gfortran.dg/dec_ichar_with_string_1.f | 21 +++++++++++++++++++
3 files changed, 24 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc
index 82db8e4e1b2..623c1cc470e 100644
--- a/gcc/fortran/check.cc
+++ b/gcc/fortran/check.cc
@@ -3157,7 +3157,7 @@ gfc_check_ichar_iachar (gfc_expr *c, gfc_expr *kind)
else
return true;
- if (i != 1)
+ if (i != 1 && !flag_dec)
{
gfc_error ("Argument of %s at %L must be of length one",
gfc_current_intrinsic, &c->where);
diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index 23317a2e2d9..9900572424f 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -3261,7 +3261,7 @@ gfc_simplify_iachar (gfc_expr *e, gfc_expr *kind)
if (e->expr_type != EXPR_CONSTANT)
return NULL;
- if (e->value.character.length != 1)
+ if (e->value.character.length != 1 && !flag_dec)
{
gfc_error ("Argument of IACHAR at %L must be of length one", &e->where);
return &gfc_bad_expr;
@@ -3459,7 +3459,7 @@ gfc_simplify_ichar (gfc_expr *e, gfc_expr *kind)
if (e->expr_type != EXPR_CONSTANT)
return NULL;
- if (e->value.character.length != 1)
+ if (e->value.character.length != 1 && !flag_dec)
{
gfc_error ("Argument of ICHAR at %L must be of length one", &e->where);
return &gfc_bad_expr;
diff --git a/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
new file mode 100644
index 00000000000..85efccecc0f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
@@ -0,0 +1,21 @@
+! { dg-do run }
+! { dg-options "-fdec" }
+!
+! Test ICHAR and IACHAR with more than one character as argument
+!
+! Test case contributed by Jim MacArthur <[email protected]>
+! Modified by Mark Eggleston <[email protected]>
+!
+ PROGRAM ichar_more_than_one_character
+ CHARACTER*4 st/'Test'/
+ INTEGER i
+
+ i = ICHAR(st)
+ if (i.NE.84) STOP 1
+ i = IACHAR(st)
+ if (i.NE.84) STOP 2
+ i = ICHAR('Test')
+ if (i.NE.84) STOP 3
+ i = IACHAR('Test')
+ if (i.NE.84) STOP 4
+ END
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ticat-fp/ocs_spec_gcc.git
[email protected]:ticat-fp/ocs_spec_gcc.git
ticat-fp
ocs_spec_gcc
ocs_spec_gcc
master

搜索帮助