summaryrefslogtreecommitdiff
path: root/gcc/fortran/expr.c
diff options
context:
space:
mode:
authorfengwang <fengwang@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-07 07:54:58 +0000
committerfengwang <fengwang@138bc75d-0d04-0410-961f-82ee72b054a4>2005-07-07 07:54:58 +0000
commit169f9d09e5d61b72aebc64c5a6632bc376ba2081 (patch)
tree7bfda0a20b79d65d1ac562cb286d5799c84e43db /gcc/fortran/expr.c
parentbbe50a5a148bb7e80ca9447e91950e7be867ea9f (diff)
downloadgcc-169f9d09e5d61b72aebc64c5a6632bc376ba2081.tar.gz
For the 60th anniversary of Chinese people��s Anti-Japan war victory.
2005-07-07 Feng Wang <fengwang@nudt.edu.cn> PR fortran/16531 PR fortran/15966 PR fortran/18781 * arith.c (gfc_hollerith2int, gfc_hollerith2real, gfc_hollerith2complex, gfc_hollerith2character, gfc_hollerith2logical): New functions. (eval_intrinsic): Don't evaluate if Hollerith constant arguments exist. * arith.h (gfc_hollerith2int, gfc_hollerith2real, gfc_hollerith2complex, gfc_hollerith2character, gfc_hollerith2logical): Add prototypes. * expr.c (free_expr0): Free memery allocated for Hollerith constant. (gfc_copy_expr): Allocate and copy string if Expr is from Hollerith. (gfc_check_assign): Enable conversion from Hollerith to other. * gfortran.h (bt): Add BT_HOLLERITH. (gfc_expr): Add from_H flag. * intrinsic.c (gfc_type_letter): Return 'h' for BT_HOLLERITH. (add_conversions): Add conversions from Hollerith constant to other. (do_simplify): Don't simplify if Hollerith constant arguments exist. * io.c (resolve_tag): Enable array in FORMAT tag under GFC_STD_GNU. * misc.c (gfc_basetype_name): Return "HOLLERITH" for BT_HOLLERITH. (gfc_type_name): Print "HOLLERITH" for BT_HOLLERITH. * primary.c (match_hollerith_constant): New function. (gfc_match_literal_constant): Add match Hollerith before Integer. * simplify.c (gfc_convert_constant): Add conversion from Hollerith to other. * trans-const.c (gfc_conv_constant_to_tree): Use VIEW_CONVERT_EXPR to convert Hollerith constant to tree. * trans-io.c (gfc_convert_array_to_string): Get array's address and length to set string expr. (set_string): Deal with array assigned Hollerith constant and character array. * gfortran.texi: Document Hollerith constants as extention support. 2005-07-07 Feng Wang <fengwang@nudt.edu.cn> PR fortran/16531 PR fortran/15966 PR fortran/18781 * gfortran.dg/hollerith.f90: New. * gfortran.dg/hollerith2.f90: New. * gfortran.dg/hollerith3.f90: New. * gfortran.dg/hollerith4.f90: New. * gfortran.dg/hollerith_f95.f90: New. * gfortran.dg/hollerith_legacy.f90: New. * gfortran.dg/g77/cpp4.F: New. Port from g77. 2005-07-07 Feng Wang <fengwang@nudt.edu.cn> PR fortran/16531 * io/transfer.c (formatted_transfer): Enable FMT_A on other types to support Hollerith constants. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101688 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r--gcc/fortran/expr.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index fe4c74603ac..a3a24b59f40 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -141,6 +141,12 @@ free_expr0 (gfc_expr * e)
switch (e->expr_type)
{
case EXPR_CONSTANT:
+ if (e->from_H)
+ {
+ gfc_free (e->value.character.string);
+ break;
+ }
+
switch (e->ts.type)
{
case BT_INTEGER:
@@ -152,6 +158,7 @@ free_expr0 (gfc_expr * e)
break;
case BT_CHARACTER:
+ case BT_HOLLERITH:
gfc_free (e->value.character.string);
break;
@@ -393,6 +400,15 @@ gfc_copy_expr (gfc_expr * p)
break;
case EXPR_CONSTANT:
+ if (p->from_H)
+ {
+ s = gfc_getmem (p->value.character.length + 1);
+ q->value.character.string = s;
+
+ memcpy (s, p->value.character.string,
+ p->value.character.length + 1);
+ break;
+ }
switch (q->ts.type)
{
case BT_INTEGER:
@@ -414,6 +430,7 @@ gfc_copy_expr (gfc_expr * p)
break;
case BT_CHARACTER:
+ case BT_HOLLERITH:
s = gfc_getmem (p->value.character.length + 1);
q->value.character.string = s;
@@ -1813,7 +1830,10 @@ gfc_check_assign (gfc_expr * lvalue, gfc_expr * rvalue, int conform)
if (!conform)
{
- if (gfc_numeric_ts (&lvalue->ts) && gfc_numeric_ts (&rvalue->ts))
+ /* Numeric can be converted to any other numeric. And Hollerith can be
+ converted to any other type. */
+ if ((gfc_numeric_ts (&lvalue->ts) && gfc_numeric_ts (&rvalue->ts))
+ || rvalue->ts.type == BT_HOLLERITH)
return SUCCESS;
if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)