[fortran,patch]Enable Hollerith constant and character array in format tag (2nd).

Feng Wang fengwang@nudt.edu.cn
Tue May 24 16:01:00 GMT 2005


I rewrite the patch I posted on:
http://gcc.gnu.org/ml/fortran/2005-03/msg00502.html

Add the document of Hollerith constants in 
gfortran.texi as the extention support of gfortran. In 
my implementation, the Hollerith constants can be used 
as the right hands in the DATA statement and ASSIGN 
statement, also as the arguments. The left hands can 
be of Integer, Real, Complex and Logical type. The 
constant will be padded or trancated to fit the size 
of left hand.

To deal with the calculatation of Hollerith constants, 
I leave it to the run-time. See eval_intrinsic() in 
arith.c and do_simplify() in intrinsics.c.

I find only one Hollerith constant test in g77 
testsuites named cpp2.F. I ported to gfortran and 
attached here. The other three tests attached check 
almost all the patch.

The patch is tested with no regression on i686.

Many thanks to Richard E Maine, Steven B, Steve Kargl, 
Paul B, etc. for discussion this topic on the list.

Best Regards,
Feng Wang

fortran/ChangeLog entry:
2005-05-24  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.

libgfortran/ChangeLog entry:
2005-05-24  Feng Wang  <fengwang@nudt.edu.cn>

	PR fortran/16531
	* io/transfer.c (formatted_transfer): Enable 
FMT_A on other types.

--
Creative Compiler Research Group,
National University of Defense Technology, China.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cpp4.F
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050524/b7be786e/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hollerith.f90
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050524/b7be786e/attachment.f90>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hollerith2.f90
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050524/b7be786e/attachment-0001.f90>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hollerith3.f90
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050524/b7be786e/attachment-0002.f90>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: lib.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050524/b7be786e/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hollerith_v10.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050524/b7be786e/attachment-0002.ksh>


More information about the Fortran mailing list