You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.6 KiB
79 lines
2.6 KiB
From 2de74ecd251387201ab78f614e73f67c8ad89033 Mon Sep 17 00:00:00 2001
|
|
From: Mark Eggleston <markeggleston@gcc.gnu.org>
|
|
Date: Mon, 3 Feb 2020 08:52:58 +0000
|
|
Subject: [PATCH 03/10] Allow more than one character as argument to ICHAR
|
|
|
|
Use -fdec to enable.
|
|
---
|
|
gcc/fortran/check.c | 2 +-
|
|
gcc/fortran/simplify.c | 4 ++--
|
|
gcc/testsuite/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.c b/gcc/fortran/check.c
|
|
index 148a3269815..4c0b83e8e6f 100644
|
|
--- a/gcc/fortran/check.c
|
|
+++ b/gcc/fortran/check.c
|
|
@@ -3154,7 +3154,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.c b/gcc/fortran/simplify.c
|
|
index eb8b2afeb29..248fe05ee48 100644
|
|
--- a/gcc/fortran/simplify.c
|
|
+++ b/gcc/fortran/simplify.c
|
|
@@ -3229,7 +3229,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;
|
|
@@ -3427,7 +3427,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 <jim.macarthur@codethink.co.uk>
|
|
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
+!
|
|
+ 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.11.0
|
|
|