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

2985e0
From d75972937274489189a151a47da9b9aadfdefe8d Mon Sep 17 00:00:00 2001
2985e0
From: Jim MacArthur <jim.macarthur@codethink.co.uk>
2985e0
Date: Mon, 5 Oct 2015 13:45:15 +0100
2985e0
Subject: [PATCH 07/23] Allow more than one character as argument to ICHAR
2985e0
2985e0
This feature is enabled by the `-std=extra-legacy` compiler flag.
2985e0
---
2985e0
2985e0
commit 44861a8907c8d849193287231a464d34fcce522d
2985e0
Author: Jim MacArthur <jim.macarthur@codethink.co.uk>
2985e0
Date:   Mon Oct 5 13:45:15 2015 +0100
2985e0
2985e0
    Allow more than one character as argument to ICHAR
2985e0
    
2985e0
    This feature is enabled by the `-std=extra-legacy` compiler flag.
2985e0
    
2985e0
    Test written by: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
2985e0
2985e0
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
2985e0
index 4f2d21610b9..38a90519c81 100644
2985e0
--- a/gcc/fortran/check.c
2985e0
+++ b/gcc/fortran/check.c
2985e0
@@ -2472,7 +2472,7 @@ gfc_check_ichar_iachar (gfc_expr *c, gfc_expr *kind)
2985e0
   else
2985e0
     return true;
2985e0
 
2985e0
-  if (i != 1)
2985e0
+  if (i != 1 && !(gfc_option.allow_std & GFC_STD_EXTRA_LEGACY))
2985e0
     {
2985e0
       gfc_error ("Argument of %s at %L must be of length one",
2985e0
 		 gfc_current_intrinsic, &c->where);
2985e0
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
2985e0
index 80c96371ad9..6e05bb444ed 100644
2985e0
--- a/gcc/fortran/simplify.c
2985e0
+++ b/gcc/fortran/simplify.c
2985e0
@@ -2774,7 +2774,7 @@ gfc_simplify_iachar (gfc_expr *e, gfc_expr *kind)
2985e0
   if (e->expr_type != EXPR_CONSTANT)
2985e0
     return NULL;
2985e0
 
2985e0
-  if (e->value.character.length != 1)
2985e0
+  if (e->value.character.length != 1 && !(gfc_option.allow_std & GFC_STD_EXTRA_LEGACY))
2985e0
     {
2985e0
       gfc_error ("Argument of IACHAR at %L must be of length one", &e->where);
2985e0
       return &gfc_bad_expr;
2985e0
@@ -2972,7 +2972,7 @@ gfc_simplify_ichar (gfc_expr *e, gfc_expr *kind)
2985e0
   if (e->expr_type != EXPR_CONSTANT)
2985e0
     return NULL;
2985e0
 
2985e0
-  if (e->value.character.length != 1)
2985e0
+  if (e->value.character.length != 1 && !(gfc_option.allow_std & GFC_STD_EXTRA_LEGACY))
2985e0
     {
2985e0
       gfc_error ("Argument of ICHAR at %L must be of length one", &e->where);
2985e0
       return &gfc_bad_expr;
2985e0
diff --git a/gcc/testsuite/gfortran.dg/dec_ichar_with_string.f b/gcc/testsuite/gfortran.dg/dec_ichar_with_string.f
2985e0
new file mode 100644
2985e0
index 00000000000..c97746d4a4e
2985e0
--- /dev/null
2985e0
+++ b/gcc/testsuite/gfortran.dg/dec_ichar_with_string.f
2985e0
@@ -0,0 +1,18 @@
2985e0
+! { dg-do compile }
2985e0
+! { dg-options "-std=extra-legacy" }
2985e0
+!
2985e0
+! Test ICHAR and IACHAR with more than one character as argument
2985e0
+!
2985e0
+        PROGRAM ichar_more_than_one_character
2985e0
+          CHARACTER*4 st/'Test'/
2985e0
+          INTEGER i
2985e0
+
2985e0
+          i = ICHAR(st)
2985e0
+          if (i.NE.84) STOP 1
2985e0
+          i = IACHAR(st)
2985e0
+          if (i.NE.84) STOP 2
2985e0
+          i = ICHAR('Test')
2985e0
+          if (i.NE.84) STOP 3
2985e0
+          i = IACHAR('Test')
2985e0
+          if (i.NE.84) STOP 4
2985e0
+        END