Blame SOURCES/0007-Allow-more-than-one-character-as-argument-to-ICHAR.patch

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