aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/io.c
diff options
context:
space:
mode:
authorFeng Wang <fengwang@nudt.edu.cn>2005-07-07 07:54:58 +0000
committerFeng Wang <fengwang@gcc.gnu.org>2005-07-07 07:54:58 +0000
commitd3642f893a731c246c8e7d8e8542abbd238daac6 (patch)
tree7bfda0a20b79d65d1ac562cb286d5799c84e43db /gcc/fortran/io.c
parent378f73afe05d3dbce185f9ab74f0c24e53f4b218 (diff)
downloadgcc-d3642f893a731c246c8e7d8e8542abbd238daac6.zip
gcc-d3642f893a731c246c8e7d8e8542abbd238daac6.tar.gz
gcc-d3642f893a731c246c8e7d8e8542abbd238daac6.tar.bz2
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. From-SVN: r101688
Diffstat (limited to 'gcc/fortran/io.c')
-rw-r--r--gcc/fortran/io.c68
1 files changed, 49 insertions, 19 deletions
diff --git a/gcc/fortran/io.c b/gcc/fortran/io.c
index ef51308..abfeead 100644
--- a/gcc/fortran/io.c
+++ b/gcc/fortran/io.c
@@ -969,33 +969,63 @@ resolve_tag (const io_tag * tag, gfc_expr * e)
if (gfc_resolve_expr (e) == FAILURE)
return FAILURE;
- if (e->ts.type != tag->type)
+ if (e->ts.type != tag->type && tag != &tag_format)
{
- /* Format label can be integer varibale. */
- if (tag != &tag_format || e->ts.type != BT_INTEGER)
- {
- gfc_error ("%s tag at %L must be of type %s or %s", tag->name,
- &e->where, gfc_basic_typename (tag->type),
- gfc_basic_typename (BT_INTEGER));
- return FAILURE;
- }
+ gfc_error ("%s tag at %L must be of type %s", tag->name,
+ &e->where, gfc_basic_typename (tag->type));
+ return FAILURE;
}
if (tag == &tag_format)
{
- if (e->rank != 1 && e->rank != 0)
+ /* If e's rank is zero and e is not an element of an array, it should be
+ of integer or character type. The integer variable should be
+ ASSIGNED. */
+ if (e->symtree == NULL || e->symtree->n.sym->as == NULL
+ || e->symtree->n.sym->as->rank == 0)
{
- gfc_error ("FORMAT tag at %L cannot be array of strings",
- &e->where);
- return FAILURE;
+ if (e->ts.type != BT_CHARACTER && e->ts.type != BT_INTEGER)
+ {
+ gfc_error ("%s tag at %L must be of type %s or %s", tag->name,
+ &e->where, gfc_basic_typename (BT_CHARACTER),
+ gfc_basic_typename (BT_INTEGER));
+ return FAILURE;
+ }
+ else if (e->ts.type == BT_INTEGER && e->expr_type == EXPR_VARIABLE)
+ {
+ if (gfc_notify_std (GFC_STD_F95_DEL,
+ "Obsolete: ASSIGNED variable in FORMAT tag at %L",
+ &e->where) == FAILURE)
+ return FAILURE;
+ if (e->symtree->n.sym->attr.assign != 1)
+ {
+ gfc_error ("Variable '%s' at %L has not been assigned a "
+ "format label", e->symtree->n.sym->name, &e->where);
+ return FAILURE;
+ }
+ }
+ return SUCCESS;
}
- /* Check assigned label. */
- if (e->expr_type == EXPR_VARIABLE && e->ts.type == BT_INTEGER
- && e->symtree->n.sym->attr.assign != 1)
+ else
{
- gfc_error ("Variable '%s' has not been assigned a format label at %L",
- e->symtree->n.sym->name, &e->where);
- return FAILURE;
+ /* if rank is nonzero, we allow the type to be character under
+ GFC_STD_GNU and other type under GFC_STD_LEGACY. It may be
+ assigned an Hollerith constant. */
+ if (e->ts.type == BT_CHARACTER)
+ {
+ if (gfc_notify_std (GFC_STD_GNU,
+ "Extension: Character array in FORMAT tag at %L",
+ &e->where) == FAILURE)
+ return FAILURE;
+ }
+ else
+ {
+ if (gfc_notify_std (GFC_STD_LEGACY,
+ "Extension: Non-character in FORMAT tag at %L",
+ &e->where) == FAILURE)
+ return FAILURE;
+ }
+ return SUCCESS;
}
}
else