|
|
6f0f47 |
From f883ac209b0feea860354cb4ef7ff06dc8063fab Mon Sep 17 00:00:00 2001
|
|
|
6f0f47 |
From: Mark Eggleston <markeggleston@gcc.gnu.org>
|
|
|
6f0f47 |
Date: Fri, 22 Jan 2021 12:53:35 +0000
|
|
|
6f0f47 |
Subject: [PATCH 03/10] Allow more than one character as argument to ICHAR
|
|
|
6f0f47 |
|
|
|
6f0f47 |
Use -fdec to enable.
|
|
|
6f0f47 |
---
|
|
|
6f0f47 |
gcc/fortran/check.c | 2 +-
|
|
|
6f0f47 |
gcc/fortran/simplify.c | 4 ++--
|
|
|
6f0f47 |
.../gfortran.dg/dec_ichar_with_string_1.f | 21 +++++++++++++++++++
|
|
|
6f0f47 |
3 files changed, 24 insertions(+), 3 deletions(-)
|
|
|
6f0f47 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
|
|
|
6f0f47 |
|
|
|
6f0f47 |
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
|
|
|
6f0f47 |
index 82db8e4e1b2..623c1cc470e 100644
|
|
|
6f0f47 |
--- a/gcc/fortran/check.c
|
|
|
6f0f47 |
+++ b/gcc/fortran/check.c
|
|
|
6f0f47 |
@@ -3157,7 +3157,7 @@ gfc_check_ichar_iachar (gfc_expr *c, gfc_expr *kind)
|
|
|
6f0f47 |
else
|
|
|
6f0f47 |
return true;
|
|
|
6f0f47 |
|
|
|
6f0f47 |
- if (i != 1)
|
|
|
6f0f47 |
+ if (i != 1 && !flag_dec)
|
|
|
6f0f47 |
{
|
|
|
6f0f47 |
gfc_error ("Argument of %s at %L must be of length one",
|
|
|
6f0f47 |
gfc_current_intrinsic, &c->where);
|
|
|
6f0f47 |
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
|
|
|
6f0f47 |
index 23317a2e2d9..9900572424f 100644
|
|
|
6f0f47 |
--- a/gcc/fortran/simplify.c
|
|
|
6f0f47 |
+++ b/gcc/fortran/simplify.c
|
|
|
6f0f47 |
@@ -3261,7 +3261,7 @@ gfc_simplify_iachar (gfc_expr *e, gfc_expr *kind)
|
|
|
6f0f47 |
if (e->expr_type != EXPR_CONSTANT)
|
|
|
6f0f47 |
return NULL;
|
|
|
6f0f47 |
|
|
|
6f0f47 |
- if (e->value.character.length != 1)
|
|
|
6f0f47 |
+ if (e->value.character.length != 1 && !flag_dec)
|
|
|
6f0f47 |
{
|
|
|
6f0f47 |
gfc_error ("Argument of IACHAR at %L must be of length one", &e->where);
|
|
|
6f0f47 |
return &gfc_bad_expr;
|
|
|
6f0f47 |
@@ -3459,7 +3459,7 @@ gfc_simplify_ichar (gfc_expr *e, gfc_expr *kind)
|
|
|
6f0f47 |
if (e->expr_type != EXPR_CONSTANT)
|
|
|
6f0f47 |
return NULL;
|
|
|
6f0f47 |
|
|
|
6f0f47 |
- if (e->value.character.length != 1)
|
|
|
6f0f47 |
+ if (e->value.character.length != 1 && !flag_dec)
|
|
|
6f0f47 |
{
|
|
|
6f0f47 |
gfc_error ("Argument of ICHAR at %L must be of length one", &e->where);
|
|
|
6f0f47 |
return &gfc_bad_expr;
|
|
|
6f0f47 |
diff --git a/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
|
|
|
6f0f47 |
new file mode 100644
|
|
|
6f0f47 |
index 00000000000..85efccecc0f
|
|
|
6f0f47 |
--- /dev/null
|
|
|
6f0f47 |
+++ b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
|
|
|
6f0f47 |
@@ -0,0 +1,21 @@
|
|
|
6f0f47 |
+! { dg-do run }
|
|
|
6f0f47 |
+! { dg-options "-fdec" }
|
|
|
6f0f47 |
+!
|
|
|
6f0f47 |
+! Test ICHAR and IACHAR with more than one character as argument
|
|
|
6f0f47 |
+!
|
|
|
6f0f47 |
+! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
|
|
|
6f0f47 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
6f0f47 |
+!
|
|
|
6f0f47 |
+ PROGRAM ichar_more_than_one_character
|
|
|
6f0f47 |
+ CHARACTER*4 st/'Test'/
|
|
|
6f0f47 |
+ INTEGER i
|
|
|
6f0f47 |
+
|
|
|
6f0f47 |
+ i = ICHAR(st)
|
|
|
6f0f47 |
+ if (i.NE.84) STOP 1
|
|
|
6f0f47 |
+ i = IACHAR(st)
|
|
|
6f0f47 |
+ if (i.NE.84) STOP 2
|
|
|
6f0f47 |
+ i = ICHAR('Test')
|
|
|
6f0f47 |
+ if (i.NE.84) STOP 3
|
|
|
6f0f47 |
+ i = IACHAR('Test')
|
|
|
6f0f47 |
+ if (i.NE.84) STOP 4
|
|
|
6f0f47 |
+ END
|
|
|
6f0f47 |
--
|
|
|
6f0f47 |
2.27.0
|
|
|
6f0f47 |
|