|
|
d0de29 |
From d15e5e207e2a6b46edee2f2b5d3e4c1cc7cdb80f Mon Sep 17 00:00:00 2001
|
|
|
d0de29 |
From: Jim MacArthur <jim.macarthur@codethink.co.uk>
|
|
|
d0de29 |
Date: Mon, 5 Oct 2015 13:45:15 +0100
|
|
|
d0de29 |
Subject: [PATCH 07/16] Allow more than one character as argument to ICHAR
|
|
|
d0de29 |
|
|
|
d0de29 |
Use -fdec to enable..
|
|
|
d0de29 |
---
|
|
|
d0de29 |
gcc/fortran/check.c | 2 +-
|
|
|
d0de29 |
gcc/fortran/simplify.c | 4 ++--
|
|
|
d0de29 |
gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f | 21 +++++++++++++++++++++
|
|
|
d0de29 |
3 files changed, 24 insertions(+), 3 deletions(-)
|
|
|
d0de29 |
create mode 100644 gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
|
|
|
d0de29 |
|
|
|
d0de29 |
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
|
|
|
d0de29 |
index a04f0d66655..0ba4d0a031f 100644
|
|
|
d0de29 |
--- a/gcc/fortran/check.c
|
|
|
d0de29 |
+++ b/gcc/fortran/check.c
|
|
|
d0de29 |
@@ -2603,7 +2603,7 @@ gfc_check_ichar_iachar (gfc_expr *c, gfc_expr *kind)
|
|
|
d0de29 |
else
|
|
|
d0de29 |
return true;
|
|
|
d0de29 |
|
|
|
d0de29 |
- if (i != 1)
|
|
|
d0de29 |
+ if (i != 1 && !flag_dec)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
gfc_error ("Argument of %s at %L must be of length one",
|
|
|
d0de29 |
gfc_current_intrinsic, &c->where);
|
|
|
d0de29 |
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
|
|
|
d0de29 |
index 7d7e3f22f73..7aff256c6b3 100644
|
|
|
d0de29 |
--- a/gcc/fortran/simplify.c
|
|
|
d0de29 |
+++ b/gcc/fortran/simplify.c
|
|
|
d0de29 |
@@ -3229,7 +3229,7 @@ gfc_simplify_iachar (gfc_expr *e, gfc_expr *kind)
|
|
|
d0de29 |
if (e->expr_type != EXPR_CONSTANT)
|
|
|
d0de29 |
return NULL;
|
|
|
d0de29 |
|
|
|
d0de29 |
- if (e->value.character.length != 1)
|
|
|
d0de29 |
+ if (e->value.character.length != 1 && !flag_dec)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
gfc_error ("Argument of IACHAR at %L must be of length one", &e->where);
|
|
|
d0de29 |
return &gfc_bad_expr;
|
|
|
d0de29 |
@@ -3427,7 +3427,7 @@ gfc_simplify_ichar (gfc_expr *e, gfc_expr *kind)
|
|
|
d0de29 |
if (e->expr_type != EXPR_CONSTANT)
|
|
|
d0de29 |
return NULL;
|
|
|
d0de29 |
|
|
|
d0de29 |
- if (e->value.character.length != 1)
|
|
|
d0de29 |
+ if (e->value.character.length != 1 && !flag_dec)
|
|
|
d0de29 |
{
|
|
|
d0de29 |
gfc_error ("Argument of ICHAR at %L must be of length one", &e->where);
|
|
|
d0de29 |
return &gfc_bad_expr;
|
|
|
d0de29 |
diff --git a/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
|
|
|
d0de29 |
new file mode 100644
|
|
|
d0de29 |
index 00000000000..85efccecc0f
|
|
|
d0de29 |
--- /dev/null
|
|
|
d0de29 |
+++ b/gcc/testsuite/gfortran.dg/dec_ichar_with_string_1.f
|
|
|
d0de29 |
@@ -0,0 +1,21 @@
|
|
|
d0de29 |
+! { dg-do run }
|
|
|
d0de29 |
+! { dg-options "-fdec" }
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test ICHAR and IACHAR with more than one character as argument
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+! Test case contributed by Jim MacArthur <jim.macarthur@codethink.co.uk>
|
|
|
d0de29 |
+! Modified by Mark Eggleston <mark.eggleston@codethink.com>
|
|
|
d0de29 |
+!
|
|
|
d0de29 |
+ PROGRAM ichar_more_than_one_character
|
|
|
d0de29 |
+ CHARACTER*4 st/'Test'/
|
|
|
d0de29 |
+ INTEGER i
|
|
|
d0de29 |
+
|
|
|
d0de29 |
+ i = ICHAR(st)
|
|
|
d0de29 |
+ if (i.NE.84) STOP 1
|
|
|
d0de29 |
+ i = IACHAR(st)
|
|
|
d0de29 |
+ if (i.NE.84) STOP 2
|
|
|
d0de29 |
+ i = ICHAR('Test')
|
|
|
d0de29 |
+ if (i.NE.84) STOP 3
|
|
|
d0de29 |
+ i = IACHAR('Test')
|
|
|
d0de29 |
+ if (i.NE.84) STOP 4
|
|
|
d0de29 |
+ END
|
|
|
d0de29 |
--
|
|
|
d0de29 |
2.11.0
|
|
|
d0de29 |
|