From ced1b6638459f33dc9f22a0cd959f97c05a62e22 Mon Sep 17 00:00:00 2001
From: Jim MacArthur <jim.macarthur@codethink.co.uk>
Date: Wed, 7 Oct 2015 18:23:31 -0400
Subject: [PATCH 11/23] Allow character-to-int conversions in DATA statements
This feature is enabled by the `-std=extra-legacy` compiler flag.
---
0011-Allow-character-to-int-conversions-in-DATA-statement.patch
commit 11b148af8967669bcebd91ea6fdae28e9ec8e97c
Author: Jim MacArthur <jim.macarthur@codethink.co.uk>
Date: Wed Oct 7 18:23:31 2015 -0400
Allow character-to-int conversions in DATA statements
This feature is enabled by the `-std=extra-legacy` compiler flag.
Test written by: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index f347c753702..9982b8d0e85 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -3294,6 +3294,10 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, int conform,
|| rvalue->ts.type == BT_HOLLERITH)
return true;
+ if ((gfc_option.allow_std & GFC_STD_EXTRA_LEGACY)
+ && gfc_numeric_ts (&lvalue->ts) && rvalue->ts.type == BT_CHARACTER)
+ return true;
+
if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)
return true;
diff --git a/gcc/testsuite/gfortran.dg/dec_char_to_int_conversion_in_data.f b/gcc/testsuite/gfortran.dg/dec_char_to_int_conversion_in_data.f
new file mode 100644
index 00000000000..e0e4f735243
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dec_char_to_int_conversion_in_data.f
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-std=extra-legacy" }
+!
+! Test character to int conversion in DATA types
+!
+ PROGRAM char_int_data_type
+ INTEGER*1 ai(2)
+
+ DATA ai/'1',1/
+ if(ai(1).NE.49) STOP 1
+ END