|
|
999efc |
From 2de74ecd251387201ab78f614e73f67c8ad89033 Mon Sep 17 00:00:00 2001
|
|
|
999efc |
From: Mark Eggleston <markeggleston@gcc.gnu.org>
|
|
|
999efc |
Date: Mon, 3 Feb 2020 08:52:58 +0000
|
|
|
999efc |
Subject: [PATCH 03/10] Allow more than one character as argument to ICHAR
|
|
|
999efc |
|
|
|
999efc |
Use -fdec to enable.
|
|
|
999efc |
---
|
|
|
999efc |
gcc/fortran/check.c | 2 +-
|
|
|
999efc |
gcc/fortran/simplify.c | 4 ++--
|
|
|
999efc |
gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f | 21 +++++++++++++++++++++
|
|
|
999efc |
3 files changed, 24 insertions(+), 3 deletions(-)
|
|
|
999efc |
create mode 100644 gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
|
|
|
999efc |
|
|
|
999efc |
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
|
|
|
999efc |
index 148a3269815..4c0b83e8e6f 100644
|
|
|
999efc |
--- a/gcc/fortran/check.c
|
|
|
999efc |
+++ b/gcc/fortran/check.c
|
|
|
999efc |
@@ -3154,7 +3154,7 @@ gfc_check_ichar_iachar (gfc_expr *c, gfc_expr *kind)
|
|
|
999efc |
else
|
|
|
999efc |
return true;
|
|
|
999efc |
|
|
|
999efc |
- if (i != 1)
|
|
|
999efc |
+ if (i != 1 && !flag_dec)
|
|
|
999efc |
{
|
|
|
999efc |
gfc_error ("Argument of %s at %L must be of length one",
|
|
|
999efc |
gfc_current_intrinsic, &c->where);
|
|
|
999efc |
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
|
|
|
999efc |
index eb8b2afeb29..248fe05ee48 100644
|
|
|
999efc |
--- a/gcc/fortran/simplify.c
|
|
|
999efc |
+++ b/gcc/fortran/simplify.c
|
|
|
999efc |
@@ -3229,7 +3229,7 @@ gfc_simplify_iachar (gfc_expr *e, gfc_expr *kind)
|
|
|
999efc |
if (e->expr_type != EXPR_CONSTANT)
|
|
|
999efc |
return NULL;
|
|
|
999efc |
|
|
|
999efc |
- if (e->value.character.length != 1)
|
|
|
999efc |
+ if (e->value.character.length != 1 && !flag_dec)
|
|
|
999efc |
{
|
|
|
999efc |
gfc_error ("Argument of IACHAR at %L must be of length one", &e->where);
|
|
|
999efc |
return &gfc_bad_expr;
|
|
|
999efc |
@@ -3427,7 +3427,7 @@ gfc_simplify_ichar (gfc_expr *e, gfc_expr *kind)
|
|
|
999efc |
if (e->expr_type != EXPR_CONSTANT)
|
|
|
999efc |
return NULL;
|
|
|
999efc |
|
|
|
999efc |
- if (e->value.character.length != 1)
|
|
|
999efc |
+ if (e->value.character.length != 1 && !flag_dec)
|
|
|
999efc |
{
|
|
|
999efc |
gfc_error ("Argument of ICHAR at %L must be of length one", &e->where);
|
|
|
999efc |
return &gfc_bad_expr;
|
|
|
999efc |
diff --git a/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
|
|
|
999efc |
new file mode 100644
|
|
|
999efc |
index 00000000000..85efccecc0f
|
|
|
999efc |
--- /dev/null
|
|
|
999efc |
+++ b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
|
|
|
999efc |
@@ -0,0 +1,21 @@
|
|
|
999efc |
+! { dg-do run }
|
|
|
999efc |
+! { dg-options "-fdec" }
|
|
|
999efc |
+!
|
|
|
999efc |
+! Test ICHAR and IACHAR with more than one character as argument
|
|
|
999efc |
+!
|
|
|
999efc |
+! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
|
|
|
999efc |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
999efc |
+!
|
|
|
999efc |
+ PROGRAM ichar_more_than_one_character
|
|
|
999efc |
+ CHARACTER*4 st/'Test'/
|
|
|
999efc |
+ INTEGER i
|
|
|
999efc |
+
|
|
|
999efc |
+ i = ICHAR(st)
|
|
|
999efc |
+ if (i.NE.84) STOP 1
|
|
|
999efc |
+ i = IACHAR(st)
|
|
|
999efc |
+ if (i.NE.84) STOP 2
|
|
|
999efc |
+ i = ICHAR('Test')
|
|
|
999efc |
+ if (i.NE.84) STOP 3
|
|
|
999efc |
+ i = IACHAR('Test')
|
|
|
999efc |
+ if (i.NE.84) STOP 4
|
|
|
999efc |
+ END
|
|
|
999efc |
--
|
|
|
999efc |
2.11.0
|
|
|
999efc |
|