xref: /openbsd/gnu/usr.bin/gcc/gcc/f/ste.c (revision c87b03e5)
1*c87b03e5Sespie /* ste.c -- Implementation File (module.c template V1.0)
2*c87b03e5Sespie    Copyright (C) 1995, 1996, 2000, 2002, 2003 Free Software Foundation, Inc.
3*c87b03e5Sespie    Contributed by James Craig Burley.
4*c87b03e5Sespie 
5*c87b03e5Sespie This file is part of GNU Fortran.
6*c87b03e5Sespie 
7*c87b03e5Sespie GNU Fortran is free software; you can redistribute it and/or modify
8*c87b03e5Sespie it under the terms of the GNU General Public License as published by
9*c87b03e5Sespie the Free Software Foundation; either version 2, or (at your option)
10*c87b03e5Sespie any later version.
11*c87b03e5Sespie 
12*c87b03e5Sespie GNU Fortran is distributed in the hope that it will be useful,
13*c87b03e5Sespie but WITHOUT ANY WARRANTY; without even the implied warranty of
14*c87b03e5Sespie MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*c87b03e5Sespie GNU General Public License for more details.
16*c87b03e5Sespie 
17*c87b03e5Sespie You should have received a copy of the GNU General Public License
18*c87b03e5Sespie along with GNU Fortran; see the file COPYING.  If not, write to
19*c87b03e5Sespie the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20*c87b03e5Sespie 02111-1307, USA.
21*c87b03e5Sespie 
22*c87b03e5Sespie    Related Modules:
23*c87b03e5Sespie       ste.c
24*c87b03e5Sespie 
25*c87b03e5Sespie    Description:
26*c87b03e5Sespie       Implements the various statements and such like.
27*c87b03e5Sespie 
28*c87b03e5Sespie    Modifications:
29*c87b03e5Sespie */
30*c87b03e5Sespie 
31*c87b03e5Sespie /* Include files. */
32*c87b03e5Sespie 
33*c87b03e5Sespie #include "proj.h"
34*c87b03e5Sespie #include "rtl.h"
35*c87b03e5Sespie #include "toplev.h"
36*c87b03e5Sespie #include "ggc.h"
37*c87b03e5Sespie #include "ste.h"
38*c87b03e5Sespie #include "bld.h"
39*c87b03e5Sespie #include "com.h"
40*c87b03e5Sespie #include "expr.h"
41*c87b03e5Sespie #include "lab.h"
42*c87b03e5Sespie #include "lex.h"
43*c87b03e5Sespie #include "sta.h"
44*c87b03e5Sespie #include "stp.h"
45*c87b03e5Sespie #include "str.h"
46*c87b03e5Sespie #include "sts.h"
47*c87b03e5Sespie #include "stt.h"
48*c87b03e5Sespie #include "stv.h"
49*c87b03e5Sespie #include "stw.h"
50*c87b03e5Sespie #include "symbol.h"
51*c87b03e5Sespie 
52*c87b03e5Sespie /* Externals defined here. */
53*c87b03e5Sespie 
54*c87b03e5Sespie 
55*c87b03e5Sespie /* Simple definitions and enumerations. */
56*c87b03e5Sespie 
57*c87b03e5Sespie typedef enum
58*c87b03e5Sespie   {
59*c87b03e5Sespie     FFESTE_stateletSIMPLE_,	/* Expecting simple/start. */
60*c87b03e5Sespie     FFESTE_stateletATTRIB_,	/* Expecting attrib/item/itemstart. */
61*c87b03e5Sespie     FFESTE_stateletITEM_,	/* Expecting item/itemstart/finish. */
62*c87b03e5Sespie     FFESTE_stateletITEMVALS_,	/* Expecting itemvalue/itemendvals. */
63*c87b03e5Sespie     FFESTE_
64*c87b03e5Sespie   } ffesteStatelet_;
65*c87b03e5Sespie 
66*c87b03e5Sespie /* Internal typedefs. */
67*c87b03e5Sespie 
68*c87b03e5Sespie 
69*c87b03e5Sespie /* Private include files. */
70*c87b03e5Sespie 
71*c87b03e5Sespie 
72*c87b03e5Sespie /* Internal structure definitions. */
73*c87b03e5Sespie 
74*c87b03e5Sespie 
75*c87b03e5Sespie /* Static objects accessed by functions in this module. */
76*c87b03e5Sespie 
77*c87b03e5Sespie static ffesteStatelet_ ffeste_statelet_ = FFESTE_stateletSIMPLE_;
78*c87b03e5Sespie static ffelab ffeste_label_formatdef_ = NULL;
79*c87b03e5Sespie static tree (*ffeste_io_driver_) (ffebld expr);	/* do?io. */
80*c87b03e5Sespie static ffecomGfrt ffeste_io_endgfrt_;	/* end function to call. */
81*c87b03e5Sespie static tree ffeste_io_abort_;	/* abort-io label or NULL_TREE. */
82*c87b03e5Sespie static bool ffeste_io_abort_is_temp_;	/* abort-io label is a temp. */
83*c87b03e5Sespie static tree ffeste_io_end_;	/* END= label or NULL_TREE. */
84*c87b03e5Sespie static tree ffeste_io_err_;	/* ERR= label or NULL_TREE. */
85*c87b03e5Sespie static tree ffeste_io_iostat_;	/* IOSTAT= var or NULL_TREE. */
86*c87b03e5Sespie static bool ffeste_io_iostat_is_temp_;	/* IOSTAT= var is a temp. */
87*c87b03e5Sespie 
88*c87b03e5Sespie /* Static functions (internal). */
89*c87b03e5Sespie 
90*c87b03e5Sespie static void ffeste_begin_iterdo_ (ffestw block, tree *tvar, tree *tincr,
91*c87b03e5Sespie 				  tree *xitersvar, ffebld var,
92*c87b03e5Sespie 				  ffebld start, ffelexToken start_token,
93*c87b03e5Sespie 				  ffebld end, ffelexToken end_token,
94*c87b03e5Sespie 				  ffebld incr, ffelexToken incr_token,
95*c87b03e5Sespie 				  const char *msg);
96*c87b03e5Sespie static void ffeste_end_iterdo_ (ffestw block, tree tvar, tree tincr,
97*c87b03e5Sespie 				tree itersvar);
98*c87b03e5Sespie static void ffeste_io_call_ (tree call, bool do_check);
99*c87b03e5Sespie static void ffeste_io_impdo_ (ffebld impdo, ffelexToken impdo_token);
100*c87b03e5Sespie static tree ffeste_io_dofio_ (ffebld expr);
101*c87b03e5Sespie static tree ffeste_io_dolio_ (ffebld expr);
102*c87b03e5Sespie static tree ffeste_io_douio_ (ffebld expr);
103*c87b03e5Sespie static tree ffeste_io_ialist_ (bool have_err, ffestvUnit unit,
104*c87b03e5Sespie 			       ffebld unit_expr, int unit_dflt);
105*c87b03e5Sespie static tree ffeste_io_cilist_ (bool have_err, ffestvUnit unit,
106*c87b03e5Sespie 			       ffebld unit_expr, int unit_dflt,
107*c87b03e5Sespie 			       bool have_end, ffestvFormat format,
108*c87b03e5Sespie 			       ffestpFile *format_spec, bool rec,
109*c87b03e5Sespie 			       ffebld rec_expr);
110*c87b03e5Sespie static tree ffeste_io_cllist_ (bool have_err, ffebld unit_expr,
111*c87b03e5Sespie 			       ffestpFile *stat_spec);
112*c87b03e5Sespie static tree ffeste_io_icilist_ (bool have_err, ffebld unit_expr,
113*c87b03e5Sespie 				bool have_end, ffestvFormat format,
114*c87b03e5Sespie 				ffestpFile *format_spec);
115*c87b03e5Sespie static tree ffeste_io_inlist_ (bool have_err,
116*c87b03e5Sespie 			       ffestpFile *unit_spec,
117*c87b03e5Sespie 			       ffestpFile *file_spec,
118*c87b03e5Sespie 			       ffestpFile *exist_spec,
119*c87b03e5Sespie 			       ffestpFile *open_spec,
120*c87b03e5Sespie 			       ffestpFile *number_spec,
121*c87b03e5Sespie 			       ffestpFile *named_spec,
122*c87b03e5Sespie 			       ffestpFile *name_spec,
123*c87b03e5Sespie 			       ffestpFile *access_spec,
124*c87b03e5Sespie 			       ffestpFile *sequential_spec,
125*c87b03e5Sespie 			       ffestpFile *direct_spec,
126*c87b03e5Sespie 			       ffestpFile *form_spec,
127*c87b03e5Sespie 			       ffestpFile *formatted_spec,
128*c87b03e5Sespie 			       ffestpFile *unformatted_spec,
129*c87b03e5Sespie 			       ffestpFile *recl_spec,
130*c87b03e5Sespie 			       ffestpFile *nextrec_spec,
131*c87b03e5Sespie 			       ffestpFile *blank_spec);
132*c87b03e5Sespie static tree ffeste_io_olist_ (bool have_err, ffebld unit_expr,
133*c87b03e5Sespie 			      ffestpFile *file_spec,
134*c87b03e5Sespie 			      ffestpFile *stat_spec,
135*c87b03e5Sespie 			      ffestpFile *access_spec,
136*c87b03e5Sespie 			      ffestpFile *form_spec,
137*c87b03e5Sespie 			      ffestpFile *recl_spec,
138*c87b03e5Sespie 			      ffestpFile *blank_spec);
139*c87b03e5Sespie static void ffeste_subr_beru_ (ffestpBeruStmt *info, ffecomGfrt rt);
140*c87b03e5Sespie 
141*c87b03e5Sespie /* Internal macros. */
142*c87b03e5Sespie 
143*c87b03e5Sespie #define ffeste_emit_line_note_() \
144*c87b03e5Sespie   emit_line_note (input_filename, lineno)
145*c87b03e5Sespie #define ffeste_check_simple_() \
146*c87b03e5Sespie   assert(ffeste_statelet_ == FFESTE_stateletSIMPLE_)
147*c87b03e5Sespie #define ffeste_check_start_() \
148*c87b03e5Sespie   assert(ffeste_statelet_ == FFESTE_stateletSIMPLE_); \
149*c87b03e5Sespie   ffeste_statelet_ = FFESTE_stateletATTRIB_
150*c87b03e5Sespie #define ffeste_check_attrib_() \
151*c87b03e5Sespie   assert(ffeste_statelet_ == FFESTE_stateletATTRIB_)
152*c87b03e5Sespie #define ffeste_check_item_() \
153*c87b03e5Sespie   assert(ffeste_statelet_ == FFESTE_stateletATTRIB_	 \
154*c87b03e5Sespie 	 || ffeste_statelet_ == FFESTE_stateletITEM_); \
155*c87b03e5Sespie   ffeste_statelet_ = FFESTE_stateletITEM_
156*c87b03e5Sespie #define ffeste_check_item_startvals_() \
157*c87b03e5Sespie   assert(ffeste_statelet_ == FFESTE_stateletATTRIB_	 \
158*c87b03e5Sespie 	 || ffeste_statelet_ == FFESTE_stateletITEM_); \
159*c87b03e5Sespie   ffeste_statelet_ = FFESTE_stateletITEMVALS_
160*c87b03e5Sespie #define ffeste_check_item_value_() \
161*c87b03e5Sespie   assert(ffeste_statelet_ == FFESTE_stateletITEMVALS_)
162*c87b03e5Sespie #define ffeste_check_item_endvals_() \
163*c87b03e5Sespie   assert(ffeste_statelet_ == FFESTE_stateletITEMVALS_); \
164*c87b03e5Sespie   ffeste_statelet_ = FFESTE_stateletITEM_
165*c87b03e5Sespie #define ffeste_check_finish_() \
166*c87b03e5Sespie   assert(ffeste_statelet_ == FFESTE_stateletATTRIB_	 \
167*c87b03e5Sespie 	 || ffeste_statelet_ == FFESTE_stateletITEM_); \
168*c87b03e5Sespie   ffeste_statelet_ = FFESTE_stateletSIMPLE_
169*c87b03e5Sespie 
170*c87b03e5Sespie #define ffeste_f2c_init_charnolen_(Exp,Init,Spec)			      \
171*c87b03e5Sespie   do									      \
172*c87b03e5Sespie     {									      \
173*c87b03e5Sespie       if ((Spec)->kw_or_val_present)					      \
174*c87b03e5Sespie 	Exp = ffecom_arg_ptr_to_const_expr ((Spec)->u.expr, &ignore);	      \
175*c87b03e5Sespie       else								      \
176*c87b03e5Sespie 	Exp = null_pointer_node;					      \
177*c87b03e5Sespie       if (Exp)								      \
178*c87b03e5Sespie 	Init = Exp;							      \
179*c87b03e5Sespie       else								      \
180*c87b03e5Sespie 	{								      \
181*c87b03e5Sespie 	  Init = null_pointer_node;					      \
182*c87b03e5Sespie 	  constantp = FALSE;						      \
183*c87b03e5Sespie 	}								      \
184*c87b03e5Sespie     } while(0)
185*c87b03e5Sespie 
186*c87b03e5Sespie #define ffeste_f2c_init_char_(Exp,Init,Lenexp,Leninit,Spec)		      \
187*c87b03e5Sespie   do									      \
188*c87b03e5Sespie     {									      \
189*c87b03e5Sespie       if ((Spec)->kw_or_val_present)					      \
190*c87b03e5Sespie 	Exp = ffecom_arg_ptr_to_const_expr ((Spec)->u.expr, &Lenexp);	      \
191*c87b03e5Sespie       else								      \
192*c87b03e5Sespie 	{								      \
193*c87b03e5Sespie 	  Exp = null_pointer_node;					      \
194*c87b03e5Sespie 	  Lenexp = ffecom_f2c_ftnlen_zero_node;				      \
195*c87b03e5Sespie 	}								      \
196*c87b03e5Sespie       if (Exp)								      \
197*c87b03e5Sespie 	Init = Exp;							      \
198*c87b03e5Sespie       else								      \
199*c87b03e5Sespie 	{								      \
200*c87b03e5Sespie 	  Init = null_pointer_node;					      \
201*c87b03e5Sespie 	  constantp = FALSE;						      \
202*c87b03e5Sespie 	}								      \
203*c87b03e5Sespie       if (Lenexp)							      \
204*c87b03e5Sespie 	Leninit = Lenexp;						      \
205*c87b03e5Sespie       else								      \
206*c87b03e5Sespie 	{								      \
207*c87b03e5Sespie 	  Leninit = ffecom_f2c_ftnlen_zero_node;			      \
208*c87b03e5Sespie 	  constantp = FALSE;						      \
209*c87b03e5Sespie 	}								      \
210*c87b03e5Sespie     } while(0)
211*c87b03e5Sespie 
212*c87b03e5Sespie #define ffeste_f2c_init_flag_(Flag,Init)				      \
213*c87b03e5Sespie   do									      \
214*c87b03e5Sespie     {									      \
215*c87b03e5Sespie       Init = convert (ffecom_f2c_flag_type_node,			      \
216*c87b03e5Sespie 		      (Flag) ? integer_one_node : integer_zero_node);	      \
217*c87b03e5Sespie     } while(0)
218*c87b03e5Sespie 
219*c87b03e5Sespie #define ffeste_f2c_init_format_(Exp,Init,Spec)				      \
220*c87b03e5Sespie   do									      \
221*c87b03e5Sespie     {									      \
222*c87b03e5Sespie       Exp = ffecom_arg_ptr_to_const_expr ((Spec)->u.expr, NULL);	      \
223*c87b03e5Sespie       if (Exp)								      \
224*c87b03e5Sespie 	Init = Exp;							      \
225*c87b03e5Sespie       else								      \
226*c87b03e5Sespie 	{								      \
227*c87b03e5Sespie 	  Init = null_pointer_node;					      \
228*c87b03e5Sespie 	  constantp = FALSE;						      \
229*c87b03e5Sespie 	}								      \
230*c87b03e5Sespie     } while(0)
231*c87b03e5Sespie 
232*c87b03e5Sespie #define ffeste_f2c_init_int_(Exp,Init,Spec)				      \
233*c87b03e5Sespie   do									      \
234*c87b03e5Sespie     {									      \
235*c87b03e5Sespie       if ((Spec)->kw_or_val_present)					      \
236*c87b03e5Sespie 	Exp = ffecom_const_expr ((Spec)->u.expr);			      \
237*c87b03e5Sespie       else								      \
238*c87b03e5Sespie 	Exp = ffecom_integer_zero_node;					      \
239*c87b03e5Sespie       if (Exp)								      \
240*c87b03e5Sespie 	Init = Exp;							      \
241*c87b03e5Sespie       else								      \
242*c87b03e5Sespie 	{								      \
243*c87b03e5Sespie 	  Init = ffecom_integer_zero_node;				      \
244*c87b03e5Sespie 	  constantp = FALSE;						      \
245*c87b03e5Sespie 	}								      \
246*c87b03e5Sespie     } while(0)
247*c87b03e5Sespie 
248*c87b03e5Sespie #define ffeste_f2c_init_ptrtoint_(Exp,Init,Spec)			      \
249*c87b03e5Sespie   do									      \
250*c87b03e5Sespie     {									      \
251*c87b03e5Sespie       if ((Spec)->kw_or_val_present)					      \
252*c87b03e5Sespie 	Exp = ffecom_ptr_to_const_expr ((Spec)->u.expr);		      \
253*c87b03e5Sespie       else								      \
254*c87b03e5Sespie 	Exp = null_pointer_node;					      \
255*c87b03e5Sespie       if (Exp)								      \
256*c87b03e5Sespie 	Init = Exp;							      \
257*c87b03e5Sespie       else								      \
258*c87b03e5Sespie 	{								      \
259*c87b03e5Sespie 	  Init = null_pointer_node;					      \
260*c87b03e5Sespie 	  constantp = FALSE;						      \
261*c87b03e5Sespie 	}								      \
262*c87b03e5Sespie     } while(0)
263*c87b03e5Sespie 
264*c87b03e5Sespie #define ffeste_f2c_init_next_(Init)					      \
265*c87b03e5Sespie   do									      \
266*c87b03e5Sespie     {									      \
267*c87b03e5Sespie       TREE_CHAIN (initn) = build_tree_list ((field = TREE_CHAIN (field)),     \
268*c87b03e5Sespie 					    (Init));			      \
269*c87b03e5Sespie       initn = TREE_CHAIN(initn);					      \
270*c87b03e5Sespie     } while(0)
271*c87b03e5Sespie 
272*c87b03e5Sespie #define ffeste_f2c_prepare_charnolen_(Spec,Exp)				      \
273*c87b03e5Sespie   do									      \
274*c87b03e5Sespie     {									      \
275*c87b03e5Sespie       if (! (Exp))							      \
276*c87b03e5Sespie         ffecom_prepare_arg_ptr_to_expr ((Spec)->u.expr);		      \
277*c87b03e5Sespie     } while(0)
278*c87b03e5Sespie 
279*c87b03e5Sespie #define ffeste_f2c_prepare_char_(Spec,Exp)				      \
280*c87b03e5Sespie   do									      \
281*c87b03e5Sespie     {									      \
282*c87b03e5Sespie       if (! (Exp))							      \
283*c87b03e5Sespie         ffecom_prepare_arg_ptr_to_expr ((Spec)->u.expr);		      \
284*c87b03e5Sespie     } while(0)
285*c87b03e5Sespie 
286*c87b03e5Sespie #define ffeste_f2c_prepare_format_(Spec,Exp)				      \
287*c87b03e5Sespie   do									      \
288*c87b03e5Sespie     {									      \
289*c87b03e5Sespie       if (! (Exp))							      \
290*c87b03e5Sespie         ffecom_prepare_arg_ptr_to_expr ((Spec)->u.expr);		      \
291*c87b03e5Sespie     } while(0)
292*c87b03e5Sespie 
293*c87b03e5Sespie #define ffeste_f2c_prepare_int_(Spec,Exp)				      \
294*c87b03e5Sespie   do									      \
295*c87b03e5Sespie     {									      \
296*c87b03e5Sespie       if (! (Exp))							      \
297*c87b03e5Sespie         ffecom_prepare_expr ((Spec)->u.expr);				      \
298*c87b03e5Sespie     } while(0)
299*c87b03e5Sespie 
300*c87b03e5Sespie #define ffeste_f2c_prepare_ptrtoint_(Spec,Exp)				      \
301*c87b03e5Sespie   do									      \
302*c87b03e5Sespie     {									      \
303*c87b03e5Sespie       if (! (Exp))							      \
304*c87b03e5Sespie         ffecom_prepare_ptr_to_expr ((Spec)->u.expr);			      \
305*c87b03e5Sespie     } while(0)
306*c87b03e5Sespie 
307*c87b03e5Sespie #define ffeste_f2c_compile_(Field,Exp)					      \
308*c87b03e5Sespie   do									      \
309*c87b03e5Sespie     {									      \
310*c87b03e5Sespie       tree exz;								      \
311*c87b03e5Sespie       if ((Exp))							      \
312*c87b03e5Sespie 	{								      \
313*c87b03e5Sespie 	  exz = ffecom_modify (void_type_node,				      \
314*c87b03e5Sespie 			       ffecom_2 (COMPONENT_REF, TREE_TYPE (Field),    \
315*c87b03e5Sespie 					 t, (Field)),			      \
316*c87b03e5Sespie 			       (Exp));					      \
317*c87b03e5Sespie 	  expand_expr_stmt (exz);					      \
318*c87b03e5Sespie 	}								      \
319*c87b03e5Sespie     } while(0)
320*c87b03e5Sespie 
321*c87b03e5Sespie #define ffeste_f2c_compile_charnolen_(Field,Spec,Exp)			      \
322*c87b03e5Sespie   do									      \
323*c87b03e5Sespie     {									      \
324*c87b03e5Sespie       tree exq;								      \
325*c87b03e5Sespie       if (! (Exp))							      \
326*c87b03e5Sespie 	{								      \
327*c87b03e5Sespie 	  exq = ffecom_arg_ptr_to_expr ((Spec)->u.expr, &ignore);	      \
328*c87b03e5Sespie 	  ffeste_f2c_compile_ ((Field), exq);				      \
329*c87b03e5Sespie 	}								      \
330*c87b03e5Sespie     } while(0)
331*c87b03e5Sespie 
332*c87b03e5Sespie #define ffeste_f2c_compile_char_(Field,Lenfield,Spec,Exp,Lenexp)	      \
333*c87b03e5Sespie   do									      \
334*c87b03e5Sespie     {									      \
335*c87b03e5Sespie       tree exq = (Exp);							      \
336*c87b03e5Sespie       tree lenexq = (Lenexp);						      \
337*c87b03e5Sespie       int need_exq = (! exq);						      \
338*c87b03e5Sespie       int need_lenexq = (! lenexq); 					      \
339*c87b03e5Sespie       if (need_exq || need_lenexq)					      \
340*c87b03e5Sespie 	{								      \
341*c87b03e5Sespie 	  exq = ffecom_arg_ptr_to_expr ((Spec)->u.expr, &lenexq);	      \
342*c87b03e5Sespie 	  if (need_exq)							      \
343*c87b03e5Sespie 	    ffeste_f2c_compile_ ((Field), exq);				      \
344*c87b03e5Sespie 	  if (need_lenexq)						      \
345*c87b03e5Sespie 	    ffeste_f2c_compile_ ((Lenfield), lenexq);			      \
346*c87b03e5Sespie 	}								      \
347*c87b03e5Sespie     } while(0)
348*c87b03e5Sespie 
349*c87b03e5Sespie #define ffeste_f2c_compile_format_(Field,Spec,Exp)			      \
350*c87b03e5Sespie   do									      \
351*c87b03e5Sespie     {									      \
352*c87b03e5Sespie       tree exq;								      \
353*c87b03e5Sespie       if (! (Exp))							      \
354*c87b03e5Sespie 	{								      \
355*c87b03e5Sespie 	  exq = ffecom_arg_ptr_to_expr ((Spec)->u.expr, NULL);		      \
356*c87b03e5Sespie 	  ffeste_f2c_compile_ ((Field), exq);				      \
357*c87b03e5Sespie 	}								      \
358*c87b03e5Sespie     } while(0)
359*c87b03e5Sespie 
360*c87b03e5Sespie #define ffeste_f2c_compile_int_(Field,Spec,Exp)				      \
361*c87b03e5Sespie   do									      \
362*c87b03e5Sespie     {									      \
363*c87b03e5Sespie       tree exq;								      \
364*c87b03e5Sespie       if (! (Exp))							      \
365*c87b03e5Sespie 	{								      \
366*c87b03e5Sespie 	  exq = ffecom_expr ((Spec)->u.expr);				      \
367*c87b03e5Sespie 	  ffeste_f2c_compile_ ((Field), exq);				      \
368*c87b03e5Sespie 	}								      \
369*c87b03e5Sespie     } while(0)
370*c87b03e5Sespie 
371*c87b03e5Sespie #define ffeste_f2c_compile_ptrtoint_(Field,Spec,Exp)			      \
372*c87b03e5Sespie   do									      \
373*c87b03e5Sespie     {									      \
374*c87b03e5Sespie       tree exq;								      \
375*c87b03e5Sespie       if (! (Exp))							      \
376*c87b03e5Sespie 	{								      \
377*c87b03e5Sespie 	  exq = ffecom_ptr_to_expr ((Spec)->u.expr);			      \
378*c87b03e5Sespie 	  ffeste_f2c_compile_ ((Field), exq);				      \
379*c87b03e5Sespie 	}								      \
380*c87b03e5Sespie     } while(0)
381*c87b03e5Sespie 
382*c87b03e5Sespie /* Start a Fortran block.  */
383*c87b03e5Sespie 
384*c87b03e5Sespie #ifdef ENABLE_CHECKING
385*c87b03e5Sespie 
386*c87b03e5Sespie typedef struct gbe_block
387*c87b03e5Sespie {
388*c87b03e5Sespie   struct gbe_block *outer;
389*c87b03e5Sespie   ffestw block;
390*c87b03e5Sespie   int lineno;
391*c87b03e5Sespie   const char *input_filename;
392*c87b03e5Sespie   bool is_stmt;
393*c87b03e5Sespie } *gbe_block;
394*c87b03e5Sespie 
395*c87b03e5Sespie gbe_block ffeste_top_block_ = NULL;
396*c87b03e5Sespie 
397*c87b03e5Sespie static void
ffeste_start_block_(ffestw block)398*c87b03e5Sespie ffeste_start_block_ (ffestw block)
399*c87b03e5Sespie {
400*c87b03e5Sespie   gbe_block b = xmalloc (sizeof (*b));
401*c87b03e5Sespie 
402*c87b03e5Sespie   b->outer = ffeste_top_block_;
403*c87b03e5Sespie   b->block = block;
404*c87b03e5Sespie   b->lineno = lineno;
405*c87b03e5Sespie   b->input_filename = input_filename;
406*c87b03e5Sespie   b->is_stmt = FALSE;
407*c87b03e5Sespie 
408*c87b03e5Sespie   ffeste_top_block_ = b;
409*c87b03e5Sespie 
410*c87b03e5Sespie   ffecom_start_compstmt ();
411*c87b03e5Sespie }
412*c87b03e5Sespie 
413*c87b03e5Sespie /* End a Fortran block.  */
414*c87b03e5Sespie 
415*c87b03e5Sespie static void
ffeste_end_block_(ffestw block)416*c87b03e5Sespie ffeste_end_block_ (ffestw block)
417*c87b03e5Sespie {
418*c87b03e5Sespie   gbe_block b = ffeste_top_block_;
419*c87b03e5Sespie 
420*c87b03e5Sespie   assert (b);
421*c87b03e5Sespie   assert (! b->is_stmt);
422*c87b03e5Sespie   assert (b->block == block);
423*c87b03e5Sespie   assert (! b->is_stmt);
424*c87b03e5Sespie 
425*c87b03e5Sespie   ffeste_top_block_ = b->outer;
426*c87b03e5Sespie 
427*c87b03e5Sespie   free (b);
428*c87b03e5Sespie 
429*c87b03e5Sespie   ffecom_end_compstmt ();
430*c87b03e5Sespie }
431*c87b03e5Sespie 
432*c87b03e5Sespie /* Start a Fortran statement.
433*c87b03e5Sespie 
434*c87b03e5Sespie    Starts a back-end block, so temporaries can be managed, clean-ups
435*c87b03e5Sespie    properly handled, etc.  Nesting of statements *is* allowed -- the
436*c87b03e5Sespie    handling of I/O items, even implied-DO I/O lists, within a READ,
437*c87b03e5Sespie    PRINT, or WRITE statement is one example.  */
438*c87b03e5Sespie 
439*c87b03e5Sespie static void
ffeste_start_stmt_(void)440*c87b03e5Sespie ffeste_start_stmt_(void)
441*c87b03e5Sespie {
442*c87b03e5Sespie   gbe_block b = xmalloc (sizeof (*b));
443*c87b03e5Sespie 
444*c87b03e5Sespie   b->outer = ffeste_top_block_;
445*c87b03e5Sespie   b->block = NULL;
446*c87b03e5Sespie   b->lineno = lineno;
447*c87b03e5Sespie   b->input_filename = input_filename;
448*c87b03e5Sespie   b->is_stmt = TRUE;
449*c87b03e5Sespie 
450*c87b03e5Sespie   ffeste_top_block_ = b;
451*c87b03e5Sespie 
452*c87b03e5Sespie   ffecom_start_compstmt ();
453*c87b03e5Sespie }
454*c87b03e5Sespie 
455*c87b03e5Sespie /* End a Fortran statement.  */
456*c87b03e5Sespie 
457*c87b03e5Sespie static void
ffeste_end_stmt_(void)458*c87b03e5Sespie ffeste_end_stmt_(void)
459*c87b03e5Sespie {
460*c87b03e5Sespie   gbe_block b = ffeste_top_block_;
461*c87b03e5Sespie 
462*c87b03e5Sespie   assert (b);
463*c87b03e5Sespie   assert (b->is_stmt);
464*c87b03e5Sespie 
465*c87b03e5Sespie   ffeste_top_block_ = b->outer;
466*c87b03e5Sespie 
467*c87b03e5Sespie   free (b);
468*c87b03e5Sespie 
469*c87b03e5Sespie   ffecom_end_compstmt ();
470*c87b03e5Sespie }
471*c87b03e5Sespie 
472*c87b03e5Sespie #else  /* ! defined (ENABLE_CHECKING) */
473*c87b03e5Sespie 
474*c87b03e5Sespie #define ffeste_start_block_(b) ffecom_start_compstmt ()
475*c87b03e5Sespie #define ffeste_end_block_(b)	\
476*c87b03e5Sespie   do				\
477*c87b03e5Sespie     {				\
478*c87b03e5Sespie       ffecom_end_compstmt ();	\
479*c87b03e5Sespie     } while(0)
480*c87b03e5Sespie #define ffeste_start_stmt_() ffeste_start_block_(NULL)
481*c87b03e5Sespie #define ffeste_end_stmt_() ffeste_end_block_(NULL)
482*c87b03e5Sespie 
483*c87b03e5Sespie #endif  /* ! defined (ENABLE_CHECKING) */
484*c87b03e5Sespie 
485*c87b03e5Sespie /* Begin an iterative DO loop.  Pass the block to start if
486*c87b03e5Sespie    applicable.  */
487*c87b03e5Sespie 
488*c87b03e5Sespie static void
ffeste_begin_iterdo_(ffestw block,tree * xtvar,tree * xtincr,tree * xitersvar,ffebld var,ffebld start,ffelexToken start_token,ffebld end,ffelexToken end_token,ffebld incr,ffelexToken incr_token,const char * msg)489*c87b03e5Sespie ffeste_begin_iterdo_ (ffestw block, tree *xtvar, tree *xtincr,
490*c87b03e5Sespie 		      tree *xitersvar, ffebld var,
491*c87b03e5Sespie 		      ffebld start, ffelexToken start_token,
492*c87b03e5Sespie 		      ffebld end, ffelexToken end_token,
493*c87b03e5Sespie 		      ffebld incr, ffelexToken incr_token,
494*c87b03e5Sespie 		      const char *msg)
495*c87b03e5Sespie {
496*c87b03e5Sespie   tree tvar;
497*c87b03e5Sespie   tree expr;
498*c87b03e5Sespie   tree tstart;
499*c87b03e5Sespie   tree tend;
500*c87b03e5Sespie   tree tincr;
501*c87b03e5Sespie   tree tincr_saved;
502*c87b03e5Sespie   tree niters;
503*c87b03e5Sespie   struct nesting *expanded_loop;
504*c87b03e5Sespie 
505*c87b03e5Sespie   /* Want to have tvar, tincr, and niters for the whole loop body. */
506*c87b03e5Sespie 
507*c87b03e5Sespie   if (block)
508*c87b03e5Sespie     ffeste_start_block_ (block);
509*c87b03e5Sespie   else
510*c87b03e5Sespie     ffeste_start_stmt_ ();
511*c87b03e5Sespie 
512*c87b03e5Sespie   niters = ffecom_make_tempvar (block ? "do" : "impdo",
513*c87b03e5Sespie 				ffecom_integer_type_node,
514*c87b03e5Sespie 				FFETARGET_charactersizeNONE, -1);
515*c87b03e5Sespie 
516*c87b03e5Sespie   ffecom_prepare_expr (incr);
517*c87b03e5Sespie   ffecom_prepare_expr_rw (NULL_TREE, var);
518*c87b03e5Sespie 
519*c87b03e5Sespie   ffecom_prepare_end ();
520*c87b03e5Sespie 
521*c87b03e5Sespie   tvar = ffecom_expr_rw (NULL_TREE, var);
522*c87b03e5Sespie   tincr = ffecom_expr (incr);
523*c87b03e5Sespie 
524*c87b03e5Sespie   if (TREE_CODE (tvar) == ERROR_MARK
525*c87b03e5Sespie       || TREE_CODE (tincr) == ERROR_MARK)
526*c87b03e5Sespie     {
527*c87b03e5Sespie       if (block)
528*c87b03e5Sespie 	{
529*c87b03e5Sespie 	  ffeste_end_block_ (block);
530*c87b03e5Sespie 	  ffestw_set_do_tvar (block, error_mark_node);
531*c87b03e5Sespie 	}
532*c87b03e5Sespie       else
533*c87b03e5Sespie 	{
534*c87b03e5Sespie 	  ffeste_end_stmt_ ();
535*c87b03e5Sespie 	  *xtvar = error_mark_node;
536*c87b03e5Sespie 	}
537*c87b03e5Sespie       return;
538*c87b03e5Sespie     }
539*c87b03e5Sespie 
540*c87b03e5Sespie   /* Check whether incr is known to be zero, complain and fix.  */
541*c87b03e5Sespie 
542*c87b03e5Sespie   if (integer_zerop (tincr) || real_zerop (tincr))
543*c87b03e5Sespie     {
544*c87b03e5Sespie       ffebad_start (FFEBAD_DO_STEP_ZERO);
545*c87b03e5Sespie       ffebad_here (0, ffelex_token_where_line (incr_token),
546*c87b03e5Sespie 		   ffelex_token_where_column (incr_token));
547*c87b03e5Sespie       ffebad_string (msg);
548*c87b03e5Sespie       ffebad_finish ();
549*c87b03e5Sespie       tincr = convert (TREE_TYPE (tvar), integer_one_node);
550*c87b03e5Sespie     }
551*c87b03e5Sespie 
552*c87b03e5Sespie   tincr_saved = ffecom_save_tree (tincr);
553*c87b03e5Sespie 
554*c87b03e5Sespie   /* Want to have tstart, tend for just this statement. */
555*c87b03e5Sespie 
556*c87b03e5Sespie   ffeste_start_stmt_ ();
557*c87b03e5Sespie 
558*c87b03e5Sespie   ffecom_prepare_expr (start);
559*c87b03e5Sespie   ffecom_prepare_expr (end);
560*c87b03e5Sespie 
561*c87b03e5Sespie   ffecom_prepare_end ();
562*c87b03e5Sespie 
563*c87b03e5Sespie   tstart = ffecom_expr (start);
564*c87b03e5Sespie   tend = ffecom_expr (end);
565*c87b03e5Sespie 
566*c87b03e5Sespie   if (TREE_CODE (tstart) == ERROR_MARK
567*c87b03e5Sespie       || TREE_CODE (tend) == ERROR_MARK)
568*c87b03e5Sespie     {
569*c87b03e5Sespie       ffeste_end_stmt_ ();
570*c87b03e5Sespie 
571*c87b03e5Sespie       if (block)
572*c87b03e5Sespie 	{
573*c87b03e5Sespie 	  ffeste_end_block_ (block);
574*c87b03e5Sespie 	  ffestw_set_do_tvar (block, error_mark_node);
575*c87b03e5Sespie 	}
576*c87b03e5Sespie       else
577*c87b03e5Sespie 	{
578*c87b03e5Sespie 	  ffeste_end_stmt_ ();
579*c87b03e5Sespie 	  *xtvar = error_mark_node;
580*c87b03e5Sespie 	}
581*c87b03e5Sespie       return;
582*c87b03e5Sespie     }
583*c87b03e5Sespie 
584*c87b03e5Sespie   /* For warnings only, nothing else happens here.  */
585*c87b03e5Sespie   {
586*c87b03e5Sespie     tree try;
587*c87b03e5Sespie 
588*c87b03e5Sespie     if (! ffe_is_onetrip ())
589*c87b03e5Sespie       {
590*c87b03e5Sespie 	try = ffecom_2 (MINUS_EXPR, TREE_TYPE (tvar),
591*c87b03e5Sespie 			tend,
592*c87b03e5Sespie 			tstart);
593*c87b03e5Sespie 
594*c87b03e5Sespie 	try = ffecom_2 (PLUS_EXPR, TREE_TYPE (tvar),
595*c87b03e5Sespie 			try,
596*c87b03e5Sespie 			tincr);
597*c87b03e5Sespie 
598*c87b03e5Sespie 	if (TREE_CODE (TREE_TYPE (tvar)) != REAL_TYPE)
599*c87b03e5Sespie 	  try = ffecom_2 (TRUNC_DIV_EXPR, integer_type_node, try,
600*c87b03e5Sespie 			  tincr);
601*c87b03e5Sespie 	else
602*c87b03e5Sespie 	  try = convert (integer_type_node,
603*c87b03e5Sespie 			 ffecom_2 (RDIV_EXPR, TREE_TYPE (tvar),
604*c87b03e5Sespie 				   try,
605*c87b03e5Sespie 				   tincr));
606*c87b03e5Sespie 
607*c87b03e5Sespie 	/* Warn if loop never executed, since we've done the evaluation
608*c87b03e5Sespie 	   of the unofficial iteration count already.  */
609*c87b03e5Sespie 
610*c87b03e5Sespie 	try = ffecom_truth_value (ffecom_2 (LE_EXPR, integer_type_node,
611*c87b03e5Sespie 					    try,
612*c87b03e5Sespie 					    convert (TREE_TYPE (tvar),
613*c87b03e5Sespie 						     integer_zero_node)));
614*c87b03e5Sespie 
615*c87b03e5Sespie 	if (integer_onep (try))
616*c87b03e5Sespie 	  {
617*c87b03e5Sespie 	    ffebad_start (FFEBAD_DO_NULL);
618*c87b03e5Sespie 	    ffebad_here (0, ffelex_token_where_line (start_token),
619*c87b03e5Sespie 			 ffelex_token_where_column (start_token));
620*c87b03e5Sespie 	    ffebad_string (msg);
621*c87b03e5Sespie 	    ffebad_finish ();
622*c87b03e5Sespie 	  }
623*c87b03e5Sespie       }
624*c87b03e5Sespie 
625*c87b03e5Sespie     /* Warn if end plus incr would overflow.  */
626*c87b03e5Sespie 
627*c87b03e5Sespie     try = ffecom_2 (PLUS_EXPR, TREE_TYPE (tvar),
628*c87b03e5Sespie 		    tend,
629*c87b03e5Sespie 		    tincr);
630*c87b03e5Sespie 
631*c87b03e5Sespie     if ((TREE_CODE_CLASS (TREE_CODE (try)) == 'c')
632*c87b03e5Sespie 	&& TREE_CONSTANT_OVERFLOW (try))
633*c87b03e5Sespie       {
634*c87b03e5Sespie 	ffebad_start (FFEBAD_DO_END_OVERFLOW);
635*c87b03e5Sespie 	ffebad_here (0, ffelex_token_where_line (end_token),
636*c87b03e5Sespie 		     ffelex_token_where_column (end_token));
637*c87b03e5Sespie 	ffebad_string (msg);
638*c87b03e5Sespie 	ffebad_finish ();
639*c87b03e5Sespie       }
640*c87b03e5Sespie   }
641*c87b03e5Sespie 
642*c87b03e5Sespie   /* Do the initial assignment into the DO var.  */
643*c87b03e5Sespie 
644*c87b03e5Sespie   tstart = ffecom_save_tree (tstart);
645*c87b03e5Sespie 
646*c87b03e5Sespie   expr = ffecom_2 (MINUS_EXPR, TREE_TYPE (tvar),
647*c87b03e5Sespie 		   tend,
648*c87b03e5Sespie 		   tstart);
649*c87b03e5Sespie 
650*c87b03e5Sespie   if (! ffe_is_onetrip ())
651*c87b03e5Sespie     {
652*c87b03e5Sespie       expr = ffecom_2 (PLUS_EXPR, TREE_TYPE (expr),
653*c87b03e5Sespie 		       expr,
654*c87b03e5Sespie 		       convert (TREE_TYPE (expr), tincr_saved));
655*c87b03e5Sespie     }
656*c87b03e5Sespie 
657*c87b03e5Sespie   if (TREE_CODE (TREE_TYPE (tvar)) != REAL_TYPE)
658*c87b03e5Sespie     expr = ffecom_2 (TRUNC_DIV_EXPR, TREE_TYPE (expr),
659*c87b03e5Sespie 		     expr,
660*c87b03e5Sespie 		     tincr_saved);
661*c87b03e5Sespie   else
662*c87b03e5Sespie     expr = ffecom_2 (RDIV_EXPR, TREE_TYPE (expr),
663*c87b03e5Sespie 		     expr,
664*c87b03e5Sespie 		     tincr_saved);
665*c87b03e5Sespie 
666*c87b03e5Sespie #if 1	/* New, F90-approved approach: convert to default INTEGER. */
667*c87b03e5Sespie   if (TREE_TYPE (tvar) != error_mark_node)
668*c87b03e5Sespie     expr = convert (ffecom_integer_type_node, expr);
669*c87b03e5Sespie #else	/* Old approach; convert to INTEGER unless that's a narrowing. */
670*c87b03e5Sespie   if ((TREE_TYPE (tvar) != error_mark_node)
671*c87b03e5Sespie       && ((TREE_CODE (TREE_TYPE (tvar)) != INTEGER_TYPE)
672*c87b03e5Sespie 	  || ((TYPE_SIZE (TREE_TYPE (tvar)) != NULL_TREE)
673*c87b03e5Sespie 	      && ((TREE_CODE (TYPE_SIZE (TREE_TYPE (tvar)))
674*c87b03e5Sespie 		   != INTEGER_CST)
675*c87b03e5Sespie 		  || (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (tvar)))
676*c87b03e5Sespie 		      <= TREE_INT_CST_LOW (TYPE_SIZE (ffecom_integer_type_node)))))))
677*c87b03e5Sespie     /* Convert unless promoting INTEGER type of any kind downward to
678*c87b03e5Sespie        default INTEGER; else leave as, say, INTEGER*8 (long long int).  */
679*c87b03e5Sespie     expr = convert (ffecom_integer_type_node, expr);
680*c87b03e5Sespie #endif
681*c87b03e5Sespie 
682*c87b03e5Sespie   assert (TYPE_MAIN_VARIANT (TREE_TYPE (niters))
683*c87b03e5Sespie 	  == TYPE_MAIN_VARIANT (TREE_TYPE (expr)));
684*c87b03e5Sespie 
685*c87b03e5Sespie   expr = ffecom_modify (void_type_node, niters, expr);
686*c87b03e5Sespie   expand_expr_stmt (expr);
687*c87b03e5Sespie 
688*c87b03e5Sespie   expr = ffecom_modify (void_type_node, tvar, tstart);
689*c87b03e5Sespie   expand_expr_stmt (expr);
690*c87b03e5Sespie 
691*c87b03e5Sespie   ffeste_end_stmt_ ();
692*c87b03e5Sespie 
693*c87b03e5Sespie   expanded_loop = expand_start_loop_continue_elsewhere (!! block);
694*c87b03e5Sespie   if (block)
695*c87b03e5Sespie     ffestw_set_do_hook (block, expanded_loop);
696*c87b03e5Sespie 
697*c87b03e5Sespie   if (! ffe_is_onetrip ())
698*c87b03e5Sespie     {
699*c87b03e5Sespie       expr = ffecom_truth_value
700*c87b03e5Sespie 	(ffecom_2 (GE_EXPR, integer_type_node,
701*c87b03e5Sespie 		   ffecom_2 (PREDECREMENT_EXPR,
702*c87b03e5Sespie 			     TREE_TYPE (niters),
703*c87b03e5Sespie 			     niters,
704*c87b03e5Sespie 			     convert (TREE_TYPE (niters),
705*c87b03e5Sespie 				      ffecom_integer_one_node)),
706*c87b03e5Sespie 		   convert (TREE_TYPE (niters),
707*c87b03e5Sespie 			    ffecom_integer_zero_node)));
708*c87b03e5Sespie 
709*c87b03e5Sespie       expand_exit_loop_top_cond (0, expr);
710*c87b03e5Sespie     }
711*c87b03e5Sespie 
712*c87b03e5Sespie   if (block)
713*c87b03e5Sespie     {
714*c87b03e5Sespie       ffestw_set_do_tvar (block, tvar);
715*c87b03e5Sespie       ffestw_set_do_incr_saved (block, tincr_saved);
716*c87b03e5Sespie       ffestw_set_do_count_var (block, niters);
717*c87b03e5Sespie     }
718*c87b03e5Sespie   else
719*c87b03e5Sespie     {
720*c87b03e5Sespie       *xtvar = tvar;
721*c87b03e5Sespie       *xtincr = tincr_saved;
722*c87b03e5Sespie       *xitersvar = niters;
723*c87b03e5Sespie     }
724*c87b03e5Sespie }
725*c87b03e5Sespie 
726*c87b03e5Sespie /* End an iterative DO loop.  Pass the same iteration variable and increment
727*c87b03e5Sespie    value trees that were generated in the paired _begin_ call.  */
728*c87b03e5Sespie 
729*c87b03e5Sespie static void
ffeste_end_iterdo_(ffestw block,tree tvar,tree tincr,tree itersvar)730*c87b03e5Sespie ffeste_end_iterdo_ (ffestw block, tree tvar, tree tincr, tree itersvar)
731*c87b03e5Sespie {
732*c87b03e5Sespie   tree expr;
733*c87b03e5Sespie   tree niters = itersvar;
734*c87b03e5Sespie 
735*c87b03e5Sespie   if (tvar == error_mark_node)
736*c87b03e5Sespie     return;
737*c87b03e5Sespie 
738*c87b03e5Sespie   expand_loop_continue_here ();
739*c87b03e5Sespie 
740*c87b03e5Sespie   ffeste_start_stmt_ ();
741*c87b03e5Sespie 
742*c87b03e5Sespie   if (ffe_is_onetrip ())
743*c87b03e5Sespie     {
744*c87b03e5Sespie       expr = ffecom_truth_value
745*c87b03e5Sespie 	(ffecom_2 (GE_EXPR, integer_type_node,
746*c87b03e5Sespie 		   ffecom_2 (PREDECREMENT_EXPR,
747*c87b03e5Sespie 			     TREE_TYPE (niters),
748*c87b03e5Sespie 			     niters,
749*c87b03e5Sespie 			     convert (TREE_TYPE (niters),
750*c87b03e5Sespie 				      ffecom_integer_one_node)),
751*c87b03e5Sespie 		   convert (TREE_TYPE (niters),
752*c87b03e5Sespie 			    ffecom_integer_zero_node)));
753*c87b03e5Sespie 
754*c87b03e5Sespie       expand_exit_loop_if_false (0, expr);
755*c87b03e5Sespie     }
756*c87b03e5Sespie 
757*c87b03e5Sespie   expr = ffecom_modify (void_type_node, tvar,
758*c87b03e5Sespie 			ffecom_2 (PLUS_EXPR, TREE_TYPE (tvar),
759*c87b03e5Sespie 				  tvar,
760*c87b03e5Sespie 				  tincr));
761*c87b03e5Sespie   expand_expr_stmt (expr);
762*c87b03e5Sespie 
763*c87b03e5Sespie   /* Lose the stuff we just built. */
764*c87b03e5Sespie   ffeste_end_stmt_ ();
765*c87b03e5Sespie 
766*c87b03e5Sespie   expand_end_loop ();
767*c87b03e5Sespie 
768*c87b03e5Sespie   /* Lose the tvar and incr_saved trees. */
769*c87b03e5Sespie   if (block)
770*c87b03e5Sespie     ffeste_end_block_ (block);
771*c87b03e5Sespie   else
772*c87b03e5Sespie     ffeste_end_stmt_ ();
773*c87b03e5Sespie }
774*c87b03e5Sespie 
775*c87b03e5Sespie /* Generate call to run-time I/O routine.  */
776*c87b03e5Sespie 
777*c87b03e5Sespie static void
ffeste_io_call_(tree call,bool do_check)778*c87b03e5Sespie ffeste_io_call_ (tree call, bool do_check)
779*c87b03e5Sespie {
780*c87b03e5Sespie   /* Generate the call and optional assignment into iostat var. */
781*c87b03e5Sespie 
782*c87b03e5Sespie   TREE_SIDE_EFFECTS (call) = 1;
783*c87b03e5Sespie   if (ffeste_io_iostat_ != NULL_TREE)
784*c87b03e5Sespie     call = ffecom_modify (do_check ? NULL_TREE : void_type_node,
785*c87b03e5Sespie 			  ffeste_io_iostat_, call);
786*c87b03e5Sespie   expand_expr_stmt (call);
787*c87b03e5Sespie 
788*c87b03e5Sespie   if (! do_check
789*c87b03e5Sespie       || ffeste_io_abort_ == NULL_TREE
790*c87b03e5Sespie       || TREE_CODE (ffeste_io_abort_) == ERROR_MARK)
791*c87b03e5Sespie     return;
792*c87b03e5Sespie 
793*c87b03e5Sespie   /* Generate optional test. */
794*c87b03e5Sespie 
795*c87b03e5Sespie   expand_start_cond (ffecom_truth_value (ffeste_io_iostat_), 0);
796*c87b03e5Sespie   expand_goto (ffeste_io_abort_);
797*c87b03e5Sespie   expand_end_cond ();
798*c87b03e5Sespie }
799*c87b03e5Sespie 
800*c87b03e5Sespie /* Handle implied-DO in I/O list.
801*c87b03e5Sespie 
802*c87b03e5Sespie    Expands code to start up the DO loop.  Then for each item in the
803*c87b03e5Sespie    DO loop, handles appropriately (possibly including recursively calling
804*c87b03e5Sespie    itself).  Then expands code to end the DO loop.  */
805*c87b03e5Sespie 
806*c87b03e5Sespie static void
ffeste_io_impdo_(ffebld impdo,ffelexToken impdo_token)807*c87b03e5Sespie ffeste_io_impdo_ (ffebld impdo, ffelexToken impdo_token)
808*c87b03e5Sespie {
809*c87b03e5Sespie   ffebld var = ffebld_head (ffebld_right (impdo));
810*c87b03e5Sespie   ffebld start = ffebld_head (ffebld_trail (ffebld_right (impdo)));
811*c87b03e5Sespie   ffebld end = ffebld_head (ffebld_trail (ffebld_trail
812*c87b03e5Sespie 					  (ffebld_right (impdo))));
813*c87b03e5Sespie   ffebld incr = ffebld_head (ffebld_trail (ffebld_trail
814*c87b03e5Sespie 				    (ffebld_trail (ffebld_right (impdo)))));
815*c87b03e5Sespie   ffebld list;
816*c87b03e5Sespie   ffebld item;
817*c87b03e5Sespie   tree tvar;
818*c87b03e5Sespie   tree tincr;
819*c87b03e5Sespie   tree titervar;
820*c87b03e5Sespie 
821*c87b03e5Sespie   if (incr == NULL)
822*c87b03e5Sespie     {
823*c87b03e5Sespie       incr = ffebld_new_conter (ffebld_constant_new_integerdefault_val (1));
824*c87b03e5Sespie       ffebld_set_info (incr, ffeinfo_new
825*c87b03e5Sespie 		       (FFEINFO_basictypeINTEGER,
826*c87b03e5Sespie 			FFEINFO_kindtypeINTEGERDEFAULT,
827*c87b03e5Sespie 			0,
828*c87b03e5Sespie 			FFEINFO_kindENTITY,
829*c87b03e5Sespie 			FFEINFO_whereCONSTANT,
830*c87b03e5Sespie 			FFETARGET_charactersizeNONE));
831*c87b03e5Sespie     }
832*c87b03e5Sespie 
833*c87b03e5Sespie   /* Start the DO loop.  */
834*c87b03e5Sespie 
835*c87b03e5Sespie   start = ffeexpr_convert_expr (start, impdo_token, var, impdo_token,
836*c87b03e5Sespie 				FFEEXPR_contextLET);
837*c87b03e5Sespie   end = ffeexpr_convert_expr (end, impdo_token, var, impdo_token,
838*c87b03e5Sespie 			      FFEEXPR_contextLET);
839*c87b03e5Sespie   incr = ffeexpr_convert_expr (incr, impdo_token, var, impdo_token,
840*c87b03e5Sespie 			       FFEEXPR_contextLET);
841*c87b03e5Sespie 
842*c87b03e5Sespie   ffeste_begin_iterdo_ (NULL, &tvar, &tincr, &titervar, var,
843*c87b03e5Sespie 			start, impdo_token,
844*c87b03e5Sespie 			end, impdo_token,
845*c87b03e5Sespie 			incr, impdo_token,
846*c87b03e5Sespie 			"Implied DO loop");
847*c87b03e5Sespie 
848*c87b03e5Sespie   /* Handle the list of items.  */
849*c87b03e5Sespie 
850*c87b03e5Sespie   for (list = ffebld_left (impdo); list != NULL; list = ffebld_trail (list))
851*c87b03e5Sespie     {
852*c87b03e5Sespie       item = ffebld_head (list);
853*c87b03e5Sespie       if (item == NULL)
854*c87b03e5Sespie 	continue;
855*c87b03e5Sespie 
856*c87b03e5Sespie       /* Strip parens off items such as in "READ *,(A)".  This is really a bug
857*c87b03e5Sespie 	 in the user's code, but I've been told lots of code does this.  */
858*c87b03e5Sespie       while (ffebld_op (item) == FFEBLD_opPAREN)
859*c87b03e5Sespie 	item = ffebld_left (item);
860*c87b03e5Sespie 
861*c87b03e5Sespie       if (ffebld_op (item) == FFEBLD_opANY)
862*c87b03e5Sespie 	continue;
863*c87b03e5Sespie 
864*c87b03e5Sespie       if (ffebld_op (item) == FFEBLD_opIMPDO)
865*c87b03e5Sespie 	ffeste_io_impdo_ (item, impdo_token);
866*c87b03e5Sespie       else
867*c87b03e5Sespie 	{
868*c87b03e5Sespie 	  ffeste_start_stmt_ ();
869*c87b03e5Sespie 
870*c87b03e5Sespie 	  ffecom_prepare_arg_ptr_to_expr (item);
871*c87b03e5Sespie 
872*c87b03e5Sespie 	  ffecom_prepare_end ();
873*c87b03e5Sespie 
874*c87b03e5Sespie 	  ffeste_io_call_ ((*ffeste_io_driver_) (item), TRUE);
875*c87b03e5Sespie 
876*c87b03e5Sespie 	  ffeste_end_stmt_ ();
877*c87b03e5Sespie 	}
878*c87b03e5Sespie     }
879*c87b03e5Sespie 
880*c87b03e5Sespie   /* Generate end of implied-do construct. */
881*c87b03e5Sespie 
882*c87b03e5Sespie   ffeste_end_iterdo_ (NULL, tvar, tincr, titervar);
883*c87b03e5Sespie }
884*c87b03e5Sespie 
885*c87b03e5Sespie /* I/O driver for formatted I/O item (do_fio)
886*c87b03e5Sespie 
887*c87b03e5Sespie    Returns a tree for a CALL_EXPR to the do_fio function, which handles
888*c87b03e5Sespie    a formatted I/O list item, along with the appropriate arguments for
889*c87b03e5Sespie    the function.  It is up to the caller to set the TREE_SIDE_EFFECTS flag
890*c87b03e5Sespie    for the CALL_EXPR, expand (emit) the expression, emit any assignment
891*c87b03e5Sespie    of the result to an IOSTAT= variable, and emit any checking of the
892*c87b03e5Sespie    result for errors.  */
893*c87b03e5Sespie 
894*c87b03e5Sespie static tree
ffeste_io_dofio_(ffebld expr)895*c87b03e5Sespie ffeste_io_dofio_ (ffebld expr)
896*c87b03e5Sespie {
897*c87b03e5Sespie   tree num_elements;
898*c87b03e5Sespie   tree variable;
899*c87b03e5Sespie   tree size;
900*c87b03e5Sespie   tree arglist;
901*c87b03e5Sespie   ffeinfoBasictype bt;
902*c87b03e5Sespie   ffeinfoKindtype kt;
903*c87b03e5Sespie   bool is_complex;
904*c87b03e5Sespie 
905*c87b03e5Sespie   bt = ffeinfo_basictype (ffebld_info (expr));
906*c87b03e5Sespie   kt = ffeinfo_kindtype (ffebld_info (expr));
907*c87b03e5Sespie 
908*c87b03e5Sespie   if ((bt == FFEINFO_basictypeANY)
909*c87b03e5Sespie       || (kt == FFEINFO_kindtypeANY))
910*c87b03e5Sespie     return error_mark_node;
911*c87b03e5Sespie 
912*c87b03e5Sespie   if (bt == FFEINFO_basictypeCOMPLEX)
913*c87b03e5Sespie     {
914*c87b03e5Sespie       is_complex = TRUE;
915*c87b03e5Sespie       bt = FFEINFO_basictypeREAL;
916*c87b03e5Sespie     }
917*c87b03e5Sespie   else
918*c87b03e5Sespie     is_complex = FALSE;
919*c87b03e5Sespie 
920*c87b03e5Sespie   variable = ffecom_arg_ptr_to_expr (expr, &size);
921*c87b03e5Sespie 
922*c87b03e5Sespie   if ((variable == error_mark_node)
923*c87b03e5Sespie       || (size == error_mark_node))
924*c87b03e5Sespie     return error_mark_node;
925*c87b03e5Sespie 
926*c87b03e5Sespie   if (size == NULL_TREE)	/* Already filled in for CHARACTER type. */
927*c87b03e5Sespie     {				/* "(ftnlen) sizeof(type)" */
928*c87b03e5Sespie       size = size_binop (CEIL_DIV_EXPR,
929*c87b03e5Sespie 			 TYPE_SIZE_UNIT (ffecom_tree_type[bt][kt]),
930*c87b03e5Sespie 			 size_int (TYPE_PRECISION (char_type_node)
931*c87b03e5Sespie 				   / BITS_PER_UNIT));
932*c87b03e5Sespie #if 0	/* Assume that while it is possible that char * is wider than
933*c87b03e5Sespie 	   ftnlen, no object in Fortran space can get big enough for its
934*c87b03e5Sespie 	   size to be wider than ftnlen.  I really hope nobody wastes
935*c87b03e5Sespie 	   time debugging a case where it can!  */
936*c87b03e5Sespie       assert (TYPE_PRECISION (ffecom_f2c_ftnlen_type_node)
937*c87b03e5Sespie 	      >= TYPE_PRECISION (TREE_TYPE (size)));
938*c87b03e5Sespie #endif
939*c87b03e5Sespie       size = convert (ffecom_f2c_ftnlen_type_node, size);
940*c87b03e5Sespie     }
941*c87b03e5Sespie 
942*c87b03e5Sespie   if (ffeinfo_rank (ffebld_info (expr)) == 0
943*c87b03e5Sespie       || TREE_CODE (TREE_TYPE (TREE_TYPE (variable))) != ARRAY_TYPE)
944*c87b03e5Sespie     num_elements
945*c87b03e5Sespie       = is_complex ? ffecom_f2c_ftnlen_two_node : ffecom_f2c_ftnlen_one_node;
946*c87b03e5Sespie   else
947*c87b03e5Sespie     {
948*c87b03e5Sespie       num_elements
949*c87b03e5Sespie 	= size_binop (CEIL_DIV_EXPR,
950*c87b03e5Sespie 		      TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (variable))),
951*c87b03e5Sespie 		      convert (sizetype, size));
952*c87b03e5Sespie       num_elements = size_binop (CEIL_DIV_EXPR, num_elements,
953*c87b03e5Sespie 				 size_int (TYPE_PRECISION (char_type_node)
954*c87b03e5Sespie 					   / BITS_PER_UNIT));
955*c87b03e5Sespie       num_elements = convert (ffecom_f2c_ftnlen_type_node,
956*c87b03e5Sespie 			      num_elements);
957*c87b03e5Sespie     }
958*c87b03e5Sespie 
959*c87b03e5Sespie   num_elements
960*c87b03e5Sespie     = ffecom_1 (ADDR_EXPR, ffecom_f2c_ptr_to_ftnlen_type_node,
961*c87b03e5Sespie 		num_elements);
962*c87b03e5Sespie 
963*c87b03e5Sespie   variable = convert (string_type_node, variable);
964*c87b03e5Sespie 
965*c87b03e5Sespie   arglist = build_tree_list (NULL_TREE, num_elements);
966*c87b03e5Sespie   TREE_CHAIN (arglist) = build_tree_list (NULL_TREE, variable);
967*c87b03e5Sespie   TREE_CHAIN (TREE_CHAIN (arglist)) = build_tree_list (NULL_TREE, size);
968*c87b03e5Sespie 
969*c87b03e5Sespie   return ffecom_call_gfrt (FFECOM_gfrtDOFIO, arglist, NULL_TREE);
970*c87b03e5Sespie }
971*c87b03e5Sespie 
972*c87b03e5Sespie /* I/O driver for list-directed I/O item (do_lio)
973*c87b03e5Sespie 
974*c87b03e5Sespie    Returns a tree for a CALL_EXPR to the do_lio function, which handles
975*c87b03e5Sespie    a list-directed I/O list item, along with the appropriate arguments for
976*c87b03e5Sespie    the function.  It is up to the caller to set the TREE_SIDE_EFFECTS flag
977*c87b03e5Sespie    for the CALL_EXPR, expand (emit) the expression, emit any assignment
978*c87b03e5Sespie    of the result to an IOSTAT= variable, and emit any checking of the
979*c87b03e5Sespie    result for errors.  */
980*c87b03e5Sespie 
981*c87b03e5Sespie static tree
ffeste_io_dolio_(ffebld expr)982*c87b03e5Sespie ffeste_io_dolio_ (ffebld expr)
983*c87b03e5Sespie {
984*c87b03e5Sespie   tree type_id;
985*c87b03e5Sespie   tree num_elements;
986*c87b03e5Sespie   tree variable;
987*c87b03e5Sespie   tree size;
988*c87b03e5Sespie   tree arglist;
989*c87b03e5Sespie   ffeinfoBasictype bt;
990*c87b03e5Sespie   ffeinfoKindtype kt;
991*c87b03e5Sespie   int tc;
992*c87b03e5Sespie 
993*c87b03e5Sespie   bt = ffeinfo_basictype (ffebld_info (expr));
994*c87b03e5Sespie   kt = ffeinfo_kindtype (ffebld_info (expr));
995*c87b03e5Sespie 
996*c87b03e5Sespie   if ((bt == FFEINFO_basictypeANY)
997*c87b03e5Sespie       || (kt == FFEINFO_kindtypeANY))
998*c87b03e5Sespie     return error_mark_node;
999*c87b03e5Sespie 
1000*c87b03e5Sespie   tc = ffecom_f2c_typecode (bt, kt);
1001*c87b03e5Sespie   assert (tc != -1);
1002*c87b03e5Sespie   type_id = build_int_2 (tc, 0);
1003*c87b03e5Sespie 
1004*c87b03e5Sespie   type_id
1005*c87b03e5Sespie     = ffecom_1 (ADDR_EXPR, ffecom_f2c_ptr_to_ftnint_type_node,
1006*c87b03e5Sespie 		convert (ffecom_f2c_ftnint_type_node,
1007*c87b03e5Sespie 			 type_id));
1008*c87b03e5Sespie 
1009*c87b03e5Sespie   variable = ffecom_arg_ptr_to_expr (expr, &size);
1010*c87b03e5Sespie 
1011*c87b03e5Sespie   if ((type_id == error_mark_node)
1012*c87b03e5Sespie       || (variable == error_mark_node)
1013*c87b03e5Sespie       || (size == error_mark_node))
1014*c87b03e5Sespie     return error_mark_node;
1015*c87b03e5Sespie 
1016*c87b03e5Sespie   if (size == NULL_TREE)	/* Already filled in for CHARACTER type. */
1017*c87b03e5Sespie     {				/* "(ftnlen) sizeof(type)" */
1018*c87b03e5Sespie       size = size_binop (CEIL_DIV_EXPR,
1019*c87b03e5Sespie 			 TYPE_SIZE_UNIT (ffecom_tree_type[bt][kt]),
1020*c87b03e5Sespie 			 size_int (TYPE_PRECISION (char_type_node)
1021*c87b03e5Sespie 				   / BITS_PER_UNIT));
1022*c87b03e5Sespie #if 0	/* Assume that while it is possible that char * is wider than
1023*c87b03e5Sespie 	   ftnlen, no object in Fortran space can get big enough for its
1024*c87b03e5Sespie 	   size to be wider than ftnlen.  I really hope nobody wastes
1025*c87b03e5Sespie 	   time debugging a case where it can!  */
1026*c87b03e5Sespie       assert (TYPE_PRECISION (ffecom_f2c_ftnlen_type_node)
1027*c87b03e5Sespie 	      >= TYPE_PRECISION (TREE_TYPE (size)));
1028*c87b03e5Sespie #endif
1029*c87b03e5Sespie       size = convert (ffecom_f2c_ftnlen_type_node, size);
1030*c87b03e5Sespie     }
1031*c87b03e5Sespie 
1032*c87b03e5Sespie   if (ffeinfo_rank (ffebld_info (expr)) == 0
1033*c87b03e5Sespie       || TREE_CODE (TREE_TYPE (TREE_TYPE (variable))) != ARRAY_TYPE)
1034*c87b03e5Sespie     num_elements = ffecom_integer_one_node;
1035*c87b03e5Sespie   else
1036*c87b03e5Sespie     {
1037*c87b03e5Sespie       num_elements
1038*c87b03e5Sespie 	= size_binop (CEIL_DIV_EXPR,
1039*c87b03e5Sespie 		      TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (variable))),
1040*c87b03e5Sespie 		      convert (sizetype, size));
1041*c87b03e5Sespie       num_elements = size_binop (CEIL_DIV_EXPR, num_elements,
1042*c87b03e5Sespie 				 size_int (TYPE_PRECISION (char_type_node)
1043*c87b03e5Sespie 					   / BITS_PER_UNIT));
1044*c87b03e5Sespie       num_elements = convert (ffecom_f2c_ftnlen_type_node,
1045*c87b03e5Sespie 			      num_elements);
1046*c87b03e5Sespie     }
1047*c87b03e5Sespie 
1048*c87b03e5Sespie   num_elements
1049*c87b03e5Sespie     = ffecom_1 (ADDR_EXPR, ffecom_f2c_ptr_to_ftnlen_type_node,
1050*c87b03e5Sespie 		num_elements);
1051*c87b03e5Sespie 
1052*c87b03e5Sespie   variable = convert (string_type_node, variable);
1053*c87b03e5Sespie 
1054*c87b03e5Sespie   arglist = build_tree_list (NULL_TREE, type_id);
1055*c87b03e5Sespie   TREE_CHAIN (arglist) = build_tree_list (NULL_TREE, num_elements);
1056*c87b03e5Sespie   TREE_CHAIN (TREE_CHAIN (arglist)) = build_tree_list (NULL_TREE, variable);
1057*c87b03e5Sespie   TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (arglist)))
1058*c87b03e5Sespie     = build_tree_list (NULL_TREE, size);
1059*c87b03e5Sespie 
1060*c87b03e5Sespie   return ffecom_call_gfrt (FFECOM_gfrtDOLIO, arglist, NULL_TREE);
1061*c87b03e5Sespie }
1062*c87b03e5Sespie 
1063*c87b03e5Sespie /* I/O driver for unformatted I/O item (do_uio)
1064*c87b03e5Sespie 
1065*c87b03e5Sespie    Returns a tree for a CALL_EXPR to the do_uio function, which handles
1066*c87b03e5Sespie    an unformatted I/O list item, along with the appropriate arguments for
1067*c87b03e5Sespie    the function.  It is up to the caller to set the TREE_SIDE_EFFECTS flag
1068*c87b03e5Sespie    for the CALL_EXPR, expand (emit) the expression, emit any assignment
1069*c87b03e5Sespie    of the result to an IOSTAT= variable, and emit any checking of the
1070*c87b03e5Sespie    result for errors.  */
1071*c87b03e5Sespie 
1072*c87b03e5Sespie static tree
ffeste_io_douio_(ffebld expr)1073*c87b03e5Sespie ffeste_io_douio_ (ffebld expr)
1074*c87b03e5Sespie {
1075*c87b03e5Sespie   tree num_elements;
1076*c87b03e5Sespie   tree variable;
1077*c87b03e5Sespie   tree size;
1078*c87b03e5Sespie   tree arglist;
1079*c87b03e5Sespie   ffeinfoBasictype bt;
1080*c87b03e5Sespie   ffeinfoKindtype kt;
1081*c87b03e5Sespie   bool is_complex;
1082*c87b03e5Sespie 
1083*c87b03e5Sespie   bt = ffeinfo_basictype (ffebld_info (expr));
1084*c87b03e5Sespie   kt = ffeinfo_kindtype (ffebld_info (expr));
1085*c87b03e5Sespie 
1086*c87b03e5Sespie   if ((bt == FFEINFO_basictypeANY)
1087*c87b03e5Sespie       || (kt == FFEINFO_kindtypeANY))
1088*c87b03e5Sespie     return error_mark_node;
1089*c87b03e5Sespie 
1090*c87b03e5Sespie   if (bt == FFEINFO_basictypeCOMPLEX)
1091*c87b03e5Sespie     {
1092*c87b03e5Sespie       is_complex = TRUE;
1093*c87b03e5Sespie       bt = FFEINFO_basictypeREAL;
1094*c87b03e5Sespie     }
1095*c87b03e5Sespie   else
1096*c87b03e5Sespie     is_complex = FALSE;
1097*c87b03e5Sespie 
1098*c87b03e5Sespie   variable = ffecom_arg_ptr_to_expr (expr, &size);
1099*c87b03e5Sespie 
1100*c87b03e5Sespie   if ((variable == error_mark_node)
1101*c87b03e5Sespie       || (size == error_mark_node))
1102*c87b03e5Sespie     return error_mark_node;
1103*c87b03e5Sespie 
1104*c87b03e5Sespie   if (size == NULL_TREE)	/* Already filled in for CHARACTER type. */
1105*c87b03e5Sespie     {				/* "(ftnlen) sizeof(type)" */
1106*c87b03e5Sespie       size = size_binop (CEIL_DIV_EXPR,
1107*c87b03e5Sespie 			 TYPE_SIZE_UNIT (ffecom_tree_type[bt][kt]),
1108*c87b03e5Sespie 			 size_int (TYPE_PRECISION (char_type_node)
1109*c87b03e5Sespie 				   / BITS_PER_UNIT));
1110*c87b03e5Sespie #if 0	/* Assume that while it is possible that char * is wider than
1111*c87b03e5Sespie 	   ftnlen, no object in Fortran space can get big enough for its
1112*c87b03e5Sespie 	   size to be wider than ftnlen.  I really hope nobody wastes
1113*c87b03e5Sespie 	   time debugging a case where it can!  */
1114*c87b03e5Sespie       assert (TYPE_PRECISION (ffecom_f2c_ftnlen_type_node)
1115*c87b03e5Sespie 	      >= TYPE_PRECISION (TREE_TYPE (size)));
1116*c87b03e5Sespie #endif
1117*c87b03e5Sespie       size = convert (ffecom_f2c_ftnlen_type_node, size);
1118*c87b03e5Sespie     }
1119*c87b03e5Sespie 
1120*c87b03e5Sespie   if (ffeinfo_rank (ffebld_info (expr)) == 0
1121*c87b03e5Sespie       || TREE_CODE (TREE_TYPE (TREE_TYPE (variable))) != ARRAY_TYPE)
1122*c87b03e5Sespie     num_elements
1123*c87b03e5Sespie       = is_complex ? ffecom_f2c_ftnlen_two_node : ffecom_f2c_ftnlen_one_node;
1124*c87b03e5Sespie   else
1125*c87b03e5Sespie     {
1126*c87b03e5Sespie       num_elements
1127*c87b03e5Sespie 	= size_binop (CEIL_DIV_EXPR,
1128*c87b03e5Sespie 		      TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (variable))),
1129*c87b03e5Sespie 		      convert (sizetype, size));
1130*c87b03e5Sespie       num_elements = size_binop (CEIL_DIV_EXPR, num_elements,
1131*c87b03e5Sespie 				 size_int (TYPE_PRECISION (char_type_node)
1132*c87b03e5Sespie 					   / BITS_PER_UNIT));
1133*c87b03e5Sespie       num_elements = convert (ffecom_f2c_ftnlen_type_node,
1134*c87b03e5Sespie 			      num_elements);
1135*c87b03e5Sespie     }
1136*c87b03e5Sespie 
1137*c87b03e5Sespie   num_elements
1138*c87b03e5Sespie     = ffecom_1 (ADDR_EXPR, ffecom_f2c_ptr_to_ftnlen_type_node,
1139*c87b03e5Sespie 		num_elements);
1140*c87b03e5Sespie 
1141*c87b03e5Sespie   variable = convert (string_type_node, variable);
1142*c87b03e5Sespie 
1143*c87b03e5Sespie   arglist = build_tree_list (NULL_TREE, num_elements);
1144*c87b03e5Sespie   TREE_CHAIN (arglist) = build_tree_list (NULL_TREE, variable);
1145*c87b03e5Sespie   TREE_CHAIN (TREE_CHAIN (arglist)) = build_tree_list (NULL_TREE, size);
1146*c87b03e5Sespie 
1147*c87b03e5Sespie   return ffecom_call_gfrt (FFECOM_gfrtDOUIO, arglist, NULL_TREE);
1148*c87b03e5Sespie }
1149*c87b03e5Sespie 
1150*c87b03e5Sespie /* Make arglist with ptr to BACKSPACE/ENDFILE/REWIND control list.
1151*c87b03e5Sespie 
1152*c87b03e5Sespie    Returns a tree suitable as an argument list containing a pointer to
1153*c87b03e5Sespie    a BACKSPACE/ENDFILE/REWIND control list.  First, generates that control
1154*c87b03e5Sespie    list, if necessary, along with any static and run-time initializations
1155*c87b03e5Sespie    that are needed as specified by the arguments to this function.
1156*c87b03e5Sespie 
1157*c87b03e5Sespie    Must ensure that all expressions are prepared before being evaluated,
1158*c87b03e5Sespie    for any whose evaluation might result in the generation of temporaries.
1159*c87b03e5Sespie 
1160*c87b03e5Sespie    Note that this means this function causes a transition, within the
1161*c87b03e5Sespie    current block being code-generated via the back end, from the
1162*c87b03e5Sespie    declaration of variables (temporaries) to the expanding of expressions,
1163*c87b03e5Sespie    statements, etc.  */
1164*c87b03e5Sespie 
1165*c87b03e5Sespie static GTY(()) tree f2c_alist_struct;
1166*c87b03e5Sespie static tree
ffeste_io_ialist_(bool have_err,ffestvUnit unit,ffebld unit_expr,int unit_dflt)1167*c87b03e5Sespie ffeste_io_ialist_ (bool have_err,
1168*c87b03e5Sespie 		   ffestvUnit unit,
1169*c87b03e5Sespie 		   ffebld unit_expr,
1170*c87b03e5Sespie 		   int unit_dflt)
1171*c87b03e5Sespie {
1172*c87b03e5Sespie   tree t;
1173*c87b03e5Sespie   tree ttype;
1174*c87b03e5Sespie   tree field;
1175*c87b03e5Sespie   tree inits, initn;
1176*c87b03e5Sespie   bool constantp = TRUE;
1177*c87b03e5Sespie   static tree errfield, unitfield;
1178*c87b03e5Sespie   tree errinit, unitinit;
1179*c87b03e5Sespie   tree unitexp;
1180*c87b03e5Sespie   static int mynumber = 0;
1181*c87b03e5Sespie 
1182*c87b03e5Sespie   if (f2c_alist_struct == NULL_TREE)
1183*c87b03e5Sespie     {
1184*c87b03e5Sespie       tree ref;
1185*c87b03e5Sespie 
1186*c87b03e5Sespie       ref = make_node (RECORD_TYPE);
1187*c87b03e5Sespie 
1188*c87b03e5Sespie       errfield = ffecom_decl_field (ref, NULL_TREE, "err",
1189*c87b03e5Sespie 				    ffecom_f2c_flag_type_node);
1190*c87b03e5Sespie       unitfield = ffecom_decl_field (ref, errfield, "unit",
1191*c87b03e5Sespie 				     ffecom_f2c_ftnint_type_node);
1192*c87b03e5Sespie 
1193*c87b03e5Sespie       TYPE_FIELDS (ref) = errfield;
1194*c87b03e5Sespie       layout_type (ref);
1195*c87b03e5Sespie 
1196*c87b03e5Sespie       f2c_alist_struct = ref;
1197*c87b03e5Sespie     }
1198*c87b03e5Sespie 
1199*c87b03e5Sespie   /* Try to do as much compile-time initialization of the structure
1200*c87b03e5Sespie      as possible, to save run time.  */
1201*c87b03e5Sespie 
1202*c87b03e5Sespie   ffeste_f2c_init_flag_ (have_err, errinit);
1203*c87b03e5Sespie 
1204*c87b03e5Sespie   switch (unit)
1205*c87b03e5Sespie     {
1206*c87b03e5Sespie     case FFESTV_unitNONE:
1207*c87b03e5Sespie     case FFESTV_unitASTERISK:
1208*c87b03e5Sespie       unitinit = build_int_2 (unit_dflt, 0);
1209*c87b03e5Sespie       unitexp = unitinit;
1210*c87b03e5Sespie       break;
1211*c87b03e5Sespie 
1212*c87b03e5Sespie     case FFESTV_unitINTEXPR:
1213*c87b03e5Sespie       unitexp = ffecom_const_expr (unit_expr);
1214*c87b03e5Sespie       if (unitexp)
1215*c87b03e5Sespie 	unitinit = unitexp;
1216*c87b03e5Sespie       else
1217*c87b03e5Sespie 	{
1218*c87b03e5Sespie 	  unitinit = ffecom_integer_zero_node;
1219*c87b03e5Sespie 	  constantp = FALSE;
1220*c87b03e5Sespie 	}
1221*c87b03e5Sespie       break;
1222*c87b03e5Sespie 
1223*c87b03e5Sespie     default:
1224*c87b03e5Sespie       assert ("bad unit spec" == NULL);
1225*c87b03e5Sespie       unitinit = ffecom_integer_zero_node;
1226*c87b03e5Sespie       unitexp = unitinit;
1227*c87b03e5Sespie       break;
1228*c87b03e5Sespie     }
1229*c87b03e5Sespie 
1230*c87b03e5Sespie   inits = build_tree_list ((field = TYPE_FIELDS (f2c_alist_struct)), errinit);
1231*c87b03e5Sespie   initn = inits;
1232*c87b03e5Sespie   ffeste_f2c_init_next_ (unitinit);
1233*c87b03e5Sespie 
1234*c87b03e5Sespie   inits = build (CONSTRUCTOR, f2c_alist_struct, NULL_TREE, inits);
1235*c87b03e5Sespie   TREE_CONSTANT (inits) = constantp ? 1 : 0;
1236*c87b03e5Sespie   TREE_STATIC (inits) = 1;
1237*c87b03e5Sespie 
1238*c87b03e5Sespie   t = build_decl (VAR_DECL,
1239*c87b03e5Sespie 		  ffecom_get_invented_identifier ("__g77_alist_%d",
1240*c87b03e5Sespie 						  mynumber++),
1241*c87b03e5Sespie 		  f2c_alist_struct);
1242*c87b03e5Sespie   TREE_STATIC (t) = 1;
1243*c87b03e5Sespie   t = ffecom_start_decl (t, 1);
1244*c87b03e5Sespie   ffecom_finish_decl (t, inits, 0);
1245*c87b03e5Sespie 
1246*c87b03e5Sespie   /* Prepare run-time expressions.  */
1247*c87b03e5Sespie 
1248*c87b03e5Sespie   if (! unitexp)
1249*c87b03e5Sespie     ffecom_prepare_expr (unit_expr);
1250*c87b03e5Sespie 
1251*c87b03e5Sespie   ffecom_prepare_end ();
1252*c87b03e5Sespie 
1253*c87b03e5Sespie   /* Now evaluate run-time expressions as needed.  */
1254*c87b03e5Sespie 
1255*c87b03e5Sespie   if (! unitexp)
1256*c87b03e5Sespie     {
1257*c87b03e5Sespie       unitexp = ffecom_expr (unit_expr);
1258*c87b03e5Sespie       ffeste_f2c_compile_ (unitfield, unitexp);
1259*c87b03e5Sespie     }
1260*c87b03e5Sespie 
1261*c87b03e5Sespie   ttype = build_pointer_type (TREE_TYPE (t));
1262*c87b03e5Sespie   t = ffecom_1 (ADDR_EXPR, ttype, t);
1263*c87b03e5Sespie 
1264*c87b03e5Sespie   t = build_tree_list (NULL_TREE, t);
1265*c87b03e5Sespie 
1266*c87b03e5Sespie   return t;
1267*c87b03e5Sespie }
1268*c87b03e5Sespie 
1269*c87b03e5Sespie /* Make arglist with ptr to external-I/O control list.
1270*c87b03e5Sespie 
1271*c87b03e5Sespie    Returns a tree suitable as an argument list containing a pointer to
1272*c87b03e5Sespie    an external-I/O control list.  First, generates that control
1273*c87b03e5Sespie    list, if necessary, along with any static and run-time initializations
1274*c87b03e5Sespie    that are needed as specified by the arguments to this function.
1275*c87b03e5Sespie 
1276*c87b03e5Sespie    Must ensure that all expressions are prepared before being evaluated,
1277*c87b03e5Sespie    for any whose evaluation might result in the generation of temporaries.
1278*c87b03e5Sespie 
1279*c87b03e5Sespie    Note that this means this function causes a transition, within the
1280*c87b03e5Sespie    current block being code-generated via the back end, from the
1281*c87b03e5Sespie    declaration of variables (temporaries) to the expanding of expressions,
1282*c87b03e5Sespie    statements, etc.  */
1283*c87b03e5Sespie 
1284*c87b03e5Sespie static GTY(()) tree f2c_cilist_struct;
1285*c87b03e5Sespie static tree
ffeste_io_cilist_(bool have_err,ffestvUnit unit,ffebld unit_expr,int unit_dflt,bool have_end,ffestvFormat format,ffestpFile * format_spec,bool rec,ffebld rec_expr)1286*c87b03e5Sespie ffeste_io_cilist_ (bool have_err,
1287*c87b03e5Sespie 		   ffestvUnit unit,
1288*c87b03e5Sespie 		   ffebld unit_expr,
1289*c87b03e5Sespie 		   int unit_dflt,
1290*c87b03e5Sespie 		   bool have_end,
1291*c87b03e5Sespie 		   ffestvFormat format,
1292*c87b03e5Sespie 		   ffestpFile *format_spec,
1293*c87b03e5Sespie 		   bool rec,
1294*c87b03e5Sespie 		   ffebld rec_expr)
1295*c87b03e5Sespie {
1296*c87b03e5Sespie   tree t;
1297*c87b03e5Sespie   tree ttype;
1298*c87b03e5Sespie   tree field;
1299*c87b03e5Sespie   tree inits, initn;
1300*c87b03e5Sespie   bool constantp = TRUE;
1301*c87b03e5Sespie   static tree errfield, unitfield, endfield, formatfield, recfield;
1302*c87b03e5Sespie   tree errinit, unitinit, endinit, formatinit, recinit;
1303*c87b03e5Sespie   tree unitexp, formatexp, recexp;
1304*c87b03e5Sespie   static int mynumber = 0;
1305*c87b03e5Sespie 
1306*c87b03e5Sespie   if (f2c_cilist_struct == NULL_TREE)
1307*c87b03e5Sespie     {
1308*c87b03e5Sespie       tree ref;
1309*c87b03e5Sespie 
1310*c87b03e5Sespie       ref = make_node (RECORD_TYPE);
1311*c87b03e5Sespie 
1312*c87b03e5Sespie       errfield = ffecom_decl_field (ref, NULL_TREE, "err",
1313*c87b03e5Sespie 				    ffecom_f2c_flag_type_node);
1314*c87b03e5Sespie       unitfield = ffecom_decl_field (ref, errfield, "unit",
1315*c87b03e5Sespie 				     ffecom_f2c_ftnint_type_node);
1316*c87b03e5Sespie       endfield = ffecom_decl_field (ref, unitfield, "end",
1317*c87b03e5Sespie 				    ffecom_f2c_flag_type_node);
1318*c87b03e5Sespie       formatfield = ffecom_decl_field (ref, endfield, "format",
1319*c87b03e5Sespie 				       string_type_node);
1320*c87b03e5Sespie       recfield = ffecom_decl_field (ref, formatfield, "rec",
1321*c87b03e5Sespie 				    ffecom_f2c_ftnint_type_node);
1322*c87b03e5Sespie 
1323*c87b03e5Sespie       TYPE_FIELDS (ref) = errfield;
1324*c87b03e5Sespie       layout_type (ref);
1325*c87b03e5Sespie 
1326*c87b03e5Sespie       f2c_cilist_struct = ref;
1327*c87b03e5Sespie     }
1328*c87b03e5Sespie 
1329*c87b03e5Sespie   /* Try to do as much compile-time initialization of the structure
1330*c87b03e5Sespie      as possible, to save run time.  */
1331*c87b03e5Sespie 
1332*c87b03e5Sespie   ffeste_f2c_init_flag_ (have_err, errinit);
1333*c87b03e5Sespie 
1334*c87b03e5Sespie   switch (unit)
1335*c87b03e5Sespie     {
1336*c87b03e5Sespie     case FFESTV_unitNONE:
1337*c87b03e5Sespie     case FFESTV_unitASTERISK:
1338*c87b03e5Sespie       unitinit = build_int_2 (unit_dflt, 0);
1339*c87b03e5Sespie       unitexp = unitinit;
1340*c87b03e5Sespie       break;
1341*c87b03e5Sespie 
1342*c87b03e5Sespie     case FFESTV_unitINTEXPR:
1343*c87b03e5Sespie       unitexp = ffecom_const_expr (unit_expr);
1344*c87b03e5Sespie       if (unitexp)
1345*c87b03e5Sespie 	unitinit = unitexp;
1346*c87b03e5Sespie       else
1347*c87b03e5Sespie 	{
1348*c87b03e5Sespie 	  unitinit = ffecom_integer_zero_node;
1349*c87b03e5Sespie 	  constantp = FALSE;
1350*c87b03e5Sespie 	}
1351*c87b03e5Sespie       break;
1352*c87b03e5Sespie 
1353*c87b03e5Sespie     default:
1354*c87b03e5Sespie       assert ("bad unit spec" == NULL);
1355*c87b03e5Sespie       unitinit = ffecom_integer_zero_node;
1356*c87b03e5Sespie       unitexp = unitinit;
1357*c87b03e5Sespie       break;
1358*c87b03e5Sespie     }
1359*c87b03e5Sespie 
1360*c87b03e5Sespie   switch (format)
1361*c87b03e5Sespie     {
1362*c87b03e5Sespie     case FFESTV_formatNONE:
1363*c87b03e5Sespie       formatinit = null_pointer_node;
1364*c87b03e5Sespie       formatexp = formatinit;
1365*c87b03e5Sespie       break;
1366*c87b03e5Sespie 
1367*c87b03e5Sespie     case FFESTV_formatLABEL:
1368*c87b03e5Sespie       formatexp = error_mark_node;
1369*c87b03e5Sespie       formatinit = ffecom_lookup_label (format_spec->u.label);
1370*c87b03e5Sespie       if ((formatinit == NULL_TREE)
1371*c87b03e5Sespie 	  || (TREE_CODE (formatinit) == ERROR_MARK))
1372*c87b03e5Sespie 	break;
1373*c87b03e5Sespie       formatinit = ffecom_1 (ADDR_EXPR,
1374*c87b03e5Sespie 			     build_pointer_type (void_type_node),
1375*c87b03e5Sespie 			     formatinit);
1376*c87b03e5Sespie       TREE_CONSTANT (formatinit) = 1;
1377*c87b03e5Sespie       break;
1378*c87b03e5Sespie 
1379*c87b03e5Sespie     case FFESTV_formatCHAREXPR:
1380*c87b03e5Sespie       formatexp = ffecom_arg_ptr_to_const_expr (format_spec->u.expr, NULL);
1381*c87b03e5Sespie       if (formatexp)
1382*c87b03e5Sespie 	formatinit = formatexp;
1383*c87b03e5Sespie       else
1384*c87b03e5Sespie 	{
1385*c87b03e5Sespie 	  formatinit = null_pointer_node;
1386*c87b03e5Sespie 	  constantp = FALSE;
1387*c87b03e5Sespie 	}
1388*c87b03e5Sespie       break;
1389*c87b03e5Sespie 
1390*c87b03e5Sespie     case FFESTV_formatASTERISK:
1391*c87b03e5Sespie       formatinit = null_pointer_node;
1392*c87b03e5Sespie       formatexp = formatinit;
1393*c87b03e5Sespie       break;
1394*c87b03e5Sespie 
1395*c87b03e5Sespie     case FFESTV_formatINTEXPR:
1396*c87b03e5Sespie       formatinit = null_pointer_node;
1397*c87b03e5Sespie       formatexp = ffecom_expr_assign (format_spec->u.expr);
1398*c87b03e5Sespie       if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (formatexp)))
1399*c87b03e5Sespie 	  < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (null_pointer_node))))
1400*c87b03e5Sespie 	error ("ASSIGNed FORMAT specifier is too small");
1401*c87b03e5Sespie       formatexp = convert (string_type_node, formatexp);
1402*c87b03e5Sespie       break;
1403*c87b03e5Sespie 
1404*c87b03e5Sespie     case FFESTV_formatNAMELIST:
1405*c87b03e5Sespie       formatinit = ffecom_expr (format_spec->u.expr);
1406*c87b03e5Sespie       formatexp = formatinit;
1407*c87b03e5Sespie       break;
1408*c87b03e5Sespie 
1409*c87b03e5Sespie     default:
1410*c87b03e5Sespie       assert ("bad format spec" == NULL);
1411*c87b03e5Sespie       formatinit = integer_zero_node;
1412*c87b03e5Sespie       formatexp = formatinit;
1413*c87b03e5Sespie       break;
1414*c87b03e5Sespie     }
1415*c87b03e5Sespie 
1416*c87b03e5Sespie   ffeste_f2c_init_flag_ (have_end, endinit);
1417*c87b03e5Sespie 
1418*c87b03e5Sespie   if (rec)
1419*c87b03e5Sespie     recexp = ffecom_const_expr (rec_expr);
1420*c87b03e5Sespie   else
1421*c87b03e5Sespie     recexp = ffecom_integer_zero_node;
1422*c87b03e5Sespie   if (recexp)
1423*c87b03e5Sespie     recinit = recexp;
1424*c87b03e5Sespie   else
1425*c87b03e5Sespie     {
1426*c87b03e5Sespie       recinit = ffecom_integer_zero_node;
1427*c87b03e5Sespie       constantp = FALSE;
1428*c87b03e5Sespie     }
1429*c87b03e5Sespie 
1430*c87b03e5Sespie   inits = build_tree_list ((field = TYPE_FIELDS (f2c_cilist_struct)), errinit);
1431*c87b03e5Sespie   initn = inits;
1432*c87b03e5Sespie   ffeste_f2c_init_next_ (unitinit);
1433*c87b03e5Sespie   ffeste_f2c_init_next_ (endinit);
1434*c87b03e5Sespie   ffeste_f2c_init_next_ (formatinit);
1435*c87b03e5Sespie   ffeste_f2c_init_next_ (recinit);
1436*c87b03e5Sespie 
1437*c87b03e5Sespie   inits = build (CONSTRUCTOR, f2c_cilist_struct, NULL_TREE, inits);
1438*c87b03e5Sespie   TREE_CONSTANT (inits) = constantp ? 1 : 0;
1439*c87b03e5Sespie   TREE_STATIC (inits) = 1;
1440*c87b03e5Sespie 
1441*c87b03e5Sespie   t = build_decl (VAR_DECL,
1442*c87b03e5Sespie 		  ffecom_get_invented_identifier ("__g77_cilist_%d",
1443*c87b03e5Sespie 						  mynumber++),
1444*c87b03e5Sespie 		  f2c_cilist_struct);
1445*c87b03e5Sespie   TREE_STATIC (t) = 1;
1446*c87b03e5Sespie   t = ffecom_start_decl (t, 1);
1447*c87b03e5Sespie   ffecom_finish_decl (t, inits, 0);
1448*c87b03e5Sespie 
1449*c87b03e5Sespie   /* Prepare run-time expressions.  */
1450*c87b03e5Sespie 
1451*c87b03e5Sespie   if (! unitexp)
1452*c87b03e5Sespie     ffecom_prepare_expr (unit_expr);
1453*c87b03e5Sespie 
1454*c87b03e5Sespie   if (! formatexp)
1455*c87b03e5Sespie     ffecom_prepare_arg_ptr_to_expr (format_spec->u.expr);
1456*c87b03e5Sespie 
1457*c87b03e5Sespie   if (! recexp)
1458*c87b03e5Sespie     ffecom_prepare_expr (rec_expr);
1459*c87b03e5Sespie 
1460*c87b03e5Sespie   ffecom_prepare_end ();
1461*c87b03e5Sespie 
1462*c87b03e5Sespie   /* Now evaluate run-time expressions as needed.  */
1463*c87b03e5Sespie 
1464*c87b03e5Sespie   if (! unitexp)
1465*c87b03e5Sespie     {
1466*c87b03e5Sespie       unitexp = ffecom_expr (unit_expr);
1467*c87b03e5Sespie       ffeste_f2c_compile_ (unitfield, unitexp);
1468*c87b03e5Sespie     }
1469*c87b03e5Sespie 
1470*c87b03e5Sespie   if (! formatexp)
1471*c87b03e5Sespie     {
1472*c87b03e5Sespie       formatexp = ffecom_arg_ptr_to_expr (format_spec->u.expr, NULL);
1473*c87b03e5Sespie       ffeste_f2c_compile_ (formatfield, formatexp);
1474*c87b03e5Sespie     }
1475*c87b03e5Sespie   else if (format == FFESTV_formatINTEXPR)
1476*c87b03e5Sespie     ffeste_f2c_compile_ (formatfield, formatexp);
1477*c87b03e5Sespie 
1478*c87b03e5Sespie   if (! recexp)
1479*c87b03e5Sespie     {
1480*c87b03e5Sespie       recexp = ffecom_expr (rec_expr);
1481*c87b03e5Sespie       ffeste_f2c_compile_ (recfield, recexp);
1482*c87b03e5Sespie     }
1483*c87b03e5Sespie 
1484*c87b03e5Sespie   ttype = build_pointer_type (TREE_TYPE (t));
1485*c87b03e5Sespie   t = ffecom_1 (ADDR_EXPR, ttype, t);
1486*c87b03e5Sespie 
1487*c87b03e5Sespie   t = build_tree_list (NULL_TREE, t);
1488*c87b03e5Sespie 
1489*c87b03e5Sespie   return t;
1490*c87b03e5Sespie }
1491*c87b03e5Sespie 
1492*c87b03e5Sespie /* Make arglist with ptr to CLOSE control list.
1493*c87b03e5Sespie 
1494*c87b03e5Sespie    Returns a tree suitable as an argument list containing a pointer to
1495*c87b03e5Sespie    a CLOSE-statement control list.  First, generates that control
1496*c87b03e5Sespie    list, if necessary, along with any static and run-time initializations
1497*c87b03e5Sespie    that are needed as specified by the arguments to this function.
1498*c87b03e5Sespie 
1499*c87b03e5Sespie    Must ensure that all expressions are prepared before being evaluated,
1500*c87b03e5Sespie    for any whose evaluation might result in the generation of temporaries.
1501*c87b03e5Sespie 
1502*c87b03e5Sespie    Note that this means this function causes a transition, within the
1503*c87b03e5Sespie    current block being code-generated via the back end, from the
1504*c87b03e5Sespie    declaration of variables (temporaries) to the expanding of expressions,
1505*c87b03e5Sespie    statements, etc.  */
1506*c87b03e5Sespie 
1507*c87b03e5Sespie static GTY(()) tree f2c_close_struct;
1508*c87b03e5Sespie static tree
ffeste_io_cllist_(bool have_err,ffebld unit_expr,ffestpFile * stat_spec)1509*c87b03e5Sespie ffeste_io_cllist_ (bool have_err,
1510*c87b03e5Sespie 		   ffebld unit_expr,
1511*c87b03e5Sespie 		   ffestpFile *stat_spec)
1512*c87b03e5Sespie {
1513*c87b03e5Sespie   tree t;
1514*c87b03e5Sespie   tree ttype;
1515*c87b03e5Sespie   tree field;
1516*c87b03e5Sespie   tree inits, initn;
1517*c87b03e5Sespie   tree ignore;			/* Ignore length info for certain fields. */
1518*c87b03e5Sespie   bool constantp = TRUE;
1519*c87b03e5Sespie   static tree errfield, unitfield, statfield;
1520*c87b03e5Sespie   tree errinit, unitinit, statinit;
1521*c87b03e5Sespie   tree unitexp, statexp;
1522*c87b03e5Sespie   static int mynumber = 0;
1523*c87b03e5Sespie 
1524*c87b03e5Sespie   if (f2c_close_struct == NULL_TREE)
1525*c87b03e5Sespie     {
1526*c87b03e5Sespie       tree ref;
1527*c87b03e5Sespie 
1528*c87b03e5Sespie       ref = make_node (RECORD_TYPE);
1529*c87b03e5Sespie 
1530*c87b03e5Sespie       errfield = ffecom_decl_field (ref, NULL_TREE, "err",
1531*c87b03e5Sespie 				    ffecom_f2c_flag_type_node);
1532*c87b03e5Sespie       unitfield = ffecom_decl_field (ref, errfield, "unit",
1533*c87b03e5Sespie 				     ffecom_f2c_ftnint_type_node);
1534*c87b03e5Sespie       statfield = ffecom_decl_field (ref, unitfield, "stat",
1535*c87b03e5Sespie 				     string_type_node);
1536*c87b03e5Sespie 
1537*c87b03e5Sespie       TYPE_FIELDS (ref) = errfield;
1538*c87b03e5Sespie       layout_type (ref);
1539*c87b03e5Sespie 
1540*c87b03e5Sespie       f2c_close_struct = ref;
1541*c87b03e5Sespie     }
1542*c87b03e5Sespie 
1543*c87b03e5Sespie   /* Try to do as much compile-time initialization of the structure
1544*c87b03e5Sespie      as possible, to save run time.  */
1545*c87b03e5Sespie 
1546*c87b03e5Sespie   ffeste_f2c_init_flag_ (have_err, errinit);
1547*c87b03e5Sespie 
1548*c87b03e5Sespie   unitexp = ffecom_const_expr (unit_expr);
1549*c87b03e5Sespie   if (unitexp)
1550*c87b03e5Sespie     unitinit = unitexp;
1551*c87b03e5Sespie   else
1552*c87b03e5Sespie     {
1553*c87b03e5Sespie       unitinit = ffecom_integer_zero_node;
1554*c87b03e5Sespie       constantp = FALSE;
1555*c87b03e5Sespie     }
1556*c87b03e5Sespie 
1557*c87b03e5Sespie   ffeste_f2c_init_charnolen_ (statexp, statinit, stat_spec);
1558*c87b03e5Sespie 
1559*c87b03e5Sespie   inits = build_tree_list ((field = TYPE_FIELDS (f2c_close_struct)), errinit);
1560*c87b03e5Sespie   initn = inits;
1561*c87b03e5Sespie   ffeste_f2c_init_next_ (unitinit);
1562*c87b03e5Sespie   ffeste_f2c_init_next_ (statinit);
1563*c87b03e5Sespie 
1564*c87b03e5Sespie   inits = build (CONSTRUCTOR, f2c_close_struct, NULL_TREE, inits);
1565*c87b03e5Sespie   TREE_CONSTANT (inits) = constantp ? 1 : 0;
1566*c87b03e5Sespie   TREE_STATIC (inits) = 1;
1567*c87b03e5Sespie 
1568*c87b03e5Sespie   t = build_decl (VAR_DECL,
1569*c87b03e5Sespie 		  ffecom_get_invented_identifier ("__g77_cllist_%d",
1570*c87b03e5Sespie 						  mynumber++),
1571*c87b03e5Sespie 		  f2c_close_struct);
1572*c87b03e5Sespie   TREE_STATIC (t) = 1;
1573*c87b03e5Sespie   t = ffecom_start_decl (t, 1);
1574*c87b03e5Sespie   ffecom_finish_decl (t, inits, 0);
1575*c87b03e5Sespie 
1576*c87b03e5Sespie   /* Prepare run-time expressions.  */
1577*c87b03e5Sespie 
1578*c87b03e5Sespie   if (! unitexp)
1579*c87b03e5Sespie     ffecom_prepare_expr (unit_expr);
1580*c87b03e5Sespie 
1581*c87b03e5Sespie   if (! statexp)
1582*c87b03e5Sespie     ffecom_prepare_arg_ptr_to_expr (stat_spec->u.expr);
1583*c87b03e5Sespie 
1584*c87b03e5Sespie   ffecom_prepare_end ();
1585*c87b03e5Sespie 
1586*c87b03e5Sespie   /* Now evaluate run-time expressions as needed.  */
1587*c87b03e5Sespie 
1588*c87b03e5Sespie   if (! unitexp)
1589*c87b03e5Sespie     {
1590*c87b03e5Sespie       unitexp = ffecom_expr (unit_expr);
1591*c87b03e5Sespie       ffeste_f2c_compile_ (unitfield, unitexp);
1592*c87b03e5Sespie     }
1593*c87b03e5Sespie 
1594*c87b03e5Sespie   ffeste_f2c_compile_charnolen_ (statfield, stat_spec, statexp);
1595*c87b03e5Sespie 
1596*c87b03e5Sespie   ttype = build_pointer_type (TREE_TYPE (t));
1597*c87b03e5Sespie   t = ffecom_1 (ADDR_EXPR, ttype, t);
1598*c87b03e5Sespie 
1599*c87b03e5Sespie   t = build_tree_list (NULL_TREE, t);
1600*c87b03e5Sespie 
1601*c87b03e5Sespie   return t;
1602*c87b03e5Sespie }
1603*c87b03e5Sespie 
1604*c87b03e5Sespie /* Make arglist with ptr to internal-I/O control list.
1605*c87b03e5Sespie 
1606*c87b03e5Sespie    Returns a tree suitable as an argument list containing a pointer to
1607*c87b03e5Sespie    an internal-I/O control list.  First, generates that control
1608*c87b03e5Sespie    list, if necessary, along with any static and run-time initializations
1609*c87b03e5Sespie    that are needed as specified by the arguments to this function.
1610*c87b03e5Sespie 
1611*c87b03e5Sespie    Must ensure that all expressions are prepared before being evaluated,
1612*c87b03e5Sespie    for any whose evaluation might result in the generation of temporaries.
1613*c87b03e5Sespie 
1614*c87b03e5Sespie    Note that this means this function causes a transition, within the
1615*c87b03e5Sespie    current block being code-generated via the back end, from the
1616*c87b03e5Sespie    declaration of variables (temporaries) to the expanding of expressions,
1617*c87b03e5Sespie    statements, etc.  */
1618*c87b03e5Sespie 
1619*c87b03e5Sespie static GTY(()) tree f2c_icilist_struct;
1620*c87b03e5Sespie static tree
ffeste_io_icilist_(bool have_err,ffebld unit_expr,bool have_end,ffestvFormat format,ffestpFile * format_spec)1621*c87b03e5Sespie ffeste_io_icilist_ (bool have_err,
1622*c87b03e5Sespie 		    ffebld unit_expr,
1623*c87b03e5Sespie 		    bool have_end,
1624*c87b03e5Sespie 		    ffestvFormat format,
1625*c87b03e5Sespie 		    ffestpFile *format_spec)
1626*c87b03e5Sespie {
1627*c87b03e5Sespie   tree t;
1628*c87b03e5Sespie   tree ttype;
1629*c87b03e5Sespie   tree field;
1630*c87b03e5Sespie   tree inits, initn;
1631*c87b03e5Sespie   bool constantp = TRUE;
1632*c87b03e5Sespie   static tree errfield, unitfield, endfield, formatfield, unitlenfield,
1633*c87b03e5Sespie     unitnumfield;
1634*c87b03e5Sespie   tree errinit, unitinit, endinit, formatinit, unitleninit, unitnuminit;
1635*c87b03e5Sespie   tree unitexp, formatexp, unitlenexp, unitnumexp;
1636*c87b03e5Sespie   static int mynumber = 0;
1637*c87b03e5Sespie 
1638*c87b03e5Sespie   if (f2c_icilist_struct == NULL_TREE)
1639*c87b03e5Sespie     {
1640*c87b03e5Sespie       tree ref;
1641*c87b03e5Sespie 
1642*c87b03e5Sespie       ref = make_node (RECORD_TYPE);
1643*c87b03e5Sespie 
1644*c87b03e5Sespie       errfield = ffecom_decl_field (ref, NULL_TREE, "err",
1645*c87b03e5Sespie 				    ffecom_f2c_flag_type_node);
1646*c87b03e5Sespie       unitfield = ffecom_decl_field (ref, errfield, "unit",
1647*c87b03e5Sespie 				     string_type_node);
1648*c87b03e5Sespie       endfield = ffecom_decl_field (ref, unitfield, "end",
1649*c87b03e5Sespie 				    ffecom_f2c_flag_type_node);
1650*c87b03e5Sespie       formatfield = ffecom_decl_field (ref, endfield, "format",
1651*c87b03e5Sespie 				       string_type_node);
1652*c87b03e5Sespie       unitlenfield = ffecom_decl_field (ref, formatfield, "unitlen",
1653*c87b03e5Sespie 					ffecom_f2c_ftnint_type_node);
1654*c87b03e5Sespie       unitnumfield = ffecom_decl_field (ref, unitlenfield, "unitnum",
1655*c87b03e5Sespie 					ffecom_f2c_ftnint_type_node);
1656*c87b03e5Sespie 
1657*c87b03e5Sespie       TYPE_FIELDS (ref) = errfield;
1658*c87b03e5Sespie       layout_type (ref);
1659*c87b03e5Sespie 
1660*c87b03e5Sespie       f2c_icilist_struct = ref;
1661*c87b03e5Sespie     }
1662*c87b03e5Sespie 
1663*c87b03e5Sespie   /* Try to do as much compile-time initialization of the structure
1664*c87b03e5Sespie      as possible, to save run time.  */
1665*c87b03e5Sespie 
1666*c87b03e5Sespie   ffeste_f2c_init_flag_ (have_err, errinit);
1667*c87b03e5Sespie 
1668*c87b03e5Sespie   unitexp = ffecom_arg_ptr_to_const_expr (unit_expr, &unitlenexp);
1669*c87b03e5Sespie   if (unitexp)
1670*c87b03e5Sespie     unitinit = unitexp;
1671*c87b03e5Sespie   else
1672*c87b03e5Sespie     {
1673*c87b03e5Sespie       unitinit = null_pointer_node;
1674*c87b03e5Sespie       constantp = FALSE;
1675*c87b03e5Sespie     }
1676*c87b03e5Sespie   if (unitlenexp)
1677*c87b03e5Sespie     unitleninit = unitlenexp;
1678*c87b03e5Sespie   else
1679*c87b03e5Sespie     {
1680*c87b03e5Sespie       unitleninit = ffecom_integer_zero_node;
1681*c87b03e5Sespie       constantp = FALSE;
1682*c87b03e5Sespie     }
1683*c87b03e5Sespie 
1684*c87b03e5Sespie   /* Now see if we can fully initialize the number of elements, or
1685*c87b03e5Sespie      if we have to compute that at run time.  */
1686*c87b03e5Sespie   if (ffeinfo_rank (ffebld_info (unit_expr)) == 0
1687*c87b03e5Sespie       || (unitexp
1688*c87b03e5Sespie 	  && TREE_CODE (TREE_TYPE (TREE_TYPE (unitexp))) != ARRAY_TYPE))
1689*c87b03e5Sespie     {
1690*c87b03e5Sespie       /* Not an array, so just one element.  */
1691*c87b03e5Sespie       unitnuminit = ffecom_integer_one_node;
1692*c87b03e5Sespie       unitnumexp = unitnuminit;
1693*c87b03e5Sespie     }
1694*c87b03e5Sespie   else if (unitexp && unitlenexp)
1695*c87b03e5Sespie     {
1696*c87b03e5Sespie       /* An array, but all the info is constant, so compute now.  */
1697*c87b03e5Sespie       unitnuminit
1698*c87b03e5Sespie 	= size_binop (CEIL_DIV_EXPR,
1699*c87b03e5Sespie 		      TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (unitexp))),
1700*c87b03e5Sespie 		      convert (sizetype, unitlenexp));
1701*c87b03e5Sespie       unitnuminit = size_binop (CEIL_DIV_EXPR, unitnuminit,
1702*c87b03e5Sespie 				size_int (TYPE_PRECISION (char_type_node)
1703*c87b03e5Sespie 					  / BITS_PER_UNIT));
1704*c87b03e5Sespie       unitnumexp = unitnuminit;
1705*c87b03e5Sespie     }
1706*c87b03e5Sespie   else
1707*c87b03e5Sespie     {
1708*c87b03e5Sespie       /* Put off computing until run time.  */
1709*c87b03e5Sespie       unitnuminit = ffecom_integer_zero_node;
1710*c87b03e5Sespie       unitnumexp = NULL_TREE;
1711*c87b03e5Sespie       constantp = FALSE;
1712*c87b03e5Sespie     }
1713*c87b03e5Sespie 
1714*c87b03e5Sespie   switch (format)
1715*c87b03e5Sespie     {
1716*c87b03e5Sespie     case FFESTV_formatNONE:
1717*c87b03e5Sespie       formatinit = null_pointer_node;
1718*c87b03e5Sespie       formatexp = formatinit;
1719*c87b03e5Sespie       break;
1720*c87b03e5Sespie 
1721*c87b03e5Sespie     case FFESTV_formatLABEL:
1722*c87b03e5Sespie       formatexp = error_mark_node;
1723*c87b03e5Sespie       formatinit = ffecom_lookup_label (format_spec->u.label);
1724*c87b03e5Sespie       if ((formatinit == NULL_TREE)
1725*c87b03e5Sespie 	  || (TREE_CODE (formatinit) == ERROR_MARK))
1726*c87b03e5Sespie 	break;
1727*c87b03e5Sespie       formatinit = ffecom_1 (ADDR_EXPR,
1728*c87b03e5Sespie 			     build_pointer_type (void_type_node),
1729*c87b03e5Sespie 			     formatinit);
1730*c87b03e5Sespie       TREE_CONSTANT (formatinit) = 1;
1731*c87b03e5Sespie       break;
1732*c87b03e5Sespie 
1733*c87b03e5Sespie     case FFESTV_formatCHAREXPR:
1734*c87b03e5Sespie       ffeste_f2c_init_format_ (formatexp, formatinit, format_spec);
1735*c87b03e5Sespie       break;
1736*c87b03e5Sespie 
1737*c87b03e5Sespie     case FFESTV_formatASTERISK:
1738*c87b03e5Sespie       formatinit = null_pointer_node;
1739*c87b03e5Sespie       formatexp = formatinit;
1740*c87b03e5Sespie       break;
1741*c87b03e5Sespie 
1742*c87b03e5Sespie     case FFESTV_formatINTEXPR:
1743*c87b03e5Sespie       formatinit = null_pointer_node;
1744*c87b03e5Sespie       formatexp = ffecom_expr_assign (format_spec->u.expr);
1745*c87b03e5Sespie       if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (formatexp)))
1746*c87b03e5Sespie 	  < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (null_pointer_node))))
1747*c87b03e5Sespie 	error ("ASSIGNed FORMAT specifier is too small");
1748*c87b03e5Sespie       formatexp = convert (string_type_node, formatexp);
1749*c87b03e5Sespie       break;
1750*c87b03e5Sespie 
1751*c87b03e5Sespie     default:
1752*c87b03e5Sespie       assert ("bad format spec" == NULL);
1753*c87b03e5Sespie       formatinit = ffecom_integer_zero_node;
1754*c87b03e5Sespie       formatexp = formatinit;
1755*c87b03e5Sespie       break;
1756*c87b03e5Sespie     }
1757*c87b03e5Sespie 
1758*c87b03e5Sespie   ffeste_f2c_init_flag_ (have_end, endinit);
1759*c87b03e5Sespie 
1760*c87b03e5Sespie   inits = build_tree_list ((field = TYPE_FIELDS (f2c_icilist_struct)),
1761*c87b03e5Sespie 			   errinit);
1762*c87b03e5Sespie   initn = inits;
1763*c87b03e5Sespie   ffeste_f2c_init_next_ (unitinit);
1764*c87b03e5Sespie   ffeste_f2c_init_next_ (endinit);
1765*c87b03e5Sespie   ffeste_f2c_init_next_ (formatinit);
1766*c87b03e5Sespie   ffeste_f2c_init_next_ (unitleninit);
1767*c87b03e5Sespie   ffeste_f2c_init_next_ (unitnuminit);
1768*c87b03e5Sespie 
1769*c87b03e5Sespie   inits = build (CONSTRUCTOR, f2c_icilist_struct, NULL_TREE, inits);
1770*c87b03e5Sespie   TREE_CONSTANT (inits) = constantp ? 1 : 0;
1771*c87b03e5Sespie   TREE_STATIC (inits) = 1;
1772*c87b03e5Sespie 
1773*c87b03e5Sespie   t = build_decl (VAR_DECL,
1774*c87b03e5Sespie 		  ffecom_get_invented_identifier ("__g77_icilist_%d",
1775*c87b03e5Sespie 						  mynumber++),
1776*c87b03e5Sespie 		  f2c_icilist_struct);
1777*c87b03e5Sespie   TREE_STATIC (t) = 1;
1778*c87b03e5Sespie   t = ffecom_start_decl (t, 1);
1779*c87b03e5Sespie   ffecom_finish_decl (t, inits, 0);
1780*c87b03e5Sespie 
1781*c87b03e5Sespie   /* Prepare run-time expressions.  */
1782*c87b03e5Sespie 
1783*c87b03e5Sespie   if (! unitexp)
1784*c87b03e5Sespie     ffecom_prepare_arg_ptr_to_expr (unit_expr);
1785*c87b03e5Sespie 
1786*c87b03e5Sespie   ffeste_f2c_prepare_format_ (format_spec, formatexp);
1787*c87b03e5Sespie 
1788*c87b03e5Sespie   ffecom_prepare_end ();
1789*c87b03e5Sespie 
1790*c87b03e5Sespie   /* Now evaluate run-time expressions as needed.  */
1791*c87b03e5Sespie 
1792*c87b03e5Sespie   if (! unitexp || ! unitlenexp)
1793*c87b03e5Sespie     {
1794*c87b03e5Sespie       int need_unitexp = (! unitexp);
1795*c87b03e5Sespie       int need_unitlenexp = (! unitlenexp);
1796*c87b03e5Sespie 
1797*c87b03e5Sespie       unitexp = ffecom_arg_ptr_to_expr (unit_expr, &unitlenexp);
1798*c87b03e5Sespie       if (need_unitexp)
1799*c87b03e5Sespie 	ffeste_f2c_compile_ (unitfield, unitexp);
1800*c87b03e5Sespie       if (need_unitlenexp)
1801*c87b03e5Sespie 	ffeste_f2c_compile_ (unitlenfield, unitlenexp);
1802*c87b03e5Sespie     }
1803*c87b03e5Sespie 
1804*c87b03e5Sespie   if (! unitnumexp
1805*c87b03e5Sespie       && unitexp != error_mark_node
1806*c87b03e5Sespie       && unitlenexp != error_mark_node)
1807*c87b03e5Sespie     {
1808*c87b03e5Sespie       unitnumexp
1809*c87b03e5Sespie 	= size_binop (CEIL_DIV_EXPR,
1810*c87b03e5Sespie 		      TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (unitexp))),
1811*c87b03e5Sespie 		      convert (sizetype, unitlenexp));
1812*c87b03e5Sespie       unitnumexp = size_binop (CEIL_DIV_EXPR, unitnumexp,
1813*c87b03e5Sespie 			       size_int (TYPE_PRECISION (char_type_node)
1814*c87b03e5Sespie 					 / BITS_PER_UNIT));
1815*c87b03e5Sespie       ffeste_f2c_compile_ (unitnumfield, unitnumexp);
1816*c87b03e5Sespie     }
1817*c87b03e5Sespie 
1818*c87b03e5Sespie   if (format == FFESTV_formatINTEXPR)
1819*c87b03e5Sespie     ffeste_f2c_compile_ (formatfield, formatexp);
1820*c87b03e5Sespie   else
1821*c87b03e5Sespie     ffeste_f2c_compile_format_ (formatfield, format_spec, formatexp);
1822*c87b03e5Sespie 
1823*c87b03e5Sespie   ttype = build_pointer_type (TREE_TYPE (t));
1824*c87b03e5Sespie   t = ffecom_1 (ADDR_EXPR, ttype, t);
1825*c87b03e5Sespie 
1826*c87b03e5Sespie   t = build_tree_list (NULL_TREE, t);
1827*c87b03e5Sespie 
1828*c87b03e5Sespie   return t;
1829*c87b03e5Sespie }
1830*c87b03e5Sespie 
1831*c87b03e5Sespie /* Make arglist with ptr to INQUIRE control list
1832*c87b03e5Sespie 
1833*c87b03e5Sespie    Returns a tree suitable as an argument list containing a pointer to
1834*c87b03e5Sespie    an INQUIRE-statement control list.  First, generates that control
1835*c87b03e5Sespie    list, if necessary, along with any static and run-time initializations
1836*c87b03e5Sespie    that are needed as specified by the arguments to this function.
1837*c87b03e5Sespie 
1838*c87b03e5Sespie    Must ensure that all expressions are prepared before being evaluated,
1839*c87b03e5Sespie    for any whose evaluation might result in the generation of temporaries.
1840*c87b03e5Sespie 
1841*c87b03e5Sespie    Note that this means this function causes a transition, within the
1842*c87b03e5Sespie    current block being code-generated via the back end, from the
1843*c87b03e5Sespie    declaration of variables (temporaries) to the expanding of expressions,
1844*c87b03e5Sespie    statements, etc.  */
1845*c87b03e5Sespie 
1846*c87b03e5Sespie static GTY(()) tree f2c_inquire_struct;
1847*c87b03e5Sespie static tree
ffeste_io_inlist_(bool have_err,ffestpFile * unit_spec,ffestpFile * file_spec,ffestpFile * exist_spec,ffestpFile * open_spec,ffestpFile * number_spec,ffestpFile * named_spec,ffestpFile * name_spec,ffestpFile * access_spec,ffestpFile * sequential_spec,ffestpFile * direct_spec,ffestpFile * form_spec,ffestpFile * formatted_spec,ffestpFile * unformatted_spec,ffestpFile * recl_spec,ffestpFile * nextrec_spec,ffestpFile * blank_spec)1848*c87b03e5Sespie ffeste_io_inlist_ (bool have_err,
1849*c87b03e5Sespie 		   ffestpFile *unit_spec,
1850*c87b03e5Sespie 		   ffestpFile *file_spec,
1851*c87b03e5Sespie 		   ffestpFile *exist_spec,
1852*c87b03e5Sespie 		   ffestpFile *open_spec,
1853*c87b03e5Sespie 		   ffestpFile *number_spec,
1854*c87b03e5Sespie 		   ffestpFile *named_spec,
1855*c87b03e5Sespie 		   ffestpFile *name_spec,
1856*c87b03e5Sespie 		   ffestpFile *access_spec,
1857*c87b03e5Sespie 		   ffestpFile *sequential_spec,
1858*c87b03e5Sespie 		   ffestpFile *direct_spec,
1859*c87b03e5Sespie 		   ffestpFile *form_spec,
1860*c87b03e5Sespie 		   ffestpFile *formatted_spec,
1861*c87b03e5Sespie 		   ffestpFile *unformatted_spec,
1862*c87b03e5Sespie 		   ffestpFile *recl_spec,
1863*c87b03e5Sespie 		   ffestpFile *nextrec_spec,
1864*c87b03e5Sespie 		   ffestpFile *blank_spec)
1865*c87b03e5Sespie {
1866*c87b03e5Sespie   tree t;
1867*c87b03e5Sespie   tree ttype;
1868*c87b03e5Sespie   tree field;
1869*c87b03e5Sespie   tree inits, initn;
1870*c87b03e5Sespie   bool constantp = TRUE;
1871*c87b03e5Sespie   static tree errfield, unitfield, filefield, filelenfield, existfield,
1872*c87b03e5Sespie     openfield, numberfield, namedfield, namefield, namelenfield, accessfield,
1873*c87b03e5Sespie     accesslenfield, sequentialfield, sequentiallenfield, directfield, directlenfield,
1874*c87b03e5Sespie     formfield, formlenfield, formattedfield, formattedlenfield, unformattedfield,
1875*c87b03e5Sespie     unformattedlenfield, reclfield, nextrecfield, blankfield, blanklenfield;
1876*c87b03e5Sespie   tree errinit, unitinit, fileinit, fileleninit, existinit, openinit, numberinit,
1877*c87b03e5Sespie     namedinit, nameinit, nameleninit, accessinit, accessleninit, sequentialinit,
1878*c87b03e5Sespie     sequentialleninit, directinit, directleninit, forminit, formleninit,
1879*c87b03e5Sespie     formattedinit, formattedleninit, unformattedinit, unformattedleninit,
1880*c87b03e5Sespie     reclinit, nextrecinit, blankinit, blankleninit;
1881*c87b03e5Sespie   tree
1882*c87b03e5Sespie     unitexp, fileexp, filelenexp, existexp, openexp, numberexp, namedexp,
1883*c87b03e5Sespie     nameexp, namelenexp, accessexp, accesslenexp, sequentialexp, sequentiallenexp,
1884*c87b03e5Sespie     directexp, directlenexp, formexp, formlenexp, formattedexp, formattedlenexp,
1885*c87b03e5Sespie     unformattedexp, unformattedlenexp, reclexp, nextrecexp, blankexp, blanklenexp;
1886*c87b03e5Sespie   static int mynumber = 0;
1887*c87b03e5Sespie 
1888*c87b03e5Sespie   if (f2c_inquire_struct == NULL_TREE)
1889*c87b03e5Sespie     {
1890*c87b03e5Sespie       tree ref;
1891*c87b03e5Sespie 
1892*c87b03e5Sespie       ref = make_node (RECORD_TYPE);
1893*c87b03e5Sespie 
1894*c87b03e5Sespie       errfield = ffecom_decl_field (ref, NULL_TREE, "err",
1895*c87b03e5Sespie 				    ffecom_f2c_flag_type_node);
1896*c87b03e5Sespie       unitfield = ffecom_decl_field (ref, errfield, "unit",
1897*c87b03e5Sespie 				     ffecom_f2c_ftnint_type_node);
1898*c87b03e5Sespie       filefield = ffecom_decl_field (ref, unitfield, "file",
1899*c87b03e5Sespie 				     string_type_node);
1900*c87b03e5Sespie       filelenfield = ffecom_decl_field (ref, filefield, "filelen",
1901*c87b03e5Sespie 					ffecom_f2c_ftnlen_type_node);
1902*c87b03e5Sespie       existfield = ffecom_decl_field (ref, filelenfield, "exist",
1903*c87b03e5Sespie 				      ffecom_f2c_ptr_to_ftnint_type_node);
1904*c87b03e5Sespie       openfield = ffecom_decl_field (ref, existfield, "open",
1905*c87b03e5Sespie 				     ffecom_f2c_ptr_to_ftnint_type_node);
1906*c87b03e5Sespie       numberfield = ffecom_decl_field (ref, openfield, "number",
1907*c87b03e5Sespie 				       ffecom_f2c_ptr_to_ftnint_type_node);
1908*c87b03e5Sespie       namedfield = ffecom_decl_field (ref, numberfield, "named",
1909*c87b03e5Sespie 				      ffecom_f2c_ptr_to_ftnint_type_node);
1910*c87b03e5Sespie       namefield = ffecom_decl_field (ref, namedfield, "name",
1911*c87b03e5Sespie 				     string_type_node);
1912*c87b03e5Sespie       namelenfield = ffecom_decl_field (ref, namefield, "namelen",
1913*c87b03e5Sespie 					ffecom_f2c_ftnlen_type_node);
1914*c87b03e5Sespie       accessfield = ffecom_decl_field (ref, namelenfield, "access",
1915*c87b03e5Sespie 				       string_type_node);
1916*c87b03e5Sespie       accesslenfield = ffecom_decl_field (ref, accessfield, "accesslen",
1917*c87b03e5Sespie 					  ffecom_f2c_ftnlen_type_node);
1918*c87b03e5Sespie       sequentialfield = ffecom_decl_field (ref, accesslenfield, "sequential",
1919*c87b03e5Sespie 					   string_type_node);
1920*c87b03e5Sespie       sequentiallenfield = ffecom_decl_field (ref, sequentialfield,
1921*c87b03e5Sespie 					      "sequentiallen",
1922*c87b03e5Sespie 					      ffecom_f2c_ftnlen_type_node);
1923*c87b03e5Sespie       directfield = ffecom_decl_field (ref, sequentiallenfield, "direct",
1924*c87b03e5Sespie 				       string_type_node);
1925*c87b03e5Sespie       directlenfield = ffecom_decl_field (ref, directfield, "directlen",
1926*c87b03e5Sespie 					  ffecom_f2c_ftnlen_type_node);
1927*c87b03e5Sespie       formfield = ffecom_decl_field (ref, directlenfield, "form",
1928*c87b03e5Sespie 				     string_type_node);
1929*c87b03e5Sespie       formlenfield = ffecom_decl_field (ref, formfield, "formlen",
1930*c87b03e5Sespie 					ffecom_f2c_ftnlen_type_node);
1931*c87b03e5Sespie       formattedfield = ffecom_decl_field (ref, formlenfield, "formatted",
1932*c87b03e5Sespie 					  string_type_node);
1933*c87b03e5Sespie       formattedlenfield = ffecom_decl_field (ref, formattedfield,
1934*c87b03e5Sespie 					     "formattedlen",
1935*c87b03e5Sespie 					     ffecom_f2c_ftnlen_type_node);
1936*c87b03e5Sespie       unformattedfield = ffecom_decl_field (ref, formattedlenfield,
1937*c87b03e5Sespie 					    "unformatted",
1938*c87b03e5Sespie 					    string_type_node);
1939*c87b03e5Sespie       unformattedlenfield = ffecom_decl_field (ref, unformattedfield,
1940*c87b03e5Sespie 					       "unformattedlen",
1941*c87b03e5Sespie 					       ffecom_f2c_ftnlen_type_node);
1942*c87b03e5Sespie       reclfield = ffecom_decl_field (ref, unformattedlenfield, "recl",
1943*c87b03e5Sespie 				     ffecom_f2c_ptr_to_ftnint_type_node);
1944*c87b03e5Sespie       nextrecfield = ffecom_decl_field (ref, reclfield, "nextrec",
1945*c87b03e5Sespie 					ffecom_f2c_ptr_to_ftnint_type_node);
1946*c87b03e5Sespie       blankfield = ffecom_decl_field (ref, nextrecfield, "blank",
1947*c87b03e5Sespie 				      string_type_node);
1948*c87b03e5Sespie       blanklenfield = ffecom_decl_field (ref, blankfield, "blanklen",
1949*c87b03e5Sespie 					 ffecom_f2c_ftnlen_type_node);
1950*c87b03e5Sespie 
1951*c87b03e5Sespie       TYPE_FIELDS (ref) = errfield;
1952*c87b03e5Sespie       layout_type (ref);
1953*c87b03e5Sespie 
1954*c87b03e5Sespie       f2c_inquire_struct = ref;
1955*c87b03e5Sespie     }
1956*c87b03e5Sespie 
1957*c87b03e5Sespie   /* Try to do as much compile-time initialization of the structure
1958*c87b03e5Sespie      as possible, to save run time.  */
1959*c87b03e5Sespie 
1960*c87b03e5Sespie   ffeste_f2c_init_flag_ (have_err, errinit);
1961*c87b03e5Sespie   ffeste_f2c_init_int_ (unitexp, unitinit, unit_spec);
1962*c87b03e5Sespie   ffeste_f2c_init_char_ (fileexp, fileinit, filelenexp, fileleninit,
1963*c87b03e5Sespie 			 file_spec);
1964*c87b03e5Sespie   ffeste_f2c_init_ptrtoint_ (existexp, existinit, exist_spec);
1965*c87b03e5Sespie   ffeste_f2c_init_ptrtoint_ (openexp, openinit, open_spec);
1966*c87b03e5Sespie   ffeste_f2c_init_ptrtoint_ (numberexp, numberinit, number_spec);
1967*c87b03e5Sespie   ffeste_f2c_init_ptrtoint_ (namedexp, namedinit, named_spec);
1968*c87b03e5Sespie   ffeste_f2c_init_char_ (nameexp, nameinit, namelenexp, nameleninit,
1969*c87b03e5Sespie 			 name_spec);
1970*c87b03e5Sespie   ffeste_f2c_init_char_ (accessexp, accessinit, accesslenexp,
1971*c87b03e5Sespie 			 accessleninit, access_spec);
1972*c87b03e5Sespie   ffeste_f2c_init_char_ (sequentialexp, sequentialinit, sequentiallenexp,
1973*c87b03e5Sespie 			 sequentialleninit, sequential_spec);
1974*c87b03e5Sespie   ffeste_f2c_init_char_ (directexp, directinit, directlenexp,
1975*c87b03e5Sespie 			 directleninit, direct_spec);
1976*c87b03e5Sespie   ffeste_f2c_init_char_ (formexp, forminit, formlenexp, formleninit,
1977*c87b03e5Sespie 			 form_spec);
1978*c87b03e5Sespie   ffeste_f2c_init_char_ (formattedexp, formattedinit,
1979*c87b03e5Sespie 			 formattedlenexp, formattedleninit, formatted_spec);
1980*c87b03e5Sespie   ffeste_f2c_init_char_ (unformattedexp, unformattedinit, unformattedlenexp,
1981*c87b03e5Sespie 			 unformattedleninit, unformatted_spec);
1982*c87b03e5Sespie   ffeste_f2c_init_ptrtoint_ (reclexp, reclinit, recl_spec);
1983*c87b03e5Sespie   ffeste_f2c_init_ptrtoint_ (nextrecexp, nextrecinit, nextrec_spec);
1984*c87b03e5Sespie   ffeste_f2c_init_char_ (blankexp, blankinit, blanklenexp,
1985*c87b03e5Sespie 			 blankleninit, blank_spec);
1986*c87b03e5Sespie 
1987*c87b03e5Sespie   inits = build_tree_list ((field = TYPE_FIELDS (f2c_inquire_struct)),
1988*c87b03e5Sespie 			   errinit);
1989*c87b03e5Sespie   initn = inits;
1990*c87b03e5Sespie   ffeste_f2c_init_next_ (unitinit);
1991*c87b03e5Sespie   ffeste_f2c_init_next_ (fileinit);
1992*c87b03e5Sespie   ffeste_f2c_init_next_ (fileleninit);
1993*c87b03e5Sespie   ffeste_f2c_init_next_ (existinit);
1994*c87b03e5Sespie   ffeste_f2c_init_next_ (openinit);
1995*c87b03e5Sespie   ffeste_f2c_init_next_ (numberinit);
1996*c87b03e5Sespie   ffeste_f2c_init_next_ (namedinit);
1997*c87b03e5Sespie   ffeste_f2c_init_next_ (nameinit);
1998*c87b03e5Sespie   ffeste_f2c_init_next_ (nameleninit);
1999*c87b03e5Sespie   ffeste_f2c_init_next_ (accessinit);
2000*c87b03e5Sespie   ffeste_f2c_init_next_ (accessleninit);
2001*c87b03e5Sespie   ffeste_f2c_init_next_ (sequentialinit);
2002*c87b03e5Sespie   ffeste_f2c_init_next_ (sequentialleninit);
2003*c87b03e5Sespie   ffeste_f2c_init_next_ (directinit);
2004*c87b03e5Sespie   ffeste_f2c_init_next_ (directleninit);
2005*c87b03e5Sespie   ffeste_f2c_init_next_ (forminit);
2006*c87b03e5Sespie   ffeste_f2c_init_next_ (formleninit);
2007*c87b03e5Sespie   ffeste_f2c_init_next_ (formattedinit);
2008*c87b03e5Sespie   ffeste_f2c_init_next_ (formattedleninit);
2009*c87b03e5Sespie   ffeste_f2c_init_next_ (unformattedinit);
2010*c87b03e5Sespie   ffeste_f2c_init_next_ (unformattedleninit);
2011*c87b03e5Sespie   ffeste_f2c_init_next_ (reclinit);
2012*c87b03e5Sespie   ffeste_f2c_init_next_ (nextrecinit);
2013*c87b03e5Sespie   ffeste_f2c_init_next_ (blankinit);
2014*c87b03e5Sespie   ffeste_f2c_init_next_ (blankleninit);
2015*c87b03e5Sespie 
2016*c87b03e5Sespie   inits = build (CONSTRUCTOR, f2c_inquire_struct, NULL_TREE, inits);
2017*c87b03e5Sespie   TREE_CONSTANT (inits) = constantp ? 1 : 0;
2018*c87b03e5Sespie   TREE_STATIC (inits) = 1;
2019*c87b03e5Sespie 
2020*c87b03e5Sespie   t = build_decl (VAR_DECL,
2021*c87b03e5Sespie 		  ffecom_get_invented_identifier ("__g77_inlist_%d",
2022*c87b03e5Sespie 						  mynumber++),
2023*c87b03e5Sespie 		  f2c_inquire_struct);
2024*c87b03e5Sespie   TREE_STATIC (t) = 1;
2025*c87b03e5Sespie   t = ffecom_start_decl (t, 1);
2026*c87b03e5Sespie   ffecom_finish_decl (t, inits, 0);
2027*c87b03e5Sespie 
2028*c87b03e5Sespie   /* Prepare run-time expressions.  */
2029*c87b03e5Sespie 
2030*c87b03e5Sespie   ffeste_f2c_prepare_int_ (unit_spec, unitexp);
2031*c87b03e5Sespie   ffeste_f2c_prepare_char_ (file_spec, fileexp);
2032*c87b03e5Sespie   ffeste_f2c_prepare_ptrtoint_ (exist_spec, existexp);
2033*c87b03e5Sespie   ffeste_f2c_prepare_ptrtoint_ (open_spec, openexp);
2034*c87b03e5Sespie   ffeste_f2c_prepare_ptrtoint_ (number_spec, numberexp);
2035*c87b03e5Sespie   ffeste_f2c_prepare_ptrtoint_ (named_spec, namedexp);
2036*c87b03e5Sespie   ffeste_f2c_prepare_char_ (name_spec, nameexp);
2037*c87b03e5Sespie   ffeste_f2c_prepare_char_ (access_spec, accessexp);
2038*c87b03e5Sespie   ffeste_f2c_prepare_char_ (sequential_spec, sequentialexp);
2039*c87b03e5Sespie   ffeste_f2c_prepare_char_ (direct_spec, directexp);
2040*c87b03e5Sespie   ffeste_f2c_prepare_char_ (form_spec, formexp);
2041*c87b03e5Sespie   ffeste_f2c_prepare_char_ (formatted_spec, formattedexp);
2042*c87b03e5Sespie   ffeste_f2c_prepare_char_ (unformatted_spec, unformattedexp);
2043*c87b03e5Sespie   ffeste_f2c_prepare_ptrtoint_ (recl_spec, reclexp);
2044*c87b03e5Sespie   ffeste_f2c_prepare_ptrtoint_ (nextrec_spec, nextrecexp);
2045*c87b03e5Sespie   ffeste_f2c_prepare_char_ (blank_spec, blankexp);
2046*c87b03e5Sespie 
2047*c87b03e5Sespie   ffecom_prepare_end ();
2048*c87b03e5Sespie 
2049*c87b03e5Sespie   /* Now evaluate run-time expressions as needed.  */
2050*c87b03e5Sespie 
2051*c87b03e5Sespie   ffeste_f2c_compile_int_ (unitfield, unit_spec, unitexp);
2052*c87b03e5Sespie   ffeste_f2c_compile_char_ (filefield, filelenfield, file_spec,
2053*c87b03e5Sespie 			    fileexp, filelenexp);
2054*c87b03e5Sespie   ffeste_f2c_compile_ptrtoint_ (existfield, exist_spec, existexp);
2055*c87b03e5Sespie   ffeste_f2c_compile_ptrtoint_ (openfield, open_spec, openexp);
2056*c87b03e5Sespie   ffeste_f2c_compile_ptrtoint_ (numberfield, number_spec, numberexp);
2057*c87b03e5Sespie   ffeste_f2c_compile_ptrtoint_ (namedfield, named_spec, namedexp);
2058*c87b03e5Sespie   ffeste_f2c_compile_char_ (namefield, namelenfield, name_spec, nameexp,
2059*c87b03e5Sespie 			    namelenexp);
2060*c87b03e5Sespie   ffeste_f2c_compile_char_ (accessfield, accesslenfield, access_spec,
2061*c87b03e5Sespie 			    accessexp, accesslenexp);
2062*c87b03e5Sespie   ffeste_f2c_compile_char_ (sequentialfield, sequentiallenfield,
2063*c87b03e5Sespie 			    sequential_spec, sequentialexp,
2064*c87b03e5Sespie 			    sequentiallenexp);
2065*c87b03e5Sespie   ffeste_f2c_compile_char_ (directfield, directlenfield, direct_spec,
2066*c87b03e5Sespie 			    directexp, directlenexp);
2067*c87b03e5Sespie   ffeste_f2c_compile_char_ (formfield, formlenfield, form_spec, formexp,
2068*c87b03e5Sespie 			    formlenexp);
2069*c87b03e5Sespie   ffeste_f2c_compile_char_ (formattedfield, formattedlenfield, formatted_spec,
2070*c87b03e5Sespie 			    formattedexp, formattedlenexp);
2071*c87b03e5Sespie   ffeste_f2c_compile_char_ (unformattedfield, unformattedlenfield,
2072*c87b03e5Sespie 			    unformatted_spec, unformattedexp,
2073*c87b03e5Sespie 			    unformattedlenexp);
2074*c87b03e5Sespie   ffeste_f2c_compile_ptrtoint_ (reclfield, recl_spec, reclexp);
2075*c87b03e5Sespie   ffeste_f2c_compile_ptrtoint_ (nextrecfield, nextrec_spec, nextrecexp);
2076*c87b03e5Sespie   ffeste_f2c_compile_char_ (blankfield, blanklenfield, blank_spec, blankexp,
2077*c87b03e5Sespie 			    blanklenexp);
2078*c87b03e5Sespie 
2079*c87b03e5Sespie   ttype = build_pointer_type (TREE_TYPE (t));
2080*c87b03e5Sespie   t = ffecom_1 (ADDR_EXPR, ttype, t);
2081*c87b03e5Sespie 
2082*c87b03e5Sespie   t = build_tree_list (NULL_TREE, t);
2083*c87b03e5Sespie 
2084*c87b03e5Sespie   return t;
2085*c87b03e5Sespie }
2086*c87b03e5Sespie 
2087*c87b03e5Sespie /* Make arglist with ptr to OPEN control list
2088*c87b03e5Sespie 
2089*c87b03e5Sespie    Returns a tree suitable as an argument list containing a pointer to
2090*c87b03e5Sespie    an OPEN-statement control list.  First, generates that control
2091*c87b03e5Sespie    list, if necessary, along with any static and run-time initializations
2092*c87b03e5Sespie    that are needed as specified by the arguments to this function.
2093*c87b03e5Sespie 
2094*c87b03e5Sespie    Must ensure that all expressions are prepared before being evaluated,
2095*c87b03e5Sespie    for any whose evaluation might result in the generation of temporaries.
2096*c87b03e5Sespie 
2097*c87b03e5Sespie    Note that this means this function causes a transition, within the
2098*c87b03e5Sespie    current block being code-generated via the back end, from the
2099*c87b03e5Sespie    declaration of variables (temporaries) to the expanding of expressions,
2100*c87b03e5Sespie    statements, etc.  */
2101*c87b03e5Sespie 
2102*c87b03e5Sespie static GTY(()) tree f2c_open_struct;
2103*c87b03e5Sespie static tree
ffeste_io_olist_(bool have_err,ffebld unit_expr,ffestpFile * file_spec,ffestpFile * stat_spec,ffestpFile * access_spec,ffestpFile * form_spec,ffestpFile * recl_spec,ffestpFile * blank_spec)2104*c87b03e5Sespie ffeste_io_olist_ (bool have_err,
2105*c87b03e5Sespie 		  ffebld unit_expr,
2106*c87b03e5Sespie 		  ffestpFile *file_spec,
2107*c87b03e5Sespie 		  ffestpFile *stat_spec,
2108*c87b03e5Sespie 		  ffestpFile *access_spec,
2109*c87b03e5Sespie 		  ffestpFile *form_spec,
2110*c87b03e5Sespie 		  ffestpFile *recl_spec,
2111*c87b03e5Sespie 		  ffestpFile *blank_spec)
2112*c87b03e5Sespie {
2113*c87b03e5Sespie   tree t;
2114*c87b03e5Sespie   tree ttype;
2115*c87b03e5Sespie   tree field;
2116*c87b03e5Sespie   tree inits, initn;
2117*c87b03e5Sespie   tree ignore;			/* Ignore length info for certain fields. */
2118*c87b03e5Sespie   bool constantp = TRUE;
2119*c87b03e5Sespie   static tree errfield, unitfield, filefield, filelenfield, statfield,
2120*c87b03e5Sespie     accessfield, formfield, reclfield, blankfield;
2121*c87b03e5Sespie   tree errinit, unitinit, fileinit, fileleninit, statinit, accessinit,
2122*c87b03e5Sespie     forminit, reclinit, blankinit;
2123*c87b03e5Sespie   tree
2124*c87b03e5Sespie     unitexp, fileexp, filelenexp, statexp, accessexp, formexp, reclexp,
2125*c87b03e5Sespie     blankexp;
2126*c87b03e5Sespie   static int mynumber = 0;
2127*c87b03e5Sespie 
2128*c87b03e5Sespie   if (f2c_open_struct == NULL_TREE)
2129*c87b03e5Sespie     {
2130*c87b03e5Sespie       tree ref;
2131*c87b03e5Sespie 
2132*c87b03e5Sespie       ref = make_node (RECORD_TYPE);
2133*c87b03e5Sespie 
2134*c87b03e5Sespie       errfield = ffecom_decl_field (ref, NULL_TREE, "err",
2135*c87b03e5Sespie 				    ffecom_f2c_flag_type_node);
2136*c87b03e5Sespie       unitfield = ffecom_decl_field (ref, errfield, "unit",
2137*c87b03e5Sespie 				     ffecom_f2c_ftnint_type_node);
2138*c87b03e5Sespie       filefield = ffecom_decl_field (ref, unitfield, "file",
2139*c87b03e5Sespie 				     string_type_node);
2140*c87b03e5Sespie       filelenfield = ffecom_decl_field (ref, filefield, "filelen",
2141*c87b03e5Sespie 					ffecom_f2c_ftnlen_type_node);
2142*c87b03e5Sespie       statfield = ffecom_decl_field (ref, filelenfield, "stat",
2143*c87b03e5Sespie 				     string_type_node);
2144*c87b03e5Sespie       accessfield = ffecom_decl_field (ref, statfield, "access",
2145*c87b03e5Sespie 				       string_type_node);
2146*c87b03e5Sespie       formfield = ffecom_decl_field (ref, accessfield, "form",
2147*c87b03e5Sespie 				     string_type_node);
2148*c87b03e5Sespie       reclfield = ffecom_decl_field (ref, formfield, "recl",
2149*c87b03e5Sespie 				     ffecom_f2c_ftnint_type_node);
2150*c87b03e5Sespie       blankfield = ffecom_decl_field (ref, reclfield, "blank",
2151*c87b03e5Sespie 				      string_type_node);
2152*c87b03e5Sespie 
2153*c87b03e5Sespie       TYPE_FIELDS (ref) = errfield;
2154*c87b03e5Sespie       layout_type (ref);
2155*c87b03e5Sespie 
2156*c87b03e5Sespie       f2c_open_struct = ref;
2157*c87b03e5Sespie     }
2158*c87b03e5Sespie 
2159*c87b03e5Sespie   /* Try to do as much compile-time initialization of the structure
2160*c87b03e5Sespie      as possible, to save run time.  */
2161*c87b03e5Sespie 
2162*c87b03e5Sespie   ffeste_f2c_init_flag_ (have_err, errinit);
2163*c87b03e5Sespie 
2164*c87b03e5Sespie   unitexp = ffecom_const_expr (unit_expr);
2165*c87b03e5Sespie   if (unitexp)
2166*c87b03e5Sespie     unitinit = unitexp;
2167*c87b03e5Sespie   else
2168*c87b03e5Sespie     {
2169*c87b03e5Sespie       unitinit = ffecom_integer_zero_node;
2170*c87b03e5Sespie       constantp = FALSE;
2171*c87b03e5Sespie     }
2172*c87b03e5Sespie 
2173*c87b03e5Sespie   ffeste_f2c_init_char_ (fileexp, fileinit, filelenexp, fileleninit,
2174*c87b03e5Sespie 			 file_spec);
2175*c87b03e5Sespie   ffeste_f2c_init_charnolen_ (statexp, statinit, stat_spec);
2176*c87b03e5Sespie   ffeste_f2c_init_charnolen_ (accessexp, accessinit, access_spec);
2177*c87b03e5Sespie   ffeste_f2c_init_charnolen_ (formexp, forminit, form_spec);
2178*c87b03e5Sespie   ffeste_f2c_init_int_ (reclexp, reclinit, recl_spec);
2179*c87b03e5Sespie   ffeste_f2c_init_charnolen_ (blankexp, blankinit, blank_spec);
2180*c87b03e5Sespie 
2181*c87b03e5Sespie   inits = build_tree_list ((field = TYPE_FIELDS (f2c_open_struct)), errinit);
2182*c87b03e5Sespie   initn = inits;
2183*c87b03e5Sespie   ffeste_f2c_init_next_ (unitinit);
2184*c87b03e5Sespie   ffeste_f2c_init_next_ (fileinit);
2185*c87b03e5Sespie   ffeste_f2c_init_next_ (fileleninit);
2186*c87b03e5Sespie   ffeste_f2c_init_next_ (statinit);
2187*c87b03e5Sespie   ffeste_f2c_init_next_ (accessinit);
2188*c87b03e5Sespie   ffeste_f2c_init_next_ (forminit);
2189*c87b03e5Sespie   ffeste_f2c_init_next_ (reclinit);
2190*c87b03e5Sespie   ffeste_f2c_init_next_ (blankinit);
2191*c87b03e5Sespie 
2192*c87b03e5Sespie   inits = build (CONSTRUCTOR, f2c_open_struct, NULL_TREE, inits);
2193*c87b03e5Sespie   TREE_CONSTANT (inits) = constantp ? 1 : 0;
2194*c87b03e5Sespie   TREE_STATIC (inits) = 1;
2195*c87b03e5Sespie 
2196*c87b03e5Sespie   t = build_decl (VAR_DECL,
2197*c87b03e5Sespie 		  ffecom_get_invented_identifier ("__g77_olist_%d",
2198*c87b03e5Sespie 						  mynumber++),
2199*c87b03e5Sespie 		  f2c_open_struct);
2200*c87b03e5Sespie   TREE_STATIC (t) = 1;
2201*c87b03e5Sespie   t = ffecom_start_decl (t, 1);
2202*c87b03e5Sespie   ffecom_finish_decl (t, inits, 0);
2203*c87b03e5Sespie 
2204*c87b03e5Sespie   /* Prepare run-time expressions.  */
2205*c87b03e5Sespie 
2206*c87b03e5Sespie   if (! unitexp)
2207*c87b03e5Sespie     ffecom_prepare_expr (unit_expr);
2208*c87b03e5Sespie 
2209*c87b03e5Sespie   ffeste_f2c_prepare_char_ (file_spec, fileexp);
2210*c87b03e5Sespie   ffeste_f2c_prepare_charnolen_ (stat_spec, statexp);
2211*c87b03e5Sespie   ffeste_f2c_prepare_charnolen_ (access_spec, accessexp);
2212*c87b03e5Sespie   ffeste_f2c_prepare_charnolen_ (form_spec, formexp);
2213*c87b03e5Sespie   ffeste_f2c_prepare_int_ (recl_spec, reclexp);
2214*c87b03e5Sespie   ffeste_f2c_prepare_charnolen_ (blank_spec, blankexp);
2215*c87b03e5Sespie 
2216*c87b03e5Sespie   ffecom_prepare_end ();
2217*c87b03e5Sespie 
2218*c87b03e5Sespie   /* Now evaluate run-time expressions as needed.  */
2219*c87b03e5Sespie 
2220*c87b03e5Sespie   if (! unitexp)
2221*c87b03e5Sespie     {
2222*c87b03e5Sespie       unitexp = ffecom_expr (unit_expr);
2223*c87b03e5Sespie       ffeste_f2c_compile_ (unitfield, unitexp);
2224*c87b03e5Sespie     }
2225*c87b03e5Sespie 
2226*c87b03e5Sespie   ffeste_f2c_compile_char_ (filefield, filelenfield, file_spec, fileexp,
2227*c87b03e5Sespie 			    filelenexp);
2228*c87b03e5Sespie   ffeste_f2c_compile_charnolen_ (statfield, stat_spec, statexp);
2229*c87b03e5Sespie   ffeste_f2c_compile_charnolen_ (accessfield, access_spec, accessexp);
2230*c87b03e5Sespie   ffeste_f2c_compile_charnolen_ (formfield, form_spec, formexp);
2231*c87b03e5Sespie   ffeste_f2c_compile_int_ (reclfield, recl_spec, reclexp);
2232*c87b03e5Sespie   ffeste_f2c_compile_charnolen_ (blankfield, blank_spec, blankexp);
2233*c87b03e5Sespie 
2234*c87b03e5Sespie   ttype = build_pointer_type (TREE_TYPE (t));
2235*c87b03e5Sespie   t = ffecom_1 (ADDR_EXPR, ttype, t);
2236*c87b03e5Sespie 
2237*c87b03e5Sespie   t = build_tree_list (NULL_TREE, t);
2238*c87b03e5Sespie 
2239*c87b03e5Sespie   return t;
2240*c87b03e5Sespie }
2241*c87b03e5Sespie 
2242*c87b03e5Sespie /* Generate code for BACKSPACE/ENDFILE/REWIND.  */
2243*c87b03e5Sespie 
2244*c87b03e5Sespie static void
ffeste_subr_beru_(ffestpBeruStmt * info,ffecomGfrt rt)2245*c87b03e5Sespie ffeste_subr_beru_ (ffestpBeruStmt *info, ffecomGfrt rt)
2246*c87b03e5Sespie {
2247*c87b03e5Sespie   tree alist;
2248*c87b03e5Sespie   bool iostat;
2249*c87b03e5Sespie   bool errl;
2250*c87b03e5Sespie 
2251*c87b03e5Sespie   ffeste_emit_line_note_ ();
2252*c87b03e5Sespie 
2253*c87b03e5Sespie #define specified(something) (info->beru_spec[something].kw_or_val_present)
2254*c87b03e5Sespie 
2255*c87b03e5Sespie   iostat = specified (FFESTP_beruixIOSTAT);
2256*c87b03e5Sespie   errl = specified (FFESTP_beruixERR);
2257*c87b03e5Sespie 
2258*c87b03e5Sespie #undef specified
2259*c87b03e5Sespie 
2260*c87b03e5Sespie   /* ~~For now, we assume the unit number is specified and is not ASTERISK,
2261*c87b03e5Sespie      because the FFE doesn't support BACKSPACE(*) and rejects a BACKSPACE
2262*c87b03e5Sespie      without any unit specifier.  f2c, however, supports the former
2263*c87b03e5Sespie      construct.	 When it is time to add this feature to the FFE, which
2264*c87b03e5Sespie      probably is fairly easy, ffestc_R919 and company will want to pass an
2265*c87b03e5Sespie      ffestvUnit indicator of FFESTV_unitINTEXPR or _unitASTERISK to
2266*c87b03e5Sespie      ffeste_R919 and company, and they will want to pass that same value to
2267*c87b03e5Sespie      this function, and that argument will replace the constant _unitINTEXPR_
2268*c87b03e5Sespie      in the call below.	 Right now, the default unit number, 6, is ignored.  */
2269*c87b03e5Sespie 
2270*c87b03e5Sespie   ffeste_start_stmt_ ();
2271*c87b03e5Sespie 
2272*c87b03e5Sespie   if (errl)
2273*c87b03e5Sespie     {
2274*c87b03e5Sespie       /* Have ERR= specification.   */
2275*c87b03e5Sespie 
2276*c87b03e5Sespie       ffeste_io_err_
2277*c87b03e5Sespie 	= ffeste_io_abort_
2278*c87b03e5Sespie 	= ffecom_lookup_label
2279*c87b03e5Sespie 	(info->beru_spec[FFESTP_beruixERR].u.label);
2280*c87b03e5Sespie       ffeste_io_abort_is_temp_ = FALSE;
2281*c87b03e5Sespie     }
2282*c87b03e5Sespie   else
2283*c87b03e5Sespie     {
2284*c87b03e5Sespie       /* No ERR= specification.  */
2285*c87b03e5Sespie 
2286*c87b03e5Sespie       ffeste_io_err_ = NULL_TREE;
2287*c87b03e5Sespie 
2288*c87b03e5Sespie       if ((ffeste_io_abort_is_temp_ = iostat))
2289*c87b03e5Sespie 	ffeste_io_abort_ = ffecom_temp_label ();
2290*c87b03e5Sespie       else
2291*c87b03e5Sespie 	ffeste_io_abort_ = NULL_TREE;
2292*c87b03e5Sespie     }
2293*c87b03e5Sespie 
2294*c87b03e5Sespie   if (iostat)
2295*c87b03e5Sespie     {
2296*c87b03e5Sespie       /* Have IOSTAT= specification.  */
2297*c87b03e5Sespie 
2298*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
2299*c87b03e5Sespie       ffeste_io_iostat_ = ffecom_expr
2300*c87b03e5Sespie 	(info->beru_spec[FFESTP_beruixIOSTAT].u.expr);
2301*c87b03e5Sespie     }
2302*c87b03e5Sespie   else if (ffeste_io_abort_ != NULL_TREE)
2303*c87b03e5Sespie     {
2304*c87b03e5Sespie       /* Have no IOSTAT= but have ERR=.  */
2305*c87b03e5Sespie 
2306*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = TRUE;
2307*c87b03e5Sespie       ffeste_io_iostat_
2308*c87b03e5Sespie 	= ffecom_make_tempvar ("beru", ffecom_integer_type_node,
2309*c87b03e5Sespie 			       FFETARGET_charactersizeNONE, -1);
2310*c87b03e5Sespie     }
2311*c87b03e5Sespie   else
2312*c87b03e5Sespie     {
2313*c87b03e5Sespie       /* No IOSTAT= or ERR= specification.  */
2314*c87b03e5Sespie 
2315*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
2316*c87b03e5Sespie       ffeste_io_iostat_ = NULL_TREE;
2317*c87b03e5Sespie     }
2318*c87b03e5Sespie 
2319*c87b03e5Sespie   /* Now prescan, then convert, all the arguments.  */
2320*c87b03e5Sespie 
2321*c87b03e5Sespie   alist = ffeste_io_ialist_ (errl || iostat, FFESTV_unitINTEXPR,
2322*c87b03e5Sespie 			     info->beru_spec[FFESTP_beruixUNIT].u.expr, 6);
2323*c87b03e5Sespie 
2324*c87b03e5Sespie   /* Don't generate "if (iostat != 0) goto label;" if label is temp abort
2325*c87b03e5Sespie      label, since we're gonna fall through to there anyway. */
2326*c87b03e5Sespie 
2327*c87b03e5Sespie   ffeste_io_call_ (ffecom_call_gfrt (rt, alist, NULL_TREE),
2328*c87b03e5Sespie 		   ! ffeste_io_abort_is_temp_);
2329*c87b03e5Sespie 
2330*c87b03e5Sespie   /* If we've got a temp label, generate its code here. */
2331*c87b03e5Sespie 
2332*c87b03e5Sespie   if (ffeste_io_abort_is_temp_)
2333*c87b03e5Sespie     {
2334*c87b03e5Sespie       DECL_INITIAL (ffeste_io_abort_) = error_mark_node;
2335*c87b03e5Sespie       emit_nop ();
2336*c87b03e5Sespie       expand_label (ffeste_io_abort_);
2337*c87b03e5Sespie 
2338*c87b03e5Sespie       assert (ffeste_io_err_ == NULL_TREE);
2339*c87b03e5Sespie     }
2340*c87b03e5Sespie 
2341*c87b03e5Sespie   ffeste_end_stmt_ ();
2342*c87b03e5Sespie }
2343*c87b03e5Sespie 
2344*c87b03e5Sespie /* END DO statement
2345*c87b03e5Sespie 
2346*c87b03e5Sespie    Also invoked by _labeldef_branch_finish_ (or, in cases
2347*c87b03e5Sespie    of errors, other _labeldef_ functions) when the label definition is
2348*c87b03e5Sespie    for a DO-target (LOOPEND) label, once per matching/outstanding DO
2349*c87b03e5Sespie    block on the stack.  */
2350*c87b03e5Sespie 
2351*c87b03e5Sespie void
ffeste_do(ffestw block)2352*c87b03e5Sespie ffeste_do (ffestw block)
2353*c87b03e5Sespie {
2354*c87b03e5Sespie   ffeste_emit_line_note_ ();
2355*c87b03e5Sespie 
2356*c87b03e5Sespie   if (ffestw_do_tvar (block) == 0)
2357*c87b03e5Sespie     {
2358*c87b03e5Sespie       expand_end_loop ();		/* DO WHILE and just DO. */
2359*c87b03e5Sespie 
2360*c87b03e5Sespie       ffeste_end_block_ (block);
2361*c87b03e5Sespie     }
2362*c87b03e5Sespie   else
2363*c87b03e5Sespie     ffeste_end_iterdo_ (block,
2364*c87b03e5Sespie 			ffestw_do_tvar (block),
2365*c87b03e5Sespie 			ffestw_do_incr_saved (block),
2366*c87b03e5Sespie 			ffestw_do_count_var (block));
2367*c87b03e5Sespie }
2368*c87b03e5Sespie 
2369*c87b03e5Sespie /* End of statement following logical IF.
2370*c87b03e5Sespie 
2371*c87b03e5Sespie    Applies to *only* logical IF, not to IF-THEN.  */
2372*c87b03e5Sespie 
2373*c87b03e5Sespie void
ffeste_end_R807()2374*c87b03e5Sespie ffeste_end_R807 ()
2375*c87b03e5Sespie {
2376*c87b03e5Sespie   ffeste_emit_line_note_ ();
2377*c87b03e5Sespie 
2378*c87b03e5Sespie   expand_end_cond ();
2379*c87b03e5Sespie 
2380*c87b03e5Sespie   ffeste_end_block_ (NULL);
2381*c87b03e5Sespie }
2382*c87b03e5Sespie 
2383*c87b03e5Sespie /* Generate "code" for branch label definition.  */
2384*c87b03e5Sespie 
2385*c87b03e5Sespie void
ffeste_labeldef_branch(ffelab label)2386*c87b03e5Sespie ffeste_labeldef_branch (ffelab label)
2387*c87b03e5Sespie {
2388*c87b03e5Sespie   tree glabel;
2389*c87b03e5Sespie 
2390*c87b03e5Sespie   glabel = ffecom_lookup_label (label);
2391*c87b03e5Sespie   assert (glabel != NULL_TREE);
2392*c87b03e5Sespie   if (TREE_CODE (glabel) == ERROR_MARK)
2393*c87b03e5Sespie     return;
2394*c87b03e5Sespie 
2395*c87b03e5Sespie   assert (DECL_INITIAL (glabel) == NULL_TREE);
2396*c87b03e5Sespie 
2397*c87b03e5Sespie   DECL_INITIAL (glabel) = error_mark_node;
2398*c87b03e5Sespie   DECL_SOURCE_FILE (glabel) = ffelab_definition_filename (label);
2399*c87b03e5Sespie   DECL_SOURCE_LINE (glabel) = ffelab_definition_filelinenum (label);
2400*c87b03e5Sespie 
2401*c87b03e5Sespie   emit_nop ();
2402*c87b03e5Sespie 
2403*c87b03e5Sespie   expand_label (glabel);
2404*c87b03e5Sespie }
2405*c87b03e5Sespie 
2406*c87b03e5Sespie /* Generate "code" for FORMAT label definition.  */
2407*c87b03e5Sespie 
2408*c87b03e5Sespie void
ffeste_labeldef_format(ffelab label)2409*c87b03e5Sespie ffeste_labeldef_format (ffelab label)
2410*c87b03e5Sespie {
2411*c87b03e5Sespie   ffeste_label_formatdef_ = label;
2412*c87b03e5Sespie }
2413*c87b03e5Sespie 
2414*c87b03e5Sespie /* Assignment statement (outside of WHERE).  */
2415*c87b03e5Sespie 
2416*c87b03e5Sespie void
ffeste_R737A(ffebld dest,ffebld source)2417*c87b03e5Sespie ffeste_R737A (ffebld dest, ffebld source)
2418*c87b03e5Sespie {
2419*c87b03e5Sespie   ffeste_check_simple_ ();
2420*c87b03e5Sespie 
2421*c87b03e5Sespie   ffeste_emit_line_note_ ();
2422*c87b03e5Sespie 
2423*c87b03e5Sespie   ffeste_start_stmt_ ();
2424*c87b03e5Sespie 
2425*c87b03e5Sespie   ffecom_expand_let_stmt (dest, source);
2426*c87b03e5Sespie 
2427*c87b03e5Sespie   ffeste_end_stmt_ ();
2428*c87b03e5Sespie }
2429*c87b03e5Sespie 
2430*c87b03e5Sespie /* Block IF (IF-THEN) statement.  */
2431*c87b03e5Sespie 
2432*c87b03e5Sespie void
ffeste_R803(ffestw block,ffebld expr)2433*c87b03e5Sespie ffeste_R803 (ffestw block, ffebld expr)
2434*c87b03e5Sespie {
2435*c87b03e5Sespie   tree temp;
2436*c87b03e5Sespie 
2437*c87b03e5Sespie   ffeste_check_simple_ ();
2438*c87b03e5Sespie 
2439*c87b03e5Sespie   ffeste_emit_line_note_ ();
2440*c87b03e5Sespie 
2441*c87b03e5Sespie   ffeste_start_block_ (block);
2442*c87b03e5Sespie 
2443*c87b03e5Sespie   temp = ffecom_make_tempvar ("ifthen", integer_type_node,
2444*c87b03e5Sespie 			      FFETARGET_charactersizeNONE, -1);
2445*c87b03e5Sespie 
2446*c87b03e5Sespie   ffeste_start_stmt_ ();
2447*c87b03e5Sespie 
2448*c87b03e5Sespie   ffecom_prepare_expr (expr);
2449*c87b03e5Sespie 
2450*c87b03e5Sespie   if (ffecom_prepare_end ())
2451*c87b03e5Sespie     {
2452*c87b03e5Sespie       tree result;
2453*c87b03e5Sespie 
2454*c87b03e5Sespie       result = ffecom_modify (void_type_node,
2455*c87b03e5Sespie 			      temp,
2456*c87b03e5Sespie 			      ffecom_truth_value (ffecom_expr (expr)));
2457*c87b03e5Sespie 
2458*c87b03e5Sespie       expand_expr_stmt (result);
2459*c87b03e5Sespie 
2460*c87b03e5Sespie       ffeste_end_stmt_ ();
2461*c87b03e5Sespie     }
2462*c87b03e5Sespie   else
2463*c87b03e5Sespie     {
2464*c87b03e5Sespie       ffeste_end_stmt_ ();
2465*c87b03e5Sespie 
2466*c87b03e5Sespie       temp = ffecom_truth_value (ffecom_expr (expr));
2467*c87b03e5Sespie     }
2468*c87b03e5Sespie 
2469*c87b03e5Sespie   expand_start_cond (temp, 0);
2470*c87b03e5Sespie 
2471*c87b03e5Sespie   /* No fake `else' constructs introduced (yet).  */
2472*c87b03e5Sespie   ffestw_set_ifthen_fake_else (block, 0);
2473*c87b03e5Sespie }
2474*c87b03e5Sespie 
2475*c87b03e5Sespie /* ELSE IF statement.  */
2476*c87b03e5Sespie 
2477*c87b03e5Sespie void
ffeste_R804(ffestw block,ffebld expr)2478*c87b03e5Sespie ffeste_R804 (ffestw block, ffebld expr)
2479*c87b03e5Sespie {
2480*c87b03e5Sespie   tree temp;
2481*c87b03e5Sespie 
2482*c87b03e5Sespie   ffeste_check_simple_ ();
2483*c87b03e5Sespie 
2484*c87b03e5Sespie   ffeste_emit_line_note_ ();
2485*c87b03e5Sespie 
2486*c87b03e5Sespie   /* Since ELSEIF(expr) might require preparations for expr,
2487*c87b03e5Sespie      implement as ELSE; prepare-expr; IF (expr) THEN ...; ENDIF.  */
2488*c87b03e5Sespie 
2489*c87b03e5Sespie   expand_start_else ();
2490*c87b03e5Sespie 
2491*c87b03e5Sespie   ffeste_start_block_ (block);
2492*c87b03e5Sespie 
2493*c87b03e5Sespie   temp = ffecom_make_tempvar ("elseif", integer_type_node,
2494*c87b03e5Sespie 			      FFETARGET_charactersizeNONE, -1);
2495*c87b03e5Sespie 
2496*c87b03e5Sespie   ffeste_start_stmt_ ();
2497*c87b03e5Sespie 
2498*c87b03e5Sespie   ffecom_prepare_expr (expr);
2499*c87b03e5Sespie 
2500*c87b03e5Sespie   if (ffecom_prepare_end ())
2501*c87b03e5Sespie     {
2502*c87b03e5Sespie       tree result;
2503*c87b03e5Sespie 
2504*c87b03e5Sespie       result = ffecom_modify (void_type_node,
2505*c87b03e5Sespie 			      temp,
2506*c87b03e5Sespie 			      ffecom_truth_value (ffecom_expr (expr)));
2507*c87b03e5Sespie 
2508*c87b03e5Sespie       expand_expr_stmt (result);
2509*c87b03e5Sespie 
2510*c87b03e5Sespie       ffeste_end_stmt_ ();
2511*c87b03e5Sespie     }
2512*c87b03e5Sespie   else
2513*c87b03e5Sespie     {
2514*c87b03e5Sespie       /* In this case, we could probably have used expand_start_elseif
2515*c87b03e5Sespie 	 instead, saving the need for a fake `else' construct.  But,
2516*c87b03e5Sespie 	 until it's clear that'd improve performance, it's easier this
2517*c87b03e5Sespie 	 way, since we have to expand_start_else before we get to this
2518*c87b03e5Sespie 	 test, given the current design.  */
2519*c87b03e5Sespie 
2520*c87b03e5Sespie       ffeste_end_stmt_ ();
2521*c87b03e5Sespie 
2522*c87b03e5Sespie       temp = ffecom_truth_value (ffecom_expr (expr));
2523*c87b03e5Sespie     }
2524*c87b03e5Sespie 
2525*c87b03e5Sespie   expand_start_cond (temp, 0);
2526*c87b03e5Sespie 
2527*c87b03e5Sespie   /* Increment number of fake `else' constructs introduced.  */
2528*c87b03e5Sespie   ffestw_set_ifthen_fake_else (block,
2529*c87b03e5Sespie 			       ffestw_ifthen_fake_else (block) + 1);
2530*c87b03e5Sespie }
2531*c87b03e5Sespie 
2532*c87b03e5Sespie /* ELSE statement.  */
2533*c87b03e5Sespie 
2534*c87b03e5Sespie void
ffeste_R805(ffestw block UNUSED)2535*c87b03e5Sespie ffeste_R805 (ffestw block UNUSED)
2536*c87b03e5Sespie {
2537*c87b03e5Sespie   ffeste_check_simple_ ();
2538*c87b03e5Sespie 
2539*c87b03e5Sespie   ffeste_emit_line_note_ ();
2540*c87b03e5Sespie 
2541*c87b03e5Sespie   expand_start_else ();
2542*c87b03e5Sespie }
2543*c87b03e5Sespie 
2544*c87b03e5Sespie /* END IF statement.  */
2545*c87b03e5Sespie 
2546*c87b03e5Sespie void
ffeste_R806(ffestw block)2547*c87b03e5Sespie ffeste_R806 (ffestw block)
2548*c87b03e5Sespie {
2549*c87b03e5Sespie   int i = ffestw_ifthen_fake_else (block) + 1;
2550*c87b03e5Sespie 
2551*c87b03e5Sespie   ffeste_emit_line_note_ ();
2552*c87b03e5Sespie 
2553*c87b03e5Sespie   for (; i; --i)
2554*c87b03e5Sespie     {
2555*c87b03e5Sespie       expand_end_cond ();
2556*c87b03e5Sespie 
2557*c87b03e5Sespie       ffeste_end_block_ (block);
2558*c87b03e5Sespie     }
2559*c87b03e5Sespie }
2560*c87b03e5Sespie 
2561*c87b03e5Sespie /* Logical IF statement.  */
2562*c87b03e5Sespie 
2563*c87b03e5Sespie void
ffeste_R807(ffebld expr)2564*c87b03e5Sespie ffeste_R807 (ffebld expr)
2565*c87b03e5Sespie {
2566*c87b03e5Sespie   tree temp;
2567*c87b03e5Sespie 
2568*c87b03e5Sespie   ffeste_check_simple_ ();
2569*c87b03e5Sespie 
2570*c87b03e5Sespie   ffeste_emit_line_note_ ();
2571*c87b03e5Sespie 
2572*c87b03e5Sespie   ffeste_start_block_ (NULL);
2573*c87b03e5Sespie 
2574*c87b03e5Sespie   temp = ffecom_make_tempvar ("if", integer_type_node,
2575*c87b03e5Sespie 			      FFETARGET_charactersizeNONE, -1);
2576*c87b03e5Sespie 
2577*c87b03e5Sespie   ffeste_start_stmt_ ();
2578*c87b03e5Sespie 
2579*c87b03e5Sespie   ffecom_prepare_expr (expr);
2580*c87b03e5Sespie 
2581*c87b03e5Sespie   if (ffecom_prepare_end ())
2582*c87b03e5Sespie     {
2583*c87b03e5Sespie       tree result;
2584*c87b03e5Sespie 
2585*c87b03e5Sespie       result = ffecom_modify (void_type_node,
2586*c87b03e5Sespie 			      temp,
2587*c87b03e5Sespie 			      ffecom_truth_value (ffecom_expr (expr)));
2588*c87b03e5Sespie 
2589*c87b03e5Sespie       expand_expr_stmt (result);
2590*c87b03e5Sespie 
2591*c87b03e5Sespie       ffeste_end_stmt_ ();
2592*c87b03e5Sespie     }
2593*c87b03e5Sespie   else
2594*c87b03e5Sespie     {
2595*c87b03e5Sespie       ffeste_end_stmt_ ();
2596*c87b03e5Sespie 
2597*c87b03e5Sespie       temp = ffecom_truth_value (ffecom_expr (expr));
2598*c87b03e5Sespie     }
2599*c87b03e5Sespie 
2600*c87b03e5Sespie   expand_start_cond (temp, 0);
2601*c87b03e5Sespie }
2602*c87b03e5Sespie 
2603*c87b03e5Sespie /* SELECT CASE statement.  */
2604*c87b03e5Sespie 
2605*c87b03e5Sespie void
ffeste_R809(ffestw block,ffebld expr)2606*c87b03e5Sespie ffeste_R809 (ffestw block, ffebld expr)
2607*c87b03e5Sespie {
2608*c87b03e5Sespie   ffeste_check_simple_ ();
2609*c87b03e5Sespie 
2610*c87b03e5Sespie   ffeste_emit_line_note_ ();
2611*c87b03e5Sespie 
2612*c87b03e5Sespie   ffeste_start_block_ (block);
2613*c87b03e5Sespie 
2614*c87b03e5Sespie   if ((expr == NULL)
2615*c87b03e5Sespie       || (ffeinfo_basictype (ffebld_info (expr))
2616*c87b03e5Sespie 	  == FFEINFO_basictypeANY))
2617*c87b03e5Sespie     ffestw_set_select_texpr (block, error_mark_node);
2618*c87b03e5Sespie   else if (ffeinfo_basictype (ffebld_info (expr))
2619*c87b03e5Sespie 	   == FFEINFO_basictypeCHARACTER)
2620*c87b03e5Sespie     {
2621*c87b03e5Sespie       /* ~~~Someday handle CHARACTER*1, CHARACTER*N */
2622*c87b03e5Sespie 
2623*c87b03e5Sespie       /* xgettext:no-c-format */
2624*c87b03e5Sespie       ffebad_start_msg ("SELECT CASE on CHARACTER type (at %0) not supported -- sorry",
2625*c87b03e5Sespie 			FFEBAD_severityFATAL);
2626*c87b03e5Sespie       ffebad_here (0, ffestw_line (block), ffestw_col (block));
2627*c87b03e5Sespie       ffebad_finish ();
2628*c87b03e5Sespie       ffestw_set_select_texpr (block, error_mark_node);
2629*c87b03e5Sespie     }
2630*c87b03e5Sespie   else
2631*c87b03e5Sespie     {
2632*c87b03e5Sespie       tree result;
2633*c87b03e5Sespie       tree texpr;
2634*c87b03e5Sespie 
2635*c87b03e5Sespie       result = ffecom_make_tempvar ("select", ffecom_type_expr (expr),
2636*c87b03e5Sespie 				    ffeinfo_size (ffebld_info (expr)),
2637*c87b03e5Sespie 				    -1);
2638*c87b03e5Sespie 
2639*c87b03e5Sespie       ffeste_start_stmt_ ();
2640*c87b03e5Sespie 
2641*c87b03e5Sespie       ffecom_prepare_expr (expr);
2642*c87b03e5Sespie 
2643*c87b03e5Sespie       ffecom_prepare_end ();
2644*c87b03e5Sespie 
2645*c87b03e5Sespie       texpr = ffecom_expr (expr);
2646*c87b03e5Sespie 
2647*c87b03e5Sespie       assert (TYPE_MAIN_VARIANT (TREE_TYPE (texpr))
2648*c87b03e5Sespie 	      == TYPE_MAIN_VARIANT (TREE_TYPE (result)));
2649*c87b03e5Sespie 
2650*c87b03e5Sespie       texpr = ffecom_modify (void_type_node,
2651*c87b03e5Sespie 			     result,
2652*c87b03e5Sespie 			     texpr);
2653*c87b03e5Sespie       expand_expr_stmt (texpr);
2654*c87b03e5Sespie 
2655*c87b03e5Sespie       ffeste_end_stmt_ ();
2656*c87b03e5Sespie 
2657*c87b03e5Sespie       expand_start_case (1, result, TREE_TYPE (result),
2658*c87b03e5Sespie 			 "SELECT CASE statement");
2659*c87b03e5Sespie       ffestw_set_select_texpr (block, texpr);
2660*c87b03e5Sespie       ffestw_set_select_break (block, FALSE);
2661*c87b03e5Sespie     }
2662*c87b03e5Sespie }
2663*c87b03e5Sespie 
2664*c87b03e5Sespie /* CASE statement.
2665*c87b03e5Sespie 
2666*c87b03e5Sespie    If casenum is 0, it's CASE DEFAULT.	Else it's the case ranges at
2667*c87b03e5Sespie    the start of the first_stmt list in the select object at the top of
2668*c87b03e5Sespie    the stack that match casenum.  */
2669*c87b03e5Sespie 
2670*c87b03e5Sespie void
ffeste_R810(ffestw block,unsigned long casenum)2671*c87b03e5Sespie ffeste_R810 (ffestw block, unsigned long casenum)
2672*c87b03e5Sespie {
2673*c87b03e5Sespie   ffestwSelect s = ffestw_select (block);
2674*c87b03e5Sespie   ffestwCase c;
2675*c87b03e5Sespie   tree texprlow;
2676*c87b03e5Sespie   tree texprhigh;
2677*c87b03e5Sespie   tree tlabel;
2678*c87b03e5Sespie   int pushok;
2679*c87b03e5Sespie   tree duplicate;
2680*c87b03e5Sespie 
2681*c87b03e5Sespie   ffeste_check_simple_ ();
2682*c87b03e5Sespie 
2683*c87b03e5Sespie   if (s->first_stmt == (ffestwCase) &s->first_rel)
2684*c87b03e5Sespie     c = NULL;
2685*c87b03e5Sespie   else
2686*c87b03e5Sespie     c = s->first_stmt;
2687*c87b03e5Sespie 
2688*c87b03e5Sespie   ffeste_emit_line_note_ ();
2689*c87b03e5Sespie 
2690*c87b03e5Sespie   if (ffestw_select_texpr (block) == error_mark_node)
2691*c87b03e5Sespie     return;
2692*c87b03e5Sespie 
2693*c87b03e5Sespie   /* ~~~Someday handle CHARACTER*1, CHARACTER*N */
2694*c87b03e5Sespie 
2695*c87b03e5Sespie   tlabel = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2696*c87b03e5Sespie 
2697*c87b03e5Sespie   if (ffestw_select_break (block))
2698*c87b03e5Sespie     expand_exit_something ();
2699*c87b03e5Sespie   else
2700*c87b03e5Sespie     ffestw_set_select_break (block, TRUE);
2701*c87b03e5Sespie 
2702*c87b03e5Sespie   if ((c == NULL) || (casenum != c->casenum))
2703*c87b03e5Sespie     {
2704*c87b03e5Sespie       if (casenum == 0)	/* Intentional CASE DEFAULT. */
2705*c87b03e5Sespie 	{
2706*c87b03e5Sespie 	  pushok = pushcase (NULL_TREE, 0, tlabel, &duplicate);
2707*c87b03e5Sespie 	  assert (pushok == 0);
2708*c87b03e5Sespie 	}
2709*c87b03e5Sespie     }
2710*c87b03e5Sespie   else
2711*c87b03e5Sespie     do
2712*c87b03e5Sespie       {
2713*c87b03e5Sespie 	texprlow = (c->low == NULL) ? NULL_TREE
2714*c87b03e5Sespie 	  : ffecom_constantunion_with_type (&ffebld_constant_union (c->low),
2715*c87b03e5Sespie 				  ffecom_tree_type[s->type][s->kindtype], c->low->consttype);
2716*c87b03e5Sespie 	if (c->low != c->high)
2717*c87b03e5Sespie 	  {
2718*c87b03e5Sespie 	    texprhigh = (c->high == NULL) ? NULL_TREE
2719*c87b03e5Sespie 	      : ffecom_constantunion_with_type (&ffebld_constant_union (c->high),
2720*c87b03e5Sespie 				      ffecom_tree_type[s->type][s->kindtype], c->high->consttype);
2721*c87b03e5Sespie 	    pushok = pushcase_range (texprlow, texprhigh, convert,
2722*c87b03e5Sespie 				     tlabel, &duplicate);
2723*c87b03e5Sespie 	  }
2724*c87b03e5Sespie 	else
2725*c87b03e5Sespie 	  pushok = pushcase (texprlow, convert, tlabel, &duplicate);
2726*c87b03e5Sespie 	assert((pushok !=2) || (pushok !=0));
2727*c87b03e5Sespie 	if (pushok==2)
2728*c87b03e5Sespie 	  {
2729*c87b03e5Sespie 	    ffebad_start_msg ("SELECT (at %0) has duplicate cases -- check integer overflow of CASE(s)",
2730*c87b03e5Sespie 	      FFEBAD_severityFATAL);
2731*c87b03e5Sespie 	    ffebad_here (0, ffestw_line (block), ffestw_col (block));
2732*c87b03e5Sespie 	    ffebad_finish ();
2733*c87b03e5Sespie 	    ffestw_set_select_texpr (block, error_mark_node);
2734*c87b03e5Sespie 	  }
2735*c87b03e5Sespie 	c = c->next_stmt;
2736*c87b03e5Sespie 	/* Unlink prev.  */
2737*c87b03e5Sespie 	c->previous_stmt->previous_stmt->next_stmt = c;
2738*c87b03e5Sespie 	c->previous_stmt = c->previous_stmt->previous_stmt;
2739*c87b03e5Sespie       }
2740*c87b03e5Sespie     while ((c != (ffestwCase) &s->first_rel) && (casenum == c->casenum));
2741*c87b03e5Sespie }
2742*c87b03e5Sespie 
2743*c87b03e5Sespie /* END SELECT statement.  */
2744*c87b03e5Sespie 
2745*c87b03e5Sespie void
ffeste_R811(ffestw block)2746*c87b03e5Sespie ffeste_R811 (ffestw block)
2747*c87b03e5Sespie {
2748*c87b03e5Sespie   ffeste_emit_line_note_ ();
2749*c87b03e5Sespie 
2750*c87b03e5Sespie   /* ~~~Someday handle CHARACTER*1, CHARACTER*N */
2751*c87b03e5Sespie 
2752*c87b03e5Sespie   if (TREE_CODE (ffestw_select_texpr (block)) != ERROR_MARK)
2753*c87b03e5Sespie     expand_end_case (ffestw_select_texpr (block));
2754*c87b03e5Sespie 
2755*c87b03e5Sespie   ffeste_end_block_ (block);
2756*c87b03e5Sespie }
2757*c87b03e5Sespie 
2758*c87b03e5Sespie /* Iterative DO statement.  */
2759*c87b03e5Sespie 
2760*c87b03e5Sespie void
ffeste_R819A(ffestw block,ffelab label UNUSED,ffebld var,ffebld start,ffelexToken start_token,ffebld end,ffelexToken end_token,ffebld incr,ffelexToken incr_token)2761*c87b03e5Sespie ffeste_R819A (ffestw block, ffelab label UNUSED, ffebld var,
2762*c87b03e5Sespie 	      ffebld start, ffelexToken start_token,
2763*c87b03e5Sespie 	      ffebld end, ffelexToken end_token,
2764*c87b03e5Sespie 	      ffebld incr, ffelexToken incr_token)
2765*c87b03e5Sespie {
2766*c87b03e5Sespie   ffeste_check_simple_ ();
2767*c87b03e5Sespie 
2768*c87b03e5Sespie   ffeste_emit_line_note_ ();
2769*c87b03e5Sespie 
2770*c87b03e5Sespie   ffeste_begin_iterdo_ (block, NULL, NULL, NULL,
2771*c87b03e5Sespie 			var,
2772*c87b03e5Sespie 			start, start_token,
2773*c87b03e5Sespie 			end, end_token,
2774*c87b03e5Sespie 			incr, incr_token,
2775*c87b03e5Sespie 			"Iterative DO loop");
2776*c87b03e5Sespie }
2777*c87b03e5Sespie 
2778*c87b03e5Sespie /* DO WHILE statement.  */
2779*c87b03e5Sespie 
2780*c87b03e5Sespie void
ffeste_R819B(ffestw block,ffelab label UNUSED,ffebld expr)2781*c87b03e5Sespie ffeste_R819B (ffestw block, ffelab label UNUSED, ffebld expr)
2782*c87b03e5Sespie {
2783*c87b03e5Sespie   tree result;
2784*c87b03e5Sespie 
2785*c87b03e5Sespie   ffeste_check_simple_ ();
2786*c87b03e5Sespie 
2787*c87b03e5Sespie   ffeste_emit_line_note_ ();
2788*c87b03e5Sespie 
2789*c87b03e5Sespie   ffeste_start_block_ (block);
2790*c87b03e5Sespie 
2791*c87b03e5Sespie   if (expr)
2792*c87b03e5Sespie     {
2793*c87b03e5Sespie       struct nesting *loop;
2794*c87b03e5Sespie       tree mod;
2795*c87b03e5Sespie 
2796*c87b03e5Sespie       result = ffecom_make_tempvar ("dowhile", integer_type_node,
2797*c87b03e5Sespie 				    FFETARGET_charactersizeNONE, -1);
2798*c87b03e5Sespie       loop = expand_start_loop (1);
2799*c87b03e5Sespie 
2800*c87b03e5Sespie       ffeste_start_stmt_ ();
2801*c87b03e5Sespie 
2802*c87b03e5Sespie       ffecom_prepare_expr (expr);
2803*c87b03e5Sespie 
2804*c87b03e5Sespie       ffecom_prepare_end ();
2805*c87b03e5Sespie 
2806*c87b03e5Sespie       mod = ffecom_modify (void_type_node,
2807*c87b03e5Sespie 			   result,
2808*c87b03e5Sespie 			   ffecom_truth_value (ffecom_expr (expr)));
2809*c87b03e5Sespie       expand_expr_stmt (mod);
2810*c87b03e5Sespie 
2811*c87b03e5Sespie       ffeste_end_stmt_ ();
2812*c87b03e5Sespie 
2813*c87b03e5Sespie       ffestw_set_do_hook (block, loop);
2814*c87b03e5Sespie       expand_exit_loop_top_cond (0, result);
2815*c87b03e5Sespie     }
2816*c87b03e5Sespie   else
2817*c87b03e5Sespie     ffestw_set_do_hook (block, expand_start_loop (1));
2818*c87b03e5Sespie 
2819*c87b03e5Sespie   ffestw_set_do_tvar (block, NULL_TREE);
2820*c87b03e5Sespie }
2821*c87b03e5Sespie 
2822*c87b03e5Sespie /* END DO statement.
2823*c87b03e5Sespie 
2824*c87b03e5Sespie    This is the MIL-STD 1753 END DO. It's syntactic sugar, similar to
2825*c87b03e5Sespie    CONTINUE (except that it has to have a label that is the target of
2826*c87b03e5Sespie    one or more iterative DO statement), not the Fortran-90 structured
2827*c87b03e5Sespie    END DO, which is handled elsewhere, as is the actual mechanism of
2828*c87b03e5Sespie    ending an iterative DO statement, even one that ends at a label.  */
2829*c87b03e5Sespie 
2830*c87b03e5Sespie void
ffeste_R825()2831*c87b03e5Sespie ffeste_R825 ()
2832*c87b03e5Sespie {
2833*c87b03e5Sespie   ffeste_check_simple_ ();
2834*c87b03e5Sespie 
2835*c87b03e5Sespie   ffeste_emit_line_note_ ();
2836*c87b03e5Sespie 
2837*c87b03e5Sespie   emit_nop ();
2838*c87b03e5Sespie }
2839*c87b03e5Sespie 
2840*c87b03e5Sespie /* CYCLE statement.  */
2841*c87b03e5Sespie 
2842*c87b03e5Sespie void
ffeste_R834(ffestw block)2843*c87b03e5Sespie ffeste_R834 (ffestw block)
2844*c87b03e5Sespie {
2845*c87b03e5Sespie   ffeste_check_simple_ ();
2846*c87b03e5Sespie 
2847*c87b03e5Sespie   ffeste_emit_line_note_ ();
2848*c87b03e5Sespie 
2849*c87b03e5Sespie   expand_continue_loop (ffestw_do_hook (block));
2850*c87b03e5Sespie }
2851*c87b03e5Sespie 
2852*c87b03e5Sespie /* EXIT statement.  */
2853*c87b03e5Sespie 
2854*c87b03e5Sespie void
ffeste_R835(ffestw block)2855*c87b03e5Sespie ffeste_R835 (ffestw block)
2856*c87b03e5Sespie {
2857*c87b03e5Sespie   ffeste_check_simple_ ();
2858*c87b03e5Sespie 
2859*c87b03e5Sespie   ffeste_emit_line_note_ ();
2860*c87b03e5Sespie 
2861*c87b03e5Sespie   expand_exit_loop (ffestw_do_hook (block));
2862*c87b03e5Sespie }
2863*c87b03e5Sespie 
2864*c87b03e5Sespie /* GOTO statement.  */
2865*c87b03e5Sespie 
2866*c87b03e5Sespie void
ffeste_R836(ffelab label)2867*c87b03e5Sespie ffeste_R836 (ffelab label)
2868*c87b03e5Sespie {
2869*c87b03e5Sespie   tree glabel;
2870*c87b03e5Sespie 
2871*c87b03e5Sespie   ffeste_check_simple_ ();
2872*c87b03e5Sespie 
2873*c87b03e5Sespie   ffeste_emit_line_note_ ();
2874*c87b03e5Sespie 
2875*c87b03e5Sespie   glabel = ffecom_lookup_label (label);
2876*c87b03e5Sespie   if ((glabel != NULL_TREE)
2877*c87b03e5Sespie       && (TREE_CODE (glabel) != ERROR_MARK))
2878*c87b03e5Sespie     {
2879*c87b03e5Sespie       expand_goto (glabel);
2880*c87b03e5Sespie       TREE_USED (glabel) = 1;
2881*c87b03e5Sespie     }
2882*c87b03e5Sespie }
2883*c87b03e5Sespie 
2884*c87b03e5Sespie /* Computed GOTO statement.  */
2885*c87b03e5Sespie 
2886*c87b03e5Sespie void
ffeste_R837(ffelab * labels,int count,ffebld expr)2887*c87b03e5Sespie ffeste_R837 (ffelab *labels, int count, ffebld expr)
2888*c87b03e5Sespie {
2889*c87b03e5Sespie   int i;
2890*c87b03e5Sespie   tree texpr;
2891*c87b03e5Sespie   tree value;
2892*c87b03e5Sespie   tree tlabel;
2893*c87b03e5Sespie   int pushok;
2894*c87b03e5Sespie   tree duplicate;
2895*c87b03e5Sespie 
2896*c87b03e5Sespie   ffeste_check_simple_ ();
2897*c87b03e5Sespie 
2898*c87b03e5Sespie   ffeste_emit_line_note_ ();
2899*c87b03e5Sespie 
2900*c87b03e5Sespie   ffeste_start_stmt_ ();
2901*c87b03e5Sespie 
2902*c87b03e5Sespie   ffecom_prepare_expr (expr);
2903*c87b03e5Sespie 
2904*c87b03e5Sespie   ffecom_prepare_end ();
2905*c87b03e5Sespie 
2906*c87b03e5Sespie   texpr = ffecom_expr (expr);
2907*c87b03e5Sespie 
2908*c87b03e5Sespie   expand_start_case (0, texpr, TREE_TYPE (texpr), "computed GOTO statement");
2909*c87b03e5Sespie 
2910*c87b03e5Sespie   for (i = 0; i < count; ++i)
2911*c87b03e5Sespie     {
2912*c87b03e5Sespie       value = build_int_2 (i + 1, 0);
2913*c87b03e5Sespie       tlabel = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
2914*c87b03e5Sespie 
2915*c87b03e5Sespie       pushok = pushcase (value, convert, tlabel, &duplicate);
2916*c87b03e5Sespie       assert (pushok == 0);
2917*c87b03e5Sespie 
2918*c87b03e5Sespie       tlabel = ffecom_lookup_label (labels[i]);
2919*c87b03e5Sespie       if ((tlabel == NULL_TREE)
2920*c87b03e5Sespie 	  || (TREE_CODE (tlabel) == ERROR_MARK))
2921*c87b03e5Sespie 	continue;
2922*c87b03e5Sespie 
2923*c87b03e5Sespie       expand_goto (tlabel);
2924*c87b03e5Sespie       TREE_USED (tlabel) = 1;
2925*c87b03e5Sespie     }
2926*c87b03e5Sespie   expand_end_case (texpr);
2927*c87b03e5Sespie 
2928*c87b03e5Sespie   ffeste_end_stmt_ ();
2929*c87b03e5Sespie }
2930*c87b03e5Sespie 
2931*c87b03e5Sespie /* ASSIGN statement.  */
2932*c87b03e5Sespie 
2933*c87b03e5Sespie void
ffeste_R838(ffelab label,ffebld target)2934*c87b03e5Sespie ffeste_R838 (ffelab label, ffebld target)
2935*c87b03e5Sespie {
2936*c87b03e5Sespie   tree expr_tree;
2937*c87b03e5Sespie   tree label_tree;
2938*c87b03e5Sespie   tree target_tree;
2939*c87b03e5Sespie 
2940*c87b03e5Sespie   ffeste_check_simple_ ();
2941*c87b03e5Sespie 
2942*c87b03e5Sespie   ffeste_emit_line_note_ ();
2943*c87b03e5Sespie 
2944*c87b03e5Sespie     /* No need to call ffeste_start_stmt_(), as the sorts of expressions
2945*c87b03e5Sespie        seen here should never require use of temporaries.  */
2946*c87b03e5Sespie 
2947*c87b03e5Sespie   label_tree = ffecom_lookup_label (label);
2948*c87b03e5Sespie   if ((label_tree != NULL_TREE)
2949*c87b03e5Sespie       && (TREE_CODE (label_tree) != ERROR_MARK))
2950*c87b03e5Sespie     {
2951*c87b03e5Sespie       label_tree = ffecom_1 (ADDR_EXPR,
2952*c87b03e5Sespie 			     build_pointer_type (void_type_node),
2953*c87b03e5Sespie 			     label_tree);
2954*c87b03e5Sespie       TREE_CONSTANT (label_tree) = 1;
2955*c87b03e5Sespie 
2956*c87b03e5Sespie       target_tree = ffecom_expr_assign_w (target);
2957*c87b03e5Sespie       if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (target_tree)))
2958*c87b03e5Sespie 	  < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (label_tree))))
2959*c87b03e5Sespie 	error ("ASSIGN to variable that is too small");
2960*c87b03e5Sespie 
2961*c87b03e5Sespie       label_tree = convert (TREE_TYPE (target_tree), label_tree);
2962*c87b03e5Sespie 
2963*c87b03e5Sespie       expr_tree = ffecom_modify (void_type_node,
2964*c87b03e5Sespie 				 target_tree,
2965*c87b03e5Sespie 				 label_tree);
2966*c87b03e5Sespie       expand_expr_stmt (expr_tree);
2967*c87b03e5Sespie     }
2968*c87b03e5Sespie }
2969*c87b03e5Sespie 
2970*c87b03e5Sespie /* Assigned GOTO statement.  */
2971*c87b03e5Sespie 
2972*c87b03e5Sespie void
ffeste_R839(ffebld target)2973*c87b03e5Sespie ffeste_R839 (ffebld target)
2974*c87b03e5Sespie {
2975*c87b03e5Sespie   tree t;
2976*c87b03e5Sespie 
2977*c87b03e5Sespie   ffeste_check_simple_ ();
2978*c87b03e5Sespie 
2979*c87b03e5Sespie   ffeste_emit_line_note_ ();
2980*c87b03e5Sespie 
2981*c87b03e5Sespie   /* No need to call ffeste_start_stmt_(), as the sorts of expressions
2982*c87b03e5Sespie      seen here should never require use of temporaries.  */
2983*c87b03e5Sespie 
2984*c87b03e5Sespie   t = ffecom_expr_assign (target);
2985*c87b03e5Sespie   if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (t)))
2986*c87b03e5Sespie       < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (null_pointer_node))))
2987*c87b03e5Sespie     error ("ASSIGNed GOTO target variable is too small");
2988*c87b03e5Sespie 
2989*c87b03e5Sespie   expand_computed_goto (convert (TREE_TYPE (null_pointer_node), t));
2990*c87b03e5Sespie }
2991*c87b03e5Sespie 
2992*c87b03e5Sespie /* Arithmetic IF statement.  */
2993*c87b03e5Sespie 
2994*c87b03e5Sespie void
ffeste_R840(ffebld expr,ffelab neg,ffelab zero,ffelab pos)2995*c87b03e5Sespie ffeste_R840 (ffebld expr, ffelab neg, ffelab zero, ffelab pos)
2996*c87b03e5Sespie {
2997*c87b03e5Sespie   tree gneg = ffecom_lookup_label (neg);
2998*c87b03e5Sespie   tree gzero = ffecom_lookup_label (zero);
2999*c87b03e5Sespie   tree gpos = ffecom_lookup_label (pos);
3000*c87b03e5Sespie   tree texpr;
3001*c87b03e5Sespie 
3002*c87b03e5Sespie   ffeste_check_simple_ ();
3003*c87b03e5Sespie 
3004*c87b03e5Sespie   ffeste_emit_line_note_ ();
3005*c87b03e5Sespie 
3006*c87b03e5Sespie   if ((gneg == NULL_TREE) || (gzero == NULL_TREE) || (gpos == NULL_TREE))
3007*c87b03e5Sespie     return;
3008*c87b03e5Sespie   if ((TREE_CODE (gneg) == ERROR_MARK)
3009*c87b03e5Sespie       || (TREE_CODE (gzero) == ERROR_MARK)
3010*c87b03e5Sespie       || (TREE_CODE (gpos) == ERROR_MARK))
3011*c87b03e5Sespie     return;
3012*c87b03e5Sespie 
3013*c87b03e5Sespie   ffeste_start_stmt_ ();
3014*c87b03e5Sespie 
3015*c87b03e5Sespie   ffecom_prepare_expr (expr);
3016*c87b03e5Sespie 
3017*c87b03e5Sespie   ffecom_prepare_end ();
3018*c87b03e5Sespie 
3019*c87b03e5Sespie   if (neg == zero)
3020*c87b03e5Sespie     {
3021*c87b03e5Sespie       if (neg == pos)
3022*c87b03e5Sespie 	expand_goto (gzero);
3023*c87b03e5Sespie       else
3024*c87b03e5Sespie 	{
3025*c87b03e5Sespie 	  /* IF (expr.LE.0) THEN GOTO neg/zero ELSE GOTO pos.  */
3026*c87b03e5Sespie 	  texpr = ffecom_expr (expr);
3027*c87b03e5Sespie 	  texpr = ffecom_2 (LE_EXPR, integer_type_node,
3028*c87b03e5Sespie 			    texpr,
3029*c87b03e5Sespie 			    convert (TREE_TYPE (texpr),
3030*c87b03e5Sespie 				     integer_zero_node));
3031*c87b03e5Sespie 	  expand_start_cond (ffecom_truth_value (texpr), 0);
3032*c87b03e5Sespie 	  expand_goto (gzero);
3033*c87b03e5Sespie 	  expand_start_else ();
3034*c87b03e5Sespie 	  expand_goto (gpos);
3035*c87b03e5Sespie 	  expand_end_cond ();
3036*c87b03e5Sespie 	}
3037*c87b03e5Sespie     }
3038*c87b03e5Sespie   else if (neg == pos)
3039*c87b03e5Sespie     {
3040*c87b03e5Sespie       /* IF (expr.NE.0) THEN GOTO neg/pos ELSE GOTO zero.  */
3041*c87b03e5Sespie       texpr = ffecom_expr (expr);
3042*c87b03e5Sespie       texpr = ffecom_2 (NE_EXPR, integer_type_node,
3043*c87b03e5Sespie 			texpr,
3044*c87b03e5Sespie 			convert (TREE_TYPE (texpr),
3045*c87b03e5Sespie 				 integer_zero_node));
3046*c87b03e5Sespie       expand_start_cond (ffecom_truth_value (texpr), 0);
3047*c87b03e5Sespie       expand_goto (gneg);
3048*c87b03e5Sespie       expand_start_else ();
3049*c87b03e5Sespie       expand_goto (gzero);
3050*c87b03e5Sespie       expand_end_cond ();
3051*c87b03e5Sespie     }
3052*c87b03e5Sespie   else if (zero == pos)
3053*c87b03e5Sespie     {
3054*c87b03e5Sespie       /* IF (expr.GE.0) THEN GOTO zero/pos ELSE GOTO neg.  */
3055*c87b03e5Sespie       texpr = ffecom_expr (expr);
3056*c87b03e5Sespie       texpr = ffecom_2 (GE_EXPR, integer_type_node,
3057*c87b03e5Sespie 			texpr,
3058*c87b03e5Sespie 			convert (TREE_TYPE (texpr),
3059*c87b03e5Sespie 				 integer_zero_node));
3060*c87b03e5Sespie       expand_start_cond (ffecom_truth_value (texpr), 0);
3061*c87b03e5Sespie       expand_goto (gzero);
3062*c87b03e5Sespie       expand_start_else ();
3063*c87b03e5Sespie       expand_goto (gneg);
3064*c87b03e5Sespie       expand_end_cond ();
3065*c87b03e5Sespie     }
3066*c87b03e5Sespie   else
3067*c87b03e5Sespie     {
3068*c87b03e5Sespie       /* Use a SAVE_EXPR in combo with:
3069*c87b03e5Sespie 	 IF (expr.LT.0) THEN GOTO neg
3070*c87b03e5Sespie 	 ELSEIF (expr.GT.0) THEN GOTO pos
3071*c87b03e5Sespie 	 ELSE GOTO zero.  */
3072*c87b03e5Sespie       tree expr_saved = ffecom_save_tree (ffecom_expr (expr));
3073*c87b03e5Sespie 
3074*c87b03e5Sespie       texpr = ffecom_2 (LT_EXPR, integer_type_node,
3075*c87b03e5Sespie 			expr_saved,
3076*c87b03e5Sespie 			convert (TREE_TYPE (expr_saved),
3077*c87b03e5Sespie 				 integer_zero_node));
3078*c87b03e5Sespie       expand_start_cond (ffecom_truth_value (texpr), 0);
3079*c87b03e5Sespie       expand_goto (gneg);
3080*c87b03e5Sespie       texpr = ffecom_2 (GT_EXPR, integer_type_node,
3081*c87b03e5Sespie 			expr_saved,
3082*c87b03e5Sespie 			convert (TREE_TYPE (expr_saved),
3083*c87b03e5Sespie 				 integer_zero_node));
3084*c87b03e5Sespie       expand_start_elseif (ffecom_truth_value (texpr));
3085*c87b03e5Sespie       expand_goto (gpos);
3086*c87b03e5Sespie       expand_start_else ();
3087*c87b03e5Sespie       expand_goto (gzero);
3088*c87b03e5Sespie       expand_end_cond ();
3089*c87b03e5Sespie     }
3090*c87b03e5Sespie 
3091*c87b03e5Sespie   ffeste_end_stmt_ ();
3092*c87b03e5Sespie }
3093*c87b03e5Sespie 
3094*c87b03e5Sespie /* CONTINUE statement.  */
3095*c87b03e5Sespie 
3096*c87b03e5Sespie void
ffeste_R841()3097*c87b03e5Sespie ffeste_R841 ()
3098*c87b03e5Sespie {
3099*c87b03e5Sespie   ffeste_check_simple_ ();
3100*c87b03e5Sespie 
3101*c87b03e5Sespie   ffeste_emit_line_note_ ();
3102*c87b03e5Sespie 
3103*c87b03e5Sespie   emit_nop ();
3104*c87b03e5Sespie }
3105*c87b03e5Sespie 
3106*c87b03e5Sespie /* STOP statement.  */
3107*c87b03e5Sespie 
3108*c87b03e5Sespie void
ffeste_R842(ffebld expr)3109*c87b03e5Sespie ffeste_R842 (ffebld expr)
3110*c87b03e5Sespie {
3111*c87b03e5Sespie   tree callit;
3112*c87b03e5Sespie   ffelexToken msg;
3113*c87b03e5Sespie 
3114*c87b03e5Sespie   ffeste_check_simple_ ();
3115*c87b03e5Sespie 
3116*c87b03e5Sespie   ffeste_emit_line_note_ ();
3117*c87b03e5Sespie 
3118*c87b03e5Sespie   if ((expr == NULL)
3119*c87b03e5Sespie       || (ffeinfo_basictype (ffebld_info (expr))
3120*c87b03e5Sespie 	  == FFEINFO_basictypeANY))
3121*c87b03e5Sespie     {
3122*c87b03e5Sespie       msg = ffelex_token_new_character ("",
3123*c87b03e5Sespie 					ffelex_token_where_line (ffesta_tokens[0]),
3124*c87b03e5Sespie 					ffelex_token_where_column (ffesta_tokens[0]));
3125*c87b03e5Sespie       expr = ffebld_new_conter (ffebld_constant_new_characterdefault
3126*c87b03e5Sespie 				(msg));
3127*c87b03e5Sespie       ffelex_token_kill (msg);
3128*c87b03e5Sespie       ffebld_set_info (expr, ffeinfo_new (FFEINFO_basictypeCHARACTER,
3129*c87b03e5Sespie 					  FFEINFO_kindtypeCHARACTERDEFAULT,
3130*c87b03e5Sespie 					  0, FFEINFO_kindENTITY,
3131*c87b03e5Sespie 					  FFEINFO_whereCONSTANT, 0));
3132*c87b03e5Sespie     }
3133*c87b03e5Sespie   else if (ffeinfo_basictype (ffebld_info (expr))
3134*c87b03e5Sespie 	   == FFEINFO_basictypeINTEGER)
3135*c87b03e5Sespie     {
3136*c87b03e5Sespie       char num[50];
3137*c87b03e5Sespie 
3138*c87b03e5Sespie       assert (ffebld_op (expr) == FFEBLD_opCONTER);
3139*c87b03e5Sespie       assert (ffeinfo_kindtype (ffebld_info (expr))
3140*c87b03e5Sespie 	      == FFEINFO_kindtypeINTEGERDEFAULT);
3141*c87b03e5Sespie       sprintf (num, "%" ffetargetIntegerDefault_f "d",
3142*c87b03e5Sespie 	       ffebld_constant_integer1 (ffebld_conter (expr)));
3143*c87b03e5Sespie       msg = ffelex_token_new_character (num,
3144*c87b03e5Sespie 					ffelex_token_where_line (ffesta_tokens[0]),
3145*c87b03e5Sespie 					ffelex_token_where_column (ffesta_tokens[0]));
3146*c87b03e5Sespie       expr = ffebld_new_conter (ffebld_constant_new_characterdefault (msg));
3147*c87b03e5Sespie       ffelex_token_kill (msg);
3148*c87b03e5Sespie       ffebld_set_info (expr, ffeinfo_new (FFEINFO_basictypeCHARACTER,
3149*c87b03e5Sespie 					  FFEINFO_kindtypeCHARACTERDEFAULT,
3150*c87b03e5Sespie 					  0, FFEINFO_kindENTITY,
3151*c87b03e5Sespie 					  FFEINFO_whereCONSTANT, 0));
3152*c87b03e5Sespie     }
3153*c87b03e5Sespie   else
3154*c87b03e5Sespie     {
3155*c87b03e5Sespie       assert (ffeinfo_basictype (ffebld_info (expr))
3156*c87b03e5Sespie 	      == FFEINFO_basictypeCHARACTER);
3157*c87b03e5Sespie       assert (ffebld_op (expr) == FFEBLD_opCONTER);
3158*c87b03e5Sespie       assert (ffeinfo_kindtype (ffebld_info (expr))
3159*c87b03e5Sespie 	      == FFEINFO_kindtypeCHARACTERDEFAULT);
3160*c87b03e5Sespie     }
3161*c87b03e5Sespie 
3162*c87b03e5Sespie   /* No need to call ffeste_start_stmt_(), as the sorts of expressions
3163*c87b03e5Sespie      seen here should never require use of temporaries.  */
3164*c87b03e5Sespie 
3165*c87b03e5Sespie   callit = ffecom_call_gfrt (FFECOM_gfrtSTOP,
3166*c87b03e5Sespie 			     ffecom_list_ptr_to_expr (ffebld_new_item (expr, NULL)),
3167*c87b03e5Sespie 			     NULL_TREE);
3168*c87b03e5Sespie   TREE_SIDE_EFFECTS (callit) = 1;
3169*c87b03e5Sespie 
3170*c87b03e5Sespie   expand_expr_stmt (callit);
3171*c87b03e5Sespie }
3172*c87b03e5Sespie 
3173*c87b03e5Sespie /* PAUSE statement.  */
3174*c87b03e5Sespie 
3175*c87b03e5Sespie void
ffeste_R843(ffebld expr)3176*c87b03e5Sespie ffeste_R843 (ffebld expr)
3177*c87b03e5Sespie {
3178*c87b03e5Sespie   tree callit;
3179*c87b03e5Sespie   ffelexToken msg;
3180*c87b03e5Sespie 
3181*c87b03e5Sespie   ffeste_check_simple_ ();
3182*c87b03e5Sespie 
3183*c87b03e5Sespie   ffeste_emit_line_note_ ();
3184*c87b03e5Sespie 
3185*c87b03e5Sespie   if ((expr == NULL)
3186*c87b03e5Sespie       || (ffeinfo_basictype (ffebld_info (expr))
3187*c87b03e5Sespie 	  == FFEINFO_basictypeANY))
3188*c87b03e5Sespie     {
3189*c87b03e5Sespie       msg = ffelex_token_new_character ("",
3190*c87b03e5Sespie 					ffelex_token_where_line (ffesta_tokens[0]),
3191*c87b03e5Sespie 					ffelex_token_where_column (ffesta_tokens[0]));
3192*c87b03e5Sespie       expr = ffebld_new_conter (ffebld_constant_new_characterdefault (msg));
3193*c87b03e5Sespie       ffelex_token_kill (msg);
3194*c87b03e5Sespie       ffebld_set_info (expr, ffeinfo_new (FFEINFO_basictypeCHARACTER,
3195*c87b03e5Sespie 					  FFEINFO_kindtypeCHARACTERDEFAULT,
3196*c87b03e5Sespie 					  0, FFEINFO_kindENTITY,
3197*c87b03e5Sespie 					  FFEINFO_whereCONSTANT, 0));
3198*c87b03e5Sespie     }
3199*c87b03e5Sespie   else if (ffeinfo_basictype (ffebld_info (expr)) == FFEINFO_basictypeINTEGER)
3200*c87b03e5Sespie     {
3201*c87b03e5Sespie       char num[50];
3202*c87b03e5Sespie 
3203*c87b03e5Sespie       assert (ffebld_op (expr) == FFEBLD_opCONTER);
3204*c87b03e5Sespie       assert (ffeinfo_kindtype (ffebld_info (expr))
3205*c87b03e5Sespie 	      == FFEINFO_kindtypeINTEGERDEFAULT);
3206*c87b03e5Sespie       sprintf (num, "%" ffetargetIntegerDefault_f "d",
3207*c87b03e5Sespie 	       ffebld_constant_integer1 (ffebld_conter (expr)));
3208*c87b03e5Sespie       msg = ffelex_token_new_character (num, ffelex_token_where_line (ffesta_tokens[0]),
3209*c87b03e5Sespie 					ffelex_token_where_column (ffesta_tokens[0]));
3210*c87b03e5Sespie       expr = ffebld_new_conter (ffebld_constant_new_characterdefault (msg));
3211*c87b03e5Sespie       ffelex_token_kill (msg);
3212*c87b03e5Sespie       ffebld_set_info (expr, ffeinfo_new (FFEINFO_basictypeCHARACTER,
3213*c87b03e5Sespie 					  FFEINFO_kindtypeCHARACTERDEFAULT,
3214*c87b03e5Sespie 					  0, FFEINFO_kindENTITY,
3215*c87b03e5Sespie 					  FFEINFO_whereCONSTANT, 0));
3216*c87b03e5Sespie     }
3217*c87b03e5Sespie   else
3218*c87b03e5Sespie     {
3219*c87b03e5Sespie       assert (ffeinfo_basictype (ffebld_info (expr))
3220*c87b03e5Sespie 	      == FFEINFO_basictypeCHARACTER);
3221*c87b03e5Sespie       assert (ffebld_op (expr) == FFEBLD_opCONTER);
3222*c87b03e5Sespie       assert (ffeinfo_kindtype (ffebld_info (expr))
3223*c87b03e5Sespie 	      == FFEINFO_kindtypeCHARACTERDEFAULT);
3224*c87b03e5Sespie     }
3225*c87b03e5Sespie 
3226*c87b03e5Sespie   /* No need to call ffeste_start_stmt_(), as the sorts of expressions
3227*c87b03e5Sespie      seen here should never require use of temporaries.  */
3228*c87b03e5Sespie 
3229*c87b03e5Sespie   callit = ffecom_call_gfrt (FFECOM_gfrtPAUSE,
3230*c87b03e5Sespie 			     ffecom_list_ptr_to_expr (ffebld_new_item (expr, NULL)),
3231*c87b03e5Sespie 			     NULL_TREE);
3232*c87b03e5Sespie   TREE_SIDE_EFFECTS (callit) = 1;
3233*c87b03e5Sespie 
3234*c87b03e5Sespie   expand_expr_stmt (callit);
3235*c87b03e5Sespie }
3236*c87b03e5Sespie 
3237*c87b03e5Sespie /* OPEN statement.  */
3238*c87b03e5Sespie 
3239*c87b03e5Sespie void
ffeste_R904(ffestpOpenStmt * info)3240*c87b03e5Sespie ffeste_R904 (ffestpOpenStmt *info)
3241*c87b03e5Sespie {
3242*c87b03e5Sespie   tree args;
3243*c87b03e5Sespie   bool iostat;
3244*c87b03e5Sespie   bool errl;
3245*c87b03e5Sespie 
3246*c87b03e5Sespie   ffeste_check_simple_ ();
3247*c87b03e5Sespie 
3248*c87b03e5Sespie   ffeste_emit_line_note_ ();
3249*c87b03e5Sespie 
3250*c87b03e5Sespie #define specified(something) (info->open_spec[something].kw_or_val_present)
3251*c87b03e5Sespie 
3252*c87b03e5Sespie   iostat = specified (FFESTP_openixIOSTAT);
3253*c87b03e5Sespie   errl = specified (FFESTP_openixERR);
3254*c87b03e5Sespie 
3255*c87b03e5Sespie #undef specified
3256*c87b03e5Sespie 
3257*c87b03e5Sespie   ffeste_start_stmt_ ();
3258*c87b03e5Sespie 
3259*c87b03e5Sespie   if (errl)
3260*c87b03e5Sespie     {
3261*c87b03e5Sespie       ffeste_io_err_
3262*c87b03e5Sespie 	= ffeste_io_abort_
3263*c87b03e5Sespie 	= ffecom_lookup_label
3264*c87b03e5Sespie 	(info->open_spec[FFESTP_openixERR].u.label);
3265*c87b03e5Sespie       ffeste_io_abort_is_temp_ = FALSE;
3266*c87b03e5Sespie     }
3267*c87b03e5Sespie   else
3268*c87b03e5Sespie     {
3269*c87b03e5Sespie       ffeste_io_err_ = NULL_TREE;
3270*c87b03e5Sespie 
3271*c87b03e5Sespie       if ((ffeste_io_abort_is_temp_ = iostat))
3272*c87b03e5Sespie 	ffeste_io_abort_ = ffecom_temp_label ();
3273*c87b03e5Sespie       else
3274*c87b03e5Sespie 	ffeste_io_abort_ = NULL_TREE;
3275*c87b03e5Sespie     }
3276*c87b03e5Sespie 
3277*c87b03e5Sespie   if (iostat)
3278*c87b03e5Sespie     {
3279*c87b03e5Sespie       /* Have IOSTAT= specification.  */
3280*c87b03e5Sespie 
3281*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
3282*c87b03e5Sespie       ffeste_io_iostat_ = ffecom_expr
3283*c87b03e5Sespie 	(info->open_spec[FFESTP_openixIOSTAT].u.expr);
3284*c87b03e5Sespie     }
3285*c87b03e5Sespie   else if (ffeste_io_abort_ != NULL_TREE)
3286*c87b03e5Sespie     {
3287*c87b03e5Sespie       /* Have no IOSTAT= but have ERR=.  */
3288*c87b03e5Sespie 
3289*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = TRUE;
3290*c87b03e5Sespie       ffeste_io_iostat_
3291*c87b03e5Sespie 	= ffecom_make_tempvar ("open", ffecom_integer_type_node,
3292*c87b03e5Sespie 			       FFETARGET_charactersizeNONE, -1);
3293*c87b03e5Sespie     }
3294*c87b03e5Sespie   else
3295*c87b03e5Sespie     {
3296*c87b03e5Sespie       /* No IOSTAT= or ERR= specification.  */
3297*c87b03e5Sespie 
3298*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
3299*c87b03e5Sespie       ffeste_io_iostat_ = NULL_TREE;
3300*c87b03e5Sespie     }
3301*c87b03e5Sespie 
3302*c87b03e5Sespie   /* Now prescan, then convert, all the arguments.  */
3303*c87b03e5Sespie 
3304*c87b03e5Sespie   args = ffeste_io_olist_ (errl || iostat,
3305*c87b03e5Sespie 			   info->open_spec[FFESTP_openixUNIT].u.expr,
3306*c87b03e5Sespie 			   &info->open_spec[FFESTP_openixFILE],
3307*c87b03e5Sespie 			   &info->open_spec[FFESTP_openixSTATUS],
3308*c87b03e5Sespie 			   &info->open_spec[FFESTP_openixACCESS],
3309*c87b03e5Sespie 			   &info->open_spec[FFESTP_openixFORM],
3310*c87b03e5Sespie 			   &info->open_spec[FFESTP_openixRECL],
3311*c87b03e5Sespie 			   &info->open_spec[FFESTP_openixBLANK]);
3312*c87b03e5Sespie 
3313*c87b03e5Sespie   /* Don't generate "if (iostat != 0) goto label;" if label is temp abort
3314*c87b03e5Sespie        label, since we're gonna fall through to there anyway. */
3315*c87b03e5Sespie 
3316*c87b03e5Sespie   ffeste_io_call_ (ffecom_call_gfrt (FFECOM_gfrtFOPEN, args, NULL_TREE),
3317*c87b03e5Sespie 		   ! ffeste_io_abort_is_temp_);
3318*c87b03e5Sespie 
3319*c87b03e5Sespie   /* If we've got a temp label, generate its code here.  */
3320*c87b03e5Sespie 
3321*c87b03e5Sespie   if (ffeste_io_abort_is_temp_)
3322*c87b03e5Sespie     {
3323*c87b03e5Sespie       DECL_INITIAL (ffeste_io_abort_) = error_mark_node;
3324*c87b03e5Sespie       emit_nop ();
3325*c87b03e5Sespie       expand_label (ffeste_io_abort_);
3326*c87b03e5Sespie 
3327*c87b03e5Sespie       assert (ffeste_io_err_ == NULL_TREE);
3328*c87b03e5Sespie     }
3329*c87b03e5Sespie 
3330*c87b03e5Sespie   ffeste_end_stmt_ ();
3331*c87b03e5Sespie }
3332*c87b03e5Sespie 
3333*c87b03e5Sespie /* CLOSE statement.  */
3334*c87b03e5Sespie 
3335*c87b03e5Sespie void
ffeste_R907(ffestpCloseStmt * info)3336*c87b03e5Sespie ffeste_R907 (ffestpCloseStmt *info)
3337*c87b03e5Sespie {
3338*c87b03e5Sespie   tree args;
3339*c87b03e5Sespie   bool iostat;
3340*c87b03e5Sespie   bool errl;
3341*c87b03e5Sespie 
3342*c87b03e5Sespie   ffeste_check_simple_ ();
3343*c87b03e5Sespie 
3344*c87b03e5Sespie   ffeste_emit_line_note_ ();
3345*c87b03e5Sespie 
3346*c87b03e5Sespie #define specified(something) (info->close_spec[something].kw_or_val_present)
3347*c87b03e5Sespie 
3348*c87b03e5Sespie   iostat = specified (FFESTP_closeixIOSTAT);
3349*c87b03e5Sespie   errl = specified (FFESTP_closeixERR);
3350*c87b03e5Sespie 
3351*c87b03e5Sespie #undef specified
3352*c87b03e5Sespie 
3353*c87b03e5Sespie   ffeste_start_stmt_ ();
3354*c87b03e5Sespie 
3355*c87b03e5Sespie   if (errl)
3356*c87b03e5Sespie     {
3357*c87b03e5Sespie       ffeste_io_err_
3358*c87b03e5Sespie 	= ffeste_io_abort_
3359*c87b03e5Sespie 	= ffecom_lookup_label
3360*c87b03e5Sespie 	(info->close_spec[FFESTP_closeixERR].u.label);
3361*c87b03e5Sespie       ffeste_io_abort_is_temp_ = FALSE;
3362*c87b03e5Sespie     }
3363*c87b03e5Sespie   else
3364*c87b03e5Sespie     {
3365*c87b03e5Sespie       ffeste_io_err_ = NULL_TREE;
3366*c87b03e5Sespie 
3367*c87b03e5Sespie       if ((ffeste_io_abort_is_temp_ = iostat))
3368*c87b03e5Sespie 	ffeste_io_abort_ = ffecom_temp_label ();
3369*c87b03e5Sespie       else
3370*c87b03e5Sespie 	ffeste_io_abort_ = NULL_TREE;
3371*c87b03e5Sespie     }
3372*c87b03e5Sespie 
3373*c87b03e5Sespie   if (iostat)
3374*c87b03e5Sespie     {
3375*c87b03e5Sespie       /* Have IOSTAT= specification.  */
3376*c87b03e5Sespie 
3377*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
3378*c87b03e5Sespie       ffeste_io_iostat_ = ffecom_expr
3379*c87b03e5Sespie 	(info->close_spec[FFESTP_closeixIOSTAT].u.expr);
3380*c87b03e5Sespie     }
3381*c87b03e5Sespie   else if (ffeste_io_abort_ != NULL_TREE)
3382*c87b03e5Sespie     {
3383*c87b03e5Sespie       /* Have no IOSTAT= but have ERR=.  */
3384*c87b03e5Sespie 
3385*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = TRUE;
3386*c87b03e5Sespie       ffeste_io_iostat_
3387*c87b03e5Sespie 	= ffecom_make_tempvar ("close", ffecom_integer_type_node,
3388*c87b03e5Sespie 			       FFETARGET_charactersizeNONE, -1);
3389*c87b03e5Sespie     }
3390*c87b03e5Sespie   else
3391*c87b03e5Sespie     {
3392*c87b03e5Sespie       /* No IOSTAT= or ERR= specification.  */
3393*c87b03e5Sespie 
3394*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
3395*c87b03e5Sespie       ffeste_io_iostat_ = NULL_TREE;
3396*c87b03e5Sespie     }
3397*c87b03e5Sespie 
3398*c87b03e5Sespie   /* Now prescan, then convert, all the arguments.  */
3399*c87b03e5Sespie 
3400*c87b03e5Sespie   args = ffeste_io_cllist_ (errl || iostat,
3401*c87b03e5Sespie 			    info->close_spec[FFESTP_closeixUNIT].u.expr,
3402*c87b03e5Sespie 			    &info->close_spec[FFESTP_closeixSTATUS]);
3403*c87b03e5Sespie 
3404*c87b03e5Sespie   /* Don't generate "if (iostat != 0) goto label;" if label is temp abort
3405*c87b03e5Sespie        label, since we're gonna fall through to there anyway. */
3406*c87b03e5Sespie 
3407*c87b03e5Sespie   ffeste_io_call_ (ffecom_call_gfrt (FFECOM_gfrtFCLOS, args, NULL_TREE),
3408*c87b03e5Sespie 		   ! ffeste_io_abort_is_temp_);
3409*c87b03e5Sespie 
3410*c87b03e5Sespie   /* If we've got a temp label, generate its code here. */
3411*c87b03e5Sespie 
3412*c87b03e5Sespie   if (ffeste_io_abort_is_temp_)
3413*c87b03e5Sespie     {
3414*c87b03e5Sespie       DECL_INITIAL (ffeste_io_abort_) = error_mark_node;
3415*c87b03e5Sespie       emit_nop ();
3416*c87b03e5Sespie       expand_label (ffeste_io_abort_);
3417*c87b03e5Sespie 
3418*c87b03e5Sespie       assert (ffeste_io_err_ == NULL_TREE);
3419*c87b03e5Sespie     }
3420*c87b03e5Sespie 
3421*c87b03e5Sespie   ffeste_end_stmt_ ();
3422*c87b03e5Sespie }
3423*c87b03e5Sespie 
3424*c87b03e5Sespie /* READ(...) statement -- start.  */
3425*c87b03e5Sespie 
3426*c87b03e5Sespie void
ffeste_R909_start(ffestpReadStmt * info,bool only_format UNUSED,ffestvUnit unit,ffestvFormat format,bool rec,bool key UNUSED)3427*c87b03e5Sespie ffeste_R909_start (ffestpReadStmt *info, bool only_format UNUSED,
3428*c87b03e5Sespie 		   ffestvUnit unit, ffestvFormat format, bool rec,
3429*c87b03e5Sespie 		   bool key UNUSED)
3430*c87b03e5Sespie {
3431*c87b03e5Sespie   ffecomGfrt start;
3432*c87b03e5Sespie   ffecomGfrt end;
3433*c87b03e5Sespie   tree cilist;
3434*c87b03e5Sespie   bool iostat;
3435*c87b03e5Sespie   bool errl;
3436*c87b03e5Sespie   bool endl;
3437*c87b03e5Sespie 
3438*c87b03e5Sespie   ffeste_check_start_ ();
3439*c87b03e5Sespie 
3440*c87b03e5Sespie   ffeste_emit_line_note_ ();
3441*c87b03e5Sespie 
3442*c87b03e5Sespie   /* First determine the start, per-item, and end run-time functions to
3443*c87b03e5Sespie      call.  The per-item function is picked by choosing an ffeste function
3444*c87b03e5Sespie      to call to handle a given item; it knows how to generate a call to the
3445*c87b03e5Sespie      appropriate run-time function, and is called an "I/O driver".  */
3446*c87b03e5Sespie 
3447*c87b03e5Sespie   switch (format)
3448*c87b03e5Sespie     {
3449*c87b03e5Sespie     case FFESTV_formatNONE:	/* no FMT= */
3450*c87b03e5Sespie       ffeste_io_driver_ = ffeste_io_douio_;
3451*c87b03e5Sespie       if (rec)
3452*c87b03e5Sespie 	start = FFECOM_gfrtSRDUE, end = FFECOM_gfrtERDUE;
3453*c87b03e5Sespie       else
3454*c87b03e5Sespie 	start = FFECOM_gfrtSRSUE, end = FFECOM_gfrtERSUE;
3455*c87b03e5Sespie       break;
3456*c87b03e5Sespie 
3457*c87b03e5Sespie     case FFESTV_formatLABEL:	/* FMT=10 */
3458*c87b03e5Sespie     case FFESTV_formatCHAREXPR:	/* FMT='(I10)' */
3459*c87b03e5Sespie     case FFESTV_formatINTEXPR:	/* FMT=I [after ASSIGN 10 TO I] */
3460*c87b03e5Sespie       ffeste_io_driver_ = ffeste_io_dofio_;
3461*c87b03e5Sespie       if (rec)
3462*c87b03e5Sespie 	start = FFECOM_gfrtSRDFE, end = FFECOM_gfrtERDFE;
3463*c87b03e5Sespie       else if (unit == FFESTV_unitCHAREXPR)
3464*c87b03e5Sespie 	start = FFECOM_gfrtSRSFI, end = FFECOM_gfrtERSFI;
3465*c87b03e5Sespie       else
3466*c87b03e5Sespie 	start = FFECOM_gfrtSRSFE, end = FFECOM_gfrtERSFE;
3467*c87b03e5Sespie       break;
3468*c87b03e5Sespie 
3469*c87b03e5Sespie     case FFESTV_formatASTERISK:	/* FMT=* */
3470*c87b03e5Sespie       ffeste_io_driver_ = ffeste_io_dolio_;
3471*c87b03e5Sespie       if (unit == FFESTV_unitCHAREXPR)
3472*c87b03e5Sespie 	start = FFECOM_gfrtSRSLI, end = FFECOM_gfrtERSLI;
3473*c87b03e5Sespie       else
3474*c87b03e5Sespie 	start = FFECOM_gfrtSRSLE, end = FFECOM_gfrtERSLE;
3475*c87b03e5Sespie       break;
3476*c87b03e5Sespie 
3477*c87b03e5Sespie     case FFESTV_formatNAMELIST:	/* FMT=FOO or NML=FOO [NAMELIST
3478*c87b03e5Sespie 				   /FOO/] */
3479*c87b03e5Sespie       ffeste_io_driver_ = NULL;	/* No start or driver function. */
3480*c87b03e5Sespie       start = FFECOM_gfrtSRSNE, end = FFECOM_gfrt;
3481*c87b03e5Sespie       break;
3482*c87b03e5Sespie 
3483*c87b03e5Sespie     default:
3484*c87b03e5Sespie       assert ("Weird stuff" == NULL);
3485*c87b03e5Sespie       start = FFECOM_gfrt, end = FFECOM_gfrt;
3486*c87b03e5Sespie       break;
3487*c87b03e5Sespie     }
3488*c87b03e5Sespie   ffeste_io_endgfrt_ = end;
3489*c87b03e5Sespie 
3490*c87b03e5Sespie #define specified(something) (info->read_spec[something].kw_or_val_present)
3491*c87b03e5Sespie 
3492*c87b03e5Sespie   iostat = specified (FFESTP_readixIOSTAT);
3493*c87b03e5Sespie   errl = specified (FFESTP_readixERR);
3494*c87b03e5Sespie   endl = specified (FFESTP_readixEND);
3495*c87b03e5Sespie 
3496*c87b03e5Sespie #undef specified
3497*c87b03e5Sespie 
3498*c87b03e5Sespie   ffeste_start_stmt_ ();
3499*c87b03e5Sespie 
3500*c87b03e5Sespie   if (errl)
3501*c87b03e5Sespie     {
3502*c87b03e5Sespie       /* Have ERR= specification.   */
3503*c87b03e5Sespie 
3504*c87b03e5Sespie       ffeste_io_err_
3505*c87b03e5Sespie 	= ffecom_lookup_label (info->read_spec[FFESTP_readixERR].u.label);
3506*c87b03e5Sespie 
3507*c87b03e5Sespie       if (endl)
3508*c87b03e5Sespie 	{
3509*c87b03e5Sespie 	  /* Have both ERR= and END=.  Need a temp label to handle both.  */
3510*c87b03e5Sespie 	  ffeste_io_end_
3511*c87b03e5Sespie 	    = ffecom_lookup_label (info->read_spec[FFESTP_readixEND].u.label);
3512*c87b03e5Sespie 	  ffeste_io_abort_is_temp_ = TRUE;
3513*c87b03e5Sespie 	  ffeste_io_abort_ = ffecom_temp_label ();
3514*c87b03e5Sespie 	}
3515*c87b03e5Sespie       else
3516*c87b03e5Sespie 	{
3517*c87b03e5Sespie 	  /* Have ERR= but no END=.  */
3518*c87b03e5Sespie 	  ffeste_io_end_ = NULL_TREE;
3519*c87b03e5Sespie 	  if ((ffeste_io_abort_is_temp_ = iostat))
3520*c87b03e5Sespie 	    ffeste_io_abort_ = ffecom_temp_label ();
3521*c87b03e5Sespie 	  else
3522*c87b03e5Sespie 	    ffeste_io_abort_ = ffeste_io_err_;
3523*c87b03e5Sespie 	}
3524*c87b03e5Sespie     }
3525*c87b03e5Sespie   else
3526*c87b03e5Sespie     {
3527*c87b03e5Sespie       /* No ERR= specification.  */
3528*c87b03e5Sespie 
3529*c87b03e5Sespie       ffeste_io_err_ = NULL_TREE;
3530*c87b03e5Sespie       if (endl)
3531*c87b03e5Sespie 	{
3532*c87b03e5Sespie 	  /* Have END= but no ERR=.  */
3533*c87b03e5Sespie 	  ffeste_io_end_
3534*c87b03e5Sespie 	    = ffecom_lookup_label (info->read_spec[FFESTP_readixEND].u.label);
3535*c87b03e5Sespie 	  if ((ffeste_io_abort_is_temp_ = iostat))
3536*c87b03e5Sespie 	    ffeste_io_abort_ = ffecom_temp_label ();
3537*c87b03e5Sespie 	  else
3538*c87b03e5Sespie 	    ffeste_io_abort_ = ffeste_io_end_;
3539*c87b03e5Sespie 	}
3540*c87b03e5Sespie       else
3541*c87b03e5Sespie 	{
3542*c87b03e5Sespie 	  /* Have no ERR= or END=.  */
3543*c87b03e5Sespie 
3544*c87b03e5Sespie 	  ffeste_io_end_ = NULL_TREE;
3545*c87b03e5Sespie 	  if ((ffeste_io_abort_is_temp_ = iostat))
3546*c87b03e5Sespie 	    ffeste_io_abort_ = ffecom_temp_label ();
3547*c87b03e5Sespie 	  else
3548*c87b03e5Sespie 	    ffeste_io_abort_ = NULL_TREE;
3549*c87b03e5Sespie 	}
3550*c87b03e5Sespie     }
3551*c87b03e5Sespie 
3552*c87b03e5Sespie   if (iostat)
3553*c87b03e5Sespie     {
3554*c87b03e5Sespie       /* Have IOSTAT= specification.  */
3555*c87b03e5Sespie 
3556*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
3557*c87b03e5Sespie       ffeste_io_iostat_
3558*c87b03e5Sespie 	= ffecom_expr (info->read_spec[FFESTP_readixIOSTAT].u.expr);
3559*c87b03e5Sespie     }
3560*c87b03e5Sespie   else if (ffeste_io_abort_ != NULL_TREE)
3561*c87b03e5Sespie     {
3562*c87b03e5Sespie       /* Have no IOSTAT= but have ERR= and/or END=.  */
3563*c87b03e5Sespie 
3564*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = TRUE;
3565*c87b03e5Sespie       ffeste_io_iostat_
3566*c87b03e5Sespie 	= ffecom_make_tempvar ("read", ffecom_integer_type_node,
3567*c87b03e5Sespie 			       FFETARGET_charactersizeNONE, -1);
3568*c87b03e5Sespie     }
3569*c87b03e5Sespie   else
3570*c87b03e5Sespie     {
3571*c87b03e5Sespie       /* No IOSTAT=, ERR=, or END= specification.  */
3572*c87b03e5Sespie 
3573*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
3574*c87b03e5Sespie       ffeste_io_iostat_ = NULL_TREE;
3575*c87b03e5Sespie     }
3576*c87b03e5Sespie 
3577*c87b03e5Sespie   /* Now prescan, then convert, all the arguments.  */
3578*c87b03e5Sespie 
3579*c87b03e5Sespie   if (unit == FFESTV_unitCHAREXPR)
3580*c87b03e5Sespie     cilist = ffeste_io_icilist_ (errl || iostat,
3581*c87b03e5Sespie 				 info->read_spec[FFESTP_readixUNIT].u.expr,
3582*c87b03e5Sespie 				 endl || iostat, format,
3583*c87b03e5Sespie 				 &info->read_spec[FFESTP_readixFORMAT]);
3584*c87b03e5Sespie   else
3585*c87b03e5Sespie     cilist = ffeste_io_cilist_ (errl || iostat, unit,
3586*c87b03e5Sespie 				info->read_spec[FFESTP_readixUNIT].u.expr,
3587*c87b03e5Sespie 				5, endl || iostat, format,
3588*c87b03e5Sespie 				&info->read_spec[FFESTP_readixFORMAT],
3589*c87b03e5Sespie 				rec,
3590*c87b03e5Sespie 				info->read_spec[FFESTP_readixREC].u.expr);
3591*c87b03e5Sespie 
3592*c87b03e5Sespie   /* If there is no end function, then there are no item functions (i.e.
3593*c87b03e5Sespie      it's a NAMELIST), and vice versa by the way.  In this situation, don't
3594*c87b03e5Sespie      generate the "if (iostat != 0) goto label;" if the label is temp abort
3595*c87b03e5Sespie      label, since we're gonna fall through to there anyway.  */
3596*c87b03e5Sespie 
3597*c87b03e5Sespie   ffeste_io_call_ (ffecom_call_gfrt (start, cilist, NULL_TREE),
3598*c87b03e5Sespie 		   (! ffeste_io_abort_is_temp_) || (end != FFECOM_gfrt));
3599*c87b03e5Sespie }
3600*c87b03e5Sespie 
3601*c87b03e5Sespie /* READ statement -- I/O item.  */
3602*c87b03e5Sespie 
3603*c87b03e5Sespie void
ffeste_R909_item(ffebld expr,ffelexToken expr_token)3604*c87b03e5Sespie ffeste_R909_item (ffebld expr, ffelexToken expr_token)
3605*c87b03e5Sespie {
3606*c87b03e5Sespie   ffeste_check_item_ ();
3607*c87b03e5Sespie 
3608*c87b03e5Sespie   if (expr == NULL)
3609*c87b03e5Sespie     return;
3610*c87b03e5Sespie 
3611*c87b03e5Sespie   /* Strip parens off items such as in "READ *,(A)".  This is really a bug
3612*c87b03e5Sespie      in the user's code, but I've been told lots of code does this.  */
3613*c87b03e5Sespie   while (ffebld_op (expr) == FFEBLD_opPAREN)
3614*c87b03e5Sespie     expr = ffebld_left (expr);
3615*c87b03e5Sespie 
3616*c87b03e5Sespie   if (ffebld_op (expr) == FFEBLD_opANY)
3617*c87b03e5Sespie     return;
3618*c87b03e5Sespie 
3619*c87b03e5Sespie   if (ffebld_op (expr) == FFEBLD_opIMPDO)
3620*c87b03e5Sespie     ffeste_io_impdo_ (expr, expr_token);
3621*c87b03e5Sespie   else
3622*c87b03e5Sespie     {
3623*c87b03e5Sespie       ffeste_start_stmt_ ();
3624*c87b03e5Sespie 
3625*c87b03e5Sespie       ffecom_prepare_arg_ptr_to_expr (expr);
3626*c87b03e5Sespie 
3627*c87b03e5Sespie       ffecom_prepare_end ();
3628*c87b03e5Sespie 
3629*c87b03e5Sespie       ffeste_io_call_ ((*ffeste_io_driver_) (expr), TRUE);
3630*c87b03e5Sespie 
3631*c87b03e5Sespie       ffeste_end_stmt_ ();
3632*c87b03e5Sespie     }
3633*c87b03e5Sespie }
3634*c87b03e5Sespie 
3635*c87b03e5Sespie /* READ statement -- end.  */
3636*c87b03e5Sespie 
3637*c87b03e5Sespie void
ffeste_R909_finish()3638*c87b03e5Sespie ffeste_R909_finish ()
3639*c87b03e5Sespie {
3640*c87b03e5Sespie   ffeste_check_finish_ ();
3641*c87b03e5Sespie 
3642*c87b03e5Sespie   /* Don't generate "if (iostat != 0) goto label;" if label is temp abort
3643*c87b03e5Sespie      label, since we're gonna fall through to there anyway. */
3644*c87b03e5Sespie 
3645*c87b03e5Sespie   if (ffeste_io_endgfrt_ != FFECOM_gfrt)
3646*c87b03e5Sespie     ffeste_io_call_ (ffecom_call_gfrt (ffeste_io_endgfrt_, NULL_TREE,
3647*c87b03e5Sespie 				       NULL_TREE),
3648*c87b03e5Sespie 		     ! ffeste_io_abort_is_temp_);
3649*c87b03e5Sespie 
3650*c87b03e5Sespie   /* If we've got a temp label, generate its code here and have it fan out
3651*c87b03e5Sespie      to the END= or ERR= label as appropriate. */
3652*c87b03e5Sespie 
3653*c87b03e5Sespie   if (ffeste_io_abort_is_temp_)
3654*c87b03e5Sespie     {
3655*c87b03e5Sespie       DECL_INITIAL (ffeste_io_abort_) = error_mark_node;
3656*c87b03e5Sespie       emit_nop ();
3657*c87b03e5Sespie       expand_label (ffeste_io_abort_);
3658*c87b03e5Sespie 
3659*c87b03e5Sespie       /* "if (iostat<0) goto end_label;".  */
3660*c87b03e5Sespie 
3661*c87b03e5Sespie       if ((ffeste_io_end_ != NULL_TREE)
3662*c87b03e5Sespie 	  && (TREE_CODE (ffeste_io_end_) != ERROR_MARK))
3663*c87b03e5Sespie 	{
3664*c87b03e5Sespie 	  expand_start_cond (ffecom_truth_value
3665*c87b03e5Sespie 			     (ffecom_2 (LT_EXPR, integer_type_node,
3666*c87b03e5Sespie 					ffeste_io_iostat_,
3667*c87b03e5Sespie 					ffecom_integer_zero_node)),
3668*c87b03e5Sespie 			     0);
3669*c87b03e5Sespie 	  expand_goto (ffeste_io_end_);
3670*c87b03e5Sespie 	  expand_end_cond ();
3671*c87b03e5Sespie 	}
3672*c87b03e5Sespie 
3673*c87b03e5Sespie       /* "if (iostat>0) goto err_label;".  */
3674*c87b03e5Sespie 
3675*c87b03e5Sespie       if ((ffeste_io_err_ != NULL_TREE)
3676*c87b03e5Sespie 	  && (TREE_CODE (ffeste_io_err_) != ERROR_MARK))
3677*c87b03e5Sespie 	{
3678*c87b03e5Sespie 	  expand_start_cond (ffecom_truth_value
3679*c87b03e5Sespie 			     (ffecom_2 (GT_EXPR, integer_type_node,
3680*c87b03e5Sespie 					ffeste_io_iostat_,
3681*c87b03e5Sespie 					ffecom_integer_zero_node)),
3682*c87b03e5Sespie 			     0);
3683*c87b03e5Sespie 	  expand_goto (ffeste_io_err_);
3684*c87b03e5Sespie 	  expand_end_cond ();
3685*c87b03e5Sespie 	}
3686*c87b03e5Sespie     }
3687*c87b03e5Sespie 
3688*c87b03e5Sespie   ffeste_end_stmt_ ();
3689*c87b03e5Sespie }
3690*c87b03e5Sespie 
3691*c87b03e5Sespie /* WRITE statement -- start.  */
3692*c87b03e5Sespie 
3693*c87b03e5Sespie void
ffeste_R910_start(ffestpWriteStmt * info,ffestvUnit unit,ffestvFormat format,bool rec)3694*c87b03e5Sespie ffeste_R910_start (ffestpWriteStmt *info, ffestvUnit unit,
3695*c87b03e5Sespie 		   ffestvFormat format, bool rec)
3696*c87b03e5Sespie {
3697*c87b03e5Sespie   ffecomGfrt start;
3698*c87b03e5Sespie   ffecomGfrt end;
3699*c87b03e5Sespie   tree cilist;
3700*c87b03e5Sespie   bool iostat;
3701*c87b03e5Sespie   bool errl;
3702*c87b03e5Sespie 
3703*c87b03e5Sespie   ffeste_check_start_ ();
3704*c87b03e5Sespie 
3705*c87b03e5Sespie   ffeste_emit_line_note_ ();
3706*c87b03e5Sespie 
3707*c87b03e5Sespie   /* First determine the start, per-item, and end run-time functions to
3708*c87b03e5Sespie      call.  The per-item function is picked by choosing an ffeste function
3709*c87b03e5Sespie      to call to handle a given item; it knows how to generate a call to the
3710*c87b03e5Sespie      appropriate run-time function, and is called an "I/O driver".  */
3711*c87b03e5Sespie 
3712*c87b03e5Sespie   switch (format)
3713*c87b03e5Sespie     {
3714*c87b03e5Sespie     case FFESTV_formatNONE:	/* no FMT= */
3715*c87b03e5Sespie       ffeste_io_driver_ = ffeste_io_douio_;
3716*c87b03e5Sespie       if (rec)
3717*c87b03e5Sespie 	start = FFECOM_gfrtSWDUE, end = FFECOM_gfrtEWDUE;
3718*c87b03e5Sespie       else
3719*c87b03e5Sespie 	start = FFECOM_gfrtSWSUE, end = FFECOM_gfrtEWSUE;
3720*c87b03e5Sespie       break;
3721*c87b03e5Sespie 
3722*c87b03e5Sespie     case FFESTV_formatLABEL:	/* FMT=10 */
3723*c87b03e5Sespie     case FFESTV_formatCHAREXPR:	/* FMT='(I10)' */
3724*c87b03e5Sespie     case FFESTV_formatINTEXPR:	/* FMT=I [after ASSIGN 10 TO I] */
3725*c87b03e5Sespie       ffeste_io_driver_ = ffeste_io_dofio_;
3726*c87b03e5Sespie       if (rec)
3727*c87b03e5Sespie 	start = FFECOM_gfrtSWDFE, end = FFECOM_gfrtEWDFE;
3728*c87b03e5Sespie       else if (unit == FFESTV_unitCHAREXPR)
3729*c87b03e5Sespie 	start = FFECOM_gfrtSWSFI, end = FFECOM_gfrtEWSFI;
3730*c87b03e5Sespie       else
3731*c87b03e5Sespie 	start = FFECOM_gfrtSWSFE, end = FFECOM_gfrtEWSFE;
3732*c87b03e5Sespie       break;
3733*c87b03e5Sespie 
3734*c87b03e5Sespie     case FFESTV_formatASTERISK:	/* FMT=* */
3735*c87b03e5Sespie       ffeste_io_driver_ = ffeste_io_dolio_;
3736*c87b03e5Sespie       if (unit == FFESTV_unitCHAREXPR)
3737*c87b03e5Sespie 	start = FFECOM_gfrtSWSLI, end = FFECOM_gfrtEWSLI;
3738*c87b03e5Sespie       else
3739*c87b03e5Sespie 	start = FFECOM_gfrtSWSLE, end = FFECOM_gfrtEWSLE;
3740*c87b03e5Sespie       break;
3741*c87b03e5Sespie 
3742*c87b03e5Sespie     case FFESTV_formatNAMELIST:	/* FMT=FOO or NML=FOO [NAMELIST
3743*c87b03e5Sespie 				   /FOO/] */
3744*c87b03e5Sespie       ffeste_io_driver_ = NULL;	/* No start or driver function. */
3745*c87b03e5Sespie       start = FFECOM_gfrtSWSNE, end = FFECOM_gfrt;
3746*c87b03e5Sespie       break;
3747*c87b03e5Sespie 
3748*c87b03e5Sespie     default:
3749*c87b03e5Sespie       assert ("Weird stuff" == NULL);
3750*c87b03e5Sespie       start = FFECOM_gfrt, end = FFECOM_gfrt;
3751*c87b03e5Sespie       break;
3752*c87b03e5Sespie     }
3753*c87b03e5Sespie   ffeste_io_endgfrt_ = end;
3754*c87b03e5Sespie 
3755*c87b03e5Sespie #define specified(something) (info->write_spec[something].kw_or_val_present)
3756*c87b03e5Sespie 
3757*c87b03e5Sespie   iostat = specified (FFESTP_writeixIOSTAT);
3758*c87b03e5Sespie   errl = specified (FFESTP_writeixERR);
3759*c87b03e5Sespie 
3760*c87b03e5Sespie #undef specified
3761*c87b03e5Sespie 
3762*c87b03e5Sespie   ffeste_start_stmt_ ();
3763*c87b03e5Sespie 
3764*c87b03e5Sespie   ffeste_io_end_ = NULL_TREE;
3765*c87b03e5Sespie 
3766*c87b03e5Sespie   if (errl)
3767*c87b03e5Sespie     {
3768*c87b03e5Sespie       /* Have ERR= specification.   */
3769*c87b03e5Sespie 
3770*c87b03e5Sespie       ffeste_io_err_
3771*c87b03e5Sespie 	= ffeste_io_abort_
3772*c87b03e5Sespie 	= ffecom_lookup_label
3773*c87b03e5Sespie 	(info->write_spec[FFESTP_writeixERR].u.label);
3774*c87b03e5Sespie       ffeste_io_abort_is_temp_ = FALSE;
3775*c87b03e5Sespie     }
3776*c87b03e5Sespie   else
3777*c87b03e5Sespie     {
3778*c87b03e5Sespie       /* No ERR= specification.  */
3779*c87b03e5Sespie 
3780*c87b03e5Sespie       ffeste_io_err_ = NULL_TREE;
3781*c87b03e5Sespie 
3782*c87b03e5Sespie       if ((ffeste_io_abort_is_temp_ = iostat))
3783*c87b03e5Sespie 	ffeste_io_abort_ = ffecom_temp_label ();
3784*c87b03e5Sespie       else
3785*c87b03e5Sespie 	ffeste_io_abort_ = NULL_TREE;
3786*c87b03e5Sespie     }
3787*c87b03e5Sespie 
3788*c87b03e5Sespie   if (iostat)
3789*c87b03e5Sespie     {
3790*c87b03e5Sespie       /* Have IOSTAT= specification.  */
3791*c87b03e5Sespie 
3792*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
3793*c87b03e5Sespie       ffeste_io_iostat_ = ffecom_expr
3794*c87b03e5Sespie 	(info->write_spec[FFESTP_writeixIOSTAT].u.expr);
3795*c87b03e5Sespie     }
3796*c87b03e5Sespie   else if (ffeste_io_abort_ != NULL_TREE)
3797*c87b03e5Sespie     {
3798*c87b03e5Sespie       /* Have no IOSTAT= but have ERR=.  */
3799*c87b03e5Sespie 
3800*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = TRUE;
3801*c87b03e5Sespie       ffeste_io_iostat_
3802*c87b03e5Sespie 	= ffecom_make_tempvar ("write", ffecom_integer_type_node,
3803*c87b03e5Sespie 			       FFETARGET_charactersizeNONE, -1);
3804*c87b03e5Sespie     }
3805*c87b03e5Sespie   else
3806*c87b03e5Sespie     {
3807*c87b03e5Sespie       /* No IOSTAT= or ERR= specification.  */
3808*c87b03e5Sespie 
3809*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
3810*c87b03e5Sespie       ffeste_io_iostat_ = NULL_TREE;
3811*c87b03e5Sespie     }
3812*c87b03e5Sespie 
3813*c87b03e5Sespie   /* Now prescan, then convert, all the arguments.  */
3814*c87b03e5Sespie 
3815*c87b03e5Sespie   if (unit == FFESTV_unitCHAREXPR)
3816*c87b03e5Sespie     cilist = ffeste_io_icilist_ (errl || iostat,
3817*c87b03e5Sespie 				 info->write_spec[FFESTP_writeixUNIT].u.expr,
3818*c87b03e5Sespie 				 FALSE, format,
3819*c87b03e5Sespie 				 &info->write_spec[FFESTP_writeixFORMAT]);
3820*c87b03e5Sespie   else
3821*c87b03e5Sespie     cilist = ffeste_io_cilist_ (errl || iostat, unit,
3822*c87b03e5Sespie 				info->write_spec[FFESTP_writeixUNIT].u.expr,
3823*c87b03e5Sespie 				6, FALSE, format,
3824*c87b03e5Sespie 				&info->write_spec[FFESTP_writeixFORMAT],
3825*c87b03e5Sespie 				rec,
3826*c87b03e5Sespie 				info->write_spec[FFESTP_writeixREC].u.expr);
3827*c87b03e5Sespie 
3828*c87b03e5Sespie   /* If there is no end function, then there are no item functions (i.e.
3829*c87b03e5Sespie      it's a NAMELIST), and vice versa by the way.  In this situation, don't
3830*c87b03e5Sespie      generate the "if (iostat != 0) goto label;" if the label is temp abort
3831*c87b03e5Sespie      label, since we're gonna fall through to there anyway.  */
3832*c87b03e5Sespie 
3833*c87b03e5Sespie   ffeste_io_call_ (ffecom_call_gfrt (start, cilist, NULL_TREE),
3834*c87b03e5Sespie 		   (! ffeste_io_abort_is_temp_) || (end != FFECOM_gfrt));
3835*c87b03e5Sespie }
3836*c87b03e5Sespie 
3837*c87b03e5Sespie /* WRITE statement -- I/O item.  */
3838*c87b03e5Sespie 
3839*c87b03e5Sespie void
ffeste_R910_item(ffebld expr,ffelexToken expr_token)3840*c87b03e5Sespie ffeste_R910_item (ffebld expr, ffelexToken expr_token)
3841*c87b03e5Sespie {
3842*c87b03e5Sespie   ffeste_check_item_ ();
3843*c87b03e5Sespie 
3844*c87b03e5Sespie   if (expr == NULL)
3845*c87b03e5Sespie     return;
3846*c87b03e5Sespie 
3847*c87b03e5Sespie   if (ffebld_op (expr) == FFEBLD_opANY)
3848*c87b03e5Sespie     return;
3849*c87b03e5Sespie 
3850*c87b03e5Sespie   if (ffebld_op (expr) == FFEBLD_opIMPDO)
3851*c87b03e5Sespie     ffeste_io_impdo_ (expr, expr_token);
3852*c87b03e5Sespie   else
3853*c87b03e5Sespie     {
3854*c87b03e5Sespie       ffeste_start_stmt_ ();
3855*c87b03e5Sespie 
3856*c87b03e5Sespie       ffecom_prepare_arg_ptr_to_expr (expr);
3857*c87b03e5Sespie 
3858*c87b03e5Sespie       ffecom_prepare_end ();
3859*c87b03e5Sespie 
3860*c87b03e5Sespie       ffeste_io_call_ ((*ffeste_io_driver_) (expr), TRUE);
3861*c87b03e5Sespie 
3862*c87b03e5Sespie       ffeste_end_stmt_ ();
3863*c87b03e5Sespie     }
3864*c87b03e5Sespie }
3865*c87b03e5Sespie 
3866*c87b03e5Sespie /* WRITE statement -- end.  */
3867*c87b03e5Sespie 
3868*c87b03e5Sespie void
ffeste_R910_finish()3869*c87b03e5Sespie ffeste_R910_finish ()
3870*c87b03e5Sespie {
3871*c87b03e5Sespie   ffeste_check_finish_ ();
3872*c87b03e5Sespie 
3873*c87b03e5Sespie   /* Don't generate "if (iostat != 0) goto label;" if label is temp abort
3874*c87b03e5Sespie      label, since we're gonna fall through to there anyway. */
3875*c87b03e5Sespie 
3876*c87b03e5Sespie   if (ffeste_io_endgfrt_ != FFECOM_gfrt)
3877*c87b03e5Sespie     ffeste_io_call_ (ffecom_call_gfrt (ffeste_io_endgfrt_, NULL_TREE,
3878*c87b03e5Sespie 				       NULL_TREE),
3879*c87b03e5Sespie 		     ! ffeste_io_abort_is_temp_);
3880*c87b03e5Sespie 
3881*c87b03e5Sespie   /* If we've got a temp label, generate its code here. */
3882*c87b03e5Sespie 
3883*c87b03e5Sespie   if (ffeste_io_abort_is_temp_)
3884*c87b03e5Sespie     {
3885*c87b03e5Sespie       DECL_INITIAL (ffeste_io_abort_) = error_mark_node;
3886*c87b03e5Sespie       emit_nop ();
3887*c87b03e5Sespie       expand_label (ffeste_io_abort_);
3888*c87b03e5Sespie 
3889*c87b03e5Sespie       assert (ffeste_io_err_ == NULL_TREE);
3890*c87b03e5Sespie     }
3891*c87b03e5Sespie 
3892*c87b03e5Sespie   ffeste_end_stmt_ ();
3893*c87b03e5Sespie }
3894*c87b03e5Sespie 
3895*c87b03e5Sespie /* PRINT statement -- start.  */
3896*c87b03e5Sespie 
3897*c87b03e5Sespie void
ffeste_R911_start(ffestpPrintStmt * info,ffestvFormat format)3898*c87b03e5Sespie ffeste_R911_start (ffestpPrintStmt *info, ffestvFormat format)
3899*c87b03e5Sespie {
3900*c87b03e5Sespie   ffecomGfrt start;
3901*c87b03e5Sespie   ffecomGfrt end;
3902*c87b03e5Sespie   tree cilist;
3903*c87b03e5Sespie 
3904*c87b03e5Sespie   ffeste_check_start_ ();
3905*c87b03e5Sespie 
3906*c87b03e5Sespie   ffeste_emit_line_note_ ();
3907*c87b03e5Sespie 
3908*c87b03e5Sespie   /* First determine the start, per-item, and end run-time functions to
3909*c87b03e5Sespie      call.  The per-item function is picked by choosing an ffeste function
3910*c87b03e5Sespie      to call to handle a given item; it knows how to generate a call to the
3911*c87b03e5Sespie      appropriate run-time function, and is called an "I/O driver".  */
3912*c87b03e5Sespie 
3913*c87b03e5Sespie   switch (format)
3914*c87b03e5Sespie     {
3915*c87b03e5Sespie     case FFESTV_formatLABEL:	/* FMT=10 */
3916*c87b03e5Sespie     case FFESTV_formatCHAREXPR:	/* FMT='(I10)' */
3917*c87b03e5Sespie     case FFESTV_formatINTEXPR:	/* FMT=I [after ASSIGN 10 TO I] */
3918*c87b03e5Sespie       ffeste_io_driver_ = ffeste_io_dofio_;
3919*c87b03e5Sespie       start = FFECOM_gfrtSWSFE, end = FFECOM_gfrtEWSFE;
3920*c87b03e5Sespie       break;
3921*c87b03e5Sespie 
3922*c87b03e5Sespie     case FFESTV_formatASTERISK:	/* FMT=* */
3923*c87b03e5Sespie       ffeste_io_driver_ = ffeste_io_dolio_;
3924*c87b03e5Sespie       start = FFECOM_gfrtSWSLE, end = FFECOM_gfrtEWSLE;
3925*c87b03e5Sespie       break;
3926*c87b03e5Sespie 
3927*c87b03e5Sespie     case FFESTV_formatNAMELIST:	/* FMT=FOO or NML=FOO [NAMELIST
3928*c87b03e5Sespie 				   /FOO/] */
3929*c87b03e5Sespie       ffeste_io_driver_ = NULL;	/* No start or driver function. */
3930*c87b03e5Sespie       start = FFECOM_gfrtSWSNE, end = FFECOM_gfrt;
3931*c87b03e5Sespie       break;
3932*c87b03e5Sespie 
3933*c87b03e5Sespie     default:
3934*c87b03e5Sespie       assert ("Weird stuff" == NULL);
3935*c87b03e5Sespie       start = FFECOM_gfrt, end = FFECOM_gfrt;
3936*c87b03e5Sespie       break;
3937*c87b03e5Sespie     }
3938*c87b03e5Sespie   ffeste_io_endgfrt_ = end;
3939*c87b03e5Sespie 
3940*c87b03e5Sespie   ffeste_start_stmt_ ();
3941*c87b03e5Sespie 
3942*c87b03e5Sespie   ffeste_io_end_ = NULL_TREE;
3943*c87b03e5Sespie   ffeste_io_err_ = NULL_TREE;
3944*c87b03e5Sespie   ffeste_io_abort_ = NULL_TREE;
3945*c87b03e5Sespie   ffeste_io_abort_is_temp_ = FALSE;
3946*c87b03e5Sespie   ffeste_io_iostat_is_temp_ = FALSE;
3947*c87b03e5Sespie   ffeste_io_iostat_ = NULL_TREE;
3948*c87b03e5Sespie 
3949*c87b03e5Sespie   /* Now prescan, then convert, all the arguments.  */
3950*c87b03e5Sespie 
3951*c87b03e5Sespie   cilist = ffeste_io_cilist_ (FALSE, FFESTV_unitNONE, NULL, 6, FALSE, format,
3952*c87b03e5Sespie 			      &info->print_spec[FFESTP_printixFORMAT],
3953*c87b03e5Sespie 			      FALSE, NULL);
3954*c87b03e5Sespie 
3955*c87b03e5Sespie   /* If there is no end function, then there are no item functions (i.e.
3956*c87b03e5Sespie      it's a NAMELIST), and vice versa by the way.  In this situation, don't
3957*c87b03e5Sespie      generate the "if (iostat != 0) goto label;" if the label is temp abort
3958*c87b03e5Sespie      label, since we're gonna fall through to there anyway.  */
3959*c87b03e5Sespie 
3960*c87b03e5Sespie   ffeste_io_call_ (ffecom_call_gfrt (start, cilist, NULL_TREE),
3961*c87b03e5Sespie 		   (! ffeste_io_abort_is_temp_) || (end != FFECOM_gfrt));
3962*c87b03e5Sespie }
3963*c87b03e5Sespie 
3964*c87b03e5Sespie /* PRINT statement -- I/O item.  */
3965*c87b03e5Sespie 
3966*c87b03e5Sespie void
ffeste_R911_item(ffebld expr,ffelexToken expr_token)3967*c87b03e5Sespie ffeste_R911_item (ffebld expr, ffelexToken expr_token)
3968*c87b03e5Sespie {
3969*c87b03e5Sespie   ffeste_check_item_ ();
3970*c87b03e5Sespie 
3971*c87b03e5Sespie   if (expr == NULL)
3972*c87b03e5Sespie     return;
3973*c87b03e5Sespie 
3974*c87b03e5Sespie   if (ffebld_op (expr) == FFEBLD_opANY)
3975*c87b03e5Sespie     return;
3976*c87b03e5Sespie 
3977*c87b03e5Sespie   if (ffebld_op (expr) == FFEBLD_opIMPDO)
3978*c87b03e5Sespie     ffeste_io_impdo_ (expr, expr_token);
3979*c87b03e5Sespie   else
3980*c87b03e5Sespie     {
3981*c87b03e5Sespie       ffeste_start_stmt_ ();
3982*c87b03e5Sespie 
3983*c87b03e5Sespie       ffecom_prepare_arg_ptr_to_expr (expr);
3984*c87b03e5Sespie 
3985*c87b03e5Sespie       ffecom_prepare_end ();
3986*c87b03e5Sespie 
3987*c87b03e5Sespie       ffeste_io_call_ ((*ffeste_io_driver_) (expr), TRUE);
3988*c87b03e5Sespie 
3989*c87b03e5Sespie       ffeste_end_stmt_ ();
3990*c87b03e5Sespie     }
3991*c87b03e5Sespie }
3992*c87b03e5Sespie 
3993*c87b03e5Sespie /* PRINT statement -- end.  */
3994*c87b03e5Sespie 
3995*c87b03e5Sespie void
ffeste_R911_finish()3996*c87b03e5Sespie ffeste_R911_finish ()
3997*c87b03e5Sespie {
3998*c87b03e5Sespie   ffeste_check_finish_ ();
3999*c87b03e5Sespie 
4000*c87b03e5Sespie   if (ffeste_io_endgfrt_ != FFECOM_gfrt)
4001*c87b03e5Sespie     ffeste_io_call_ (ffecom_call_gfrt (ffeste_io_endgfrt_, NULL_TREE,
4002*c87b03e5Sespie 				       NULL_TREE),
4003*c87b03e5Sespie 		     FALSE);
4004*c87b03e5Sespie 
4005*c87b03e5Sespie   ffeste_end_stmt_ ();
4006*c87b03e5Sespie }
4007*c87b03e5Sespie 
4008*c87b03e5Sespie /* BACKSPACE statement.  */
4009*c87b03e5Sespie 
4010*c87b03e5Sespie void
ffeste_R919(ffestpBeruStmt * info)4011*c87b03e5Sespie ffeste_R919 (ffestpBeruStmt *info)
4012*c87b03e5Sespie {
4013*c87b03e5Sespie   ffeste_check_simple_ ();
4014*c87b03e5Sespie 
4015*c87b03e5Sespie   ffeste_subr_beru_ (info, FFECOM_gfrtFBACK);
4016*c87b03e5Sespie }
4017*c87b03e5Sespie 
4018*c87b03e5Sespie /* ENDFILE statement.  */
4019*c87b03e5Sespie 
4020*c87b03e5Sespie void
ffeste_R920(ffestpBeruStmt * info)4021*c87b03e5Sespie ffeste_R920 (ffestpBeruStmt *info)
4022*c87b03e5Sespie {
4023*c87b03e5Sespie   ffeste_check_simple_ ();
4024*c87b03e5Sespie 
4025*c87b03e5Sespie   ffeste_subr_beru_ (info, FFECOM_gfrtFEND);
4026*c87b03e5Sespie }
4027*c87b03e5Sespie 
4028*c87b03e5Sespie /* REWIND statement.  */
4029*c87b03e5Sespie 
4030*c87b03e5Sespie void
ffeste_R921(ffestpBeruStmt * info)4031*c87b03e5Sespie ffeste_R921 (ffestpBeruStmt *info)
4032*c87b03e5Sespie {
4033*c87b03e5Sespie   ffeste_check_simple_ ();
4034*c87b03e5Sespie 
4035*c87b03e5Sespie   ffeste_subr_beru_ (info, FFECOM_gfrtFREW);
4036*c87b03e5Sespie }
4037*c87b03e5Sespie 
4038*c87b03e5Sespie /* INQUIRE statement (non-IOLENGTH version).  */
4039*c87b03e5Sespie 
4040*c87b03e5Sespie void
ffeste_R923A(ffestpInquireStmt * info,bool by_file UNUSED)4041*c87b03e5Sespie ffeste_R923A (ffestpInquireStmt *info, bool by_file UNUSED)
4042*c87b03e5Sespie {
4043*c87b03e5Sespie   tree args;
4044*c87b03e5Sespie   bool iostat;
4045*c87b03e5Sespie   bool errl;
4046*c87b03e5Sespie 
4047*c87b03e5Sespie   ffeste_check_simple_ ();
4048*c87b03e5Sespie 
4049*c87b03e5Sespie   ffeste_emit_line_note_ ();
4050*c87b03e5Sespie 
4051*c87b03e5Sespie #define specified(something) (info->inquire_spec[something].kw_or_val_present)
4052*c87b03e5Sespie 
4053*c87b03e5Sespie   iostat = specified (FFESTP_inquireixIOSTAT);
4054*c87b03e5Sespie   errl = specified (FFESTP_inquireixERR);
4055*c87b03e5Sespie 
4056*c87b03e5Sespie #undef specified
4057*c87b03e5Sespie 
4058*c87b03e5Sespie   ffeste_start_stmt_ ();
4059*c87b03e5Sespie 
4060*c87b03e5Sespie   if (errl)
4061*c87b03e5Sespie     {
4062*c87b03e5Sespie       ffeste_io_err_
4063*c87b03e5Sespie 	= ffeste_io_abort_
4064*c87b03e5Sespie 	= ffecom_lookup_label
4065*c87b03e5Sespie 	(info->inquire_spec[FFESTP_inquireixERR].u.label);
4066*c87b03e5Sespie       ffeste_io_abort_is_temp_ = FALSE;
4067*c87b03e5Sespie     }
4068*c87b03e5Sespie   else
4069*c87b03e5Sespie     {
4070*c87b03e5Sespie       ffeste_io_err_ = NULL_TREE;
4071*c87b03e5Sespie 
4072*c87b03e5Sespie       if ((ffeste_io_abort_is_temp_ = iostat))
4073*c87b03e5Sespie 	ffeste_io_abort_ = ffecom_temp_label ();
4074*c87b03e5Sespie       else
4075*c87b03e5Sespie 	ffeste_io_abort_ = NULL_TREE;
4076*c87b03e5Sespie     }
4077*c87b03e5Sespie 
4078*c87b03e5Sespie   if (iostat)
4079*c87b03e5Sespie     {
4080*c87b03e5Sespie       /* Have IOSTAT= specification.  */
4081*c87b03e5Sespie 
4082*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
4083*c87b03e5Sespie       ffeste_io_iostat_ = ffecom_expr
4084*c87b03e5Sespie 	(info->inquire_spec[FFESTP_inquireixIOSTAT].u.expr);
4085*c87b03e5Sespie     }
4086*c87b03e5Sespie   else if (ffeste_io_abort_ != NULL_TREE)
4087*c87b03e5Sespie     {
4088*c87b03e5Sespie       /* Have no IOSTAT= but have ERR=.  */
4089*c87b03e5Sespie 
4090*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = TRUE;
4091*c87b03e5Sespie       ffeste_io_iostat_
4092*c87b03e5Sespie 	= ffecom_make_tempvar ("inquire", ffecom_integer_type_node,
4093*c87b03e5Sespie 			       FFETARGET_charactersizeNONE, -1);
4094*c87b03e5Sespie     }
4095*c87b03e5Sespie   else
4096*c87b03e5Sespie     {
4097*c87b03e5Sespie       /* No IOSTAT= or ERR= specification.  */
4098*c87b03e5Sespie 
4099*c87b03e5Sespie       ffeste_io_iostat_is_temp_ = FALSE;
4100*c87b03e5Sespie       ffeste_io_iostat_ = NULL_TREE;
4101*c87b03e5Sespie     }
4102*c87b03e5Sespie 
4103*c87b03e5Sespie   /* Now prescan, then convert, all the arguments.  */
4104*c87b03e5Sespie 
4105*c87b03e5Sespie   args
4106*c87b03e5Sespie     = ffeste_io_inlist_ (errl || iostat,
4107*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixUNIT],
4108*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixFILE],
4109*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixEXIST],
4110*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixOPENED],
4111*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixNUMBER],
4112*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixNAMED],
4113*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixNAME],
4114*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixACCESS],
4115*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixSEQUENTIAL],
4116*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixDIRECT],
4117*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixFORM],
4118*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixFORMATTED],
4119*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixUNFORMATTED],
4120*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixRECL],
4121*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixNEXTREC],
4122*c87b03e5Sespie 			 &info->inquire_spec[FFESTP_inquireixBLANK]);
4123*c87b03e5Sespie 
4124*c87b03e5Sespie   /* Don't generate "if (iostat != 0) goto label;" if label is temp abort
4125*c87b03e5Sespie      label, since we're gonna fall through to there anyway. */
4126*c87b03e5Sespie 
4127*c87b03e5Sespie   ffeste_io_call_ (ffecom_call_gfrt (FFECOM_gfrtFINQU, args, NULL_TREE),
4128*c87b03e5Sespie 		   ! ffeste_io_abort_is_temp_);
4129*c87b03e5Sespie 
4130*c87b03e5Sespie   /* If we've got a temp label, generate its code here.  */
4131*c87b03e5Sespie 
4132*c87b03e5Sespie   if (ffeste_io_abort_is_temp_)
4133*c87b03e5Sespie     {
4134*c87b03e5Sespie       DECL_INITIAL (ffeste_io_abort_) = error_mark_node;
4135*c87b03e5Sespie       emit_nop ();
4136*c87b03e5Sespie       expand_label (ffeste_io_abort_);
4137*c87b03e5Sespie 
4138*c87b03e5Sespie       assert (ffeste_io_err_ == NULL_TREE);
4139*c87b03e5Sespie     }
4140*c87b03e5Sespie 
4141*c87b03e5Sespie   ffeste_end_stmt_ ();
4142*c87b03e5Sespie }
4143*c87b03e5Sespie 
4144*c87b03e5Sespie /* INQUIRE(IOLENGTH=expr) statement -- start.  */
4145*c87b03e5Sespie 
4146*c87b03e5Sespie void
ffeste_R923B_start(ffestpInquireStmt * info UNUSED)4147*c87b03e5Sespie ffeste_R923B_start (ffestpInquireStmt *info UNUSED)
4148*c87b03e5Sespie {
4149*c87b03e5Sespie   ffeste_check_start_ ();
4150*c87b03e5Sespie 
4151*c87b03e5Sespie   assert ("INQUIRE(IOLENGTH=<var>) not implemented yet! ~~~" == NULL);
4152*c87b03e5Sespie 
4153*c87b03e5Sespie   ffeste_emit_line_note_ ();
4154*c87b03e5Sespie }
4155*c87b03e5Sespie 
4156*c87b03e5Sespie /* INQUIRE(IOLENGTH=expr) statement -- I/O item.  */
4157*c87b03e5Sespie 
4158*c87b03e5Sespie void
ffeste_R923B_item(ffebld expr UNUSED)4159*c87b03e5Sespie ffeste_R923B_item (ffebld expr UNUSED)
4160*c87b03e5Sespie {
4161*c87b03e5Sespie   ffeste_check_item_ ();
4162*c87b03e5Sespie }
4163*c87b03e5Sespie 
4164*c87b03e5Sespie /* INQUIRE(IOLENGTH=expr) statement -- end.  */
4165*c87b03e5Sespie 
4166*c87b03e5Sespie void
ffeste_R923B_finish()4167*c87b03e5Sespie ffeste_R923B_finish ()
4168*c87b03e5Sespie {
4169*c87b03e5Sespie   ffeste_check_finish_ ();
4170*c87b03e5Sespie }
4171*c87b03e5Sespie 
4172*c87b03e5Sespie /* ffeste_R1001 -- FORMAT statement
4173*c87b03e5Sespie 
4174*c87b03e5Sespie    ffeste_R1001(format_list);  */
4175*c87b03e5Sespie 
4176*c87b03e5Sespie void
ffeste_R1001(ffests s)4177*c87b03e5Sespie ffeste_R1001 (ffests s)
4178*c87b03e5Sespie {
4179*c87b03e5Sespie   tree t;
4180*c87b03e5Sespie   tree ttype;
4181*c87b03e5Sespie   tree maxindex;
4182*c87b03e5Sespie   tree var;
4183*c87b03e5Sespie 
4184*c87b03e5Sespie   ffeste_check_simple_ ();
4185*c87b03e5Sespie 
4186*c87b03e5Sespie   assert (ffeste_label_formatdef_ != NULL);
4187*c87b03e5Sespie 
4188*c87b03e5Sespie   ffeste_emit_line_note_ ();
4189*c87b03e5Sespie 
4190*c87b03e5Sespie   t = build_string (ffests_length (s), ffests_text (s));
4191*c87b03e5Sespie 
4192*c87b03e5Sespie   TREE_TYPE (t)
4193*c87b03e5Sespie     = build_type_variant (build_array_type
4194*c87b03e5Sespie 			  (char_type_node,
4195*c87b03e5Sespie 			   build_range_type (integer_type_node,
4196*c87b03e5Sespie 					     integer_one_node,
4197*c87b03e5Sespie 					     build_int_2 (ffests_length (s),
4198*c87b03e5Sespie 							  0))),
4199*c87b03e5Sespie 			  1, 0);
4200*c87b03e5Sespie   TREE_CONSTANT (t) = 1;
4201*c87b03e5Sespie   TREE_STATIC (t) = 1;
4202*c87b03e5Sespie 
4203*c87b03e5Sespie   var = ffecom_lookup_label (ffeste_label_formatdef_);
4204*c87b03e5Sespie   if ((var != NULL_TREE)
4205*c87b03e5Sespie       && (TREE_CODE (var) == VAR_DECL))
4206*c87b03e5Sespie     {
4207*c87b03e5Sespie       DECL_INITIAL (var) = t;
4208*c87b03e5Sespie       maxindex = build_int_2 (ffests_length (s) - 1, 0);
4209*c87b03e5Sespie       ttype = TREE_TYPE (var);
4210*c87b03e5Sespie       TYPE_DOMAIN (ttype) = build_range_type (integer_type_node,
4211*c87b03e5Sespie 					      integer_zero_node,
4212*c87b03e5Sespie 					      maxindex);
4213*c87b03e5Sespie       if (!TREE_TYPE (maxindex))
4214*c87b03e5Sespie 	TREE_TYPE (maxindex) = TYPE_DOMAIN (ttype);
4215*c87b03e5Sespie       layout_type (ttype);
4216*c87b03e5Sespie       rest_of_decl_compilation (var, NULL, 1, 0);
4217*c87b03e5Sespie       expand_decl (var);
4218*c87b03e5Sespie       expand_decl_init (var);
4219*c87b03e5Sespie     }
4220*c87b03e5Sespie 
4221*c87b03e5Sespie   ffeste_label_formatdef_ = NULL;
4222*c87b03e5Sespie }
4223*c87b03e5Sespie 
4224*c87b03e5Sespie /* END PROGRAM.  */
4225*c87b03e5Sespie 
4226*c87b03e5Sespie void
ffeste_R1103()4227*c87b03e5Sespie ffeste_R1103 ()
4228*c87b03e5Sespie {
4229*c87b03e5Sespie }
4230*c87b03e5Sespie 
4231*c87b03e5Sespie /* END BLOCK DATA.  */
4232*c87b03e5Sespie 
4233*c87b03e5Sespie void
ffeste_R1112()4234*c87b03e5Sespie ffeste_R1112 ()
4235*c87b03e5Sespie {
4236*c87b03e5Sespie }
4237*c87b03e5Sespie 
4238*c87b03e5Sespie /* CALL statement.  */
4239*c87b03e5Sespie 
4240*c87b03e5Sespie void
ffeste_R1212(ffebld expr)4241*c87b03e5Sespie ffeste_R1212 (ffebld expr)
4242*c87b03e5Sespie {
4243*c87b03e5Sespie   ffebld args;
4244*c87b03e5Sespie   ffebld arg;
4245*c87b03e5Sespie   ffebld labels = NULL;	/* First in list of LABTERs. */
4246*c87b03e5Sespie   ffebld prevlabels = NULL;
4247*c87b03e5Sespie   ffebld prevargs = NULL;
4248*c87b03e5Sespie 
4249*c87b03e5Sespie   ffeste_check_simple_ ();
4250*c87b03e5Sespie 
4251*c87b03e5Sespie   args = ffebld_right (expr);
4252*c87b03e5Sespie 
4253*c87b03e5Sespie   ffeste_emit_line_note_ ();
4254*c87b03e5Sespie 
4255*c87b03e5Sespie   /* Here we split the list at ffebld_right(expr) into two lists: one at
4256*c87b03e5Sespie      ffebld_right(expr) consisting of all items that are not LABTERs, the
4257*c87b03e5Sespie      other at labels consisting of all items that are LABTERs.  Then, if
4258*c87b03e5Sespie      the latter list is NULL, we have an ordinary call, else we have a call
4259*c87b03e5Sespie      with alternate returns. */
4260*c87b03e5Sespie 
4261*c87b03e5Sespie   for (args = ffebld_right (expr); args != NULL; args = ffebld_trail (args))
4262*c87b03e5Sespie     {
4263*c87b03e5Sespie       if (((arg = ffebld_head (args)) == NULL)
4264*c87b03e5Sespie 	  || (ffebld_op (arg) != FFEBLD_opLABTER))
4265*c87b03e5Sespie 	{
4266*c87b03e5Sespie 	  if (prevargs == NULL)
4267*c87b03e5Sespie 	    {
4268*c87b03e5Sespie 	      prevargs = args;
4269*c87b03e5Sespie 	      ffebld_set_right (expr, args);
4270*c87b03e5Sespie 	    }
4271*c87b03e5Sespie 	  else
4272*c87b03e5Sespie 	    {
4273*c87b03e5Sespie 	      ffebld_set_trail (prevargs, args);
4274*c87b03e5Sespie 	      prevargs = args;
4275*c87b03e5Sespie 	    }
4276*c87b03e5Sespie 	}
4277*c87b03e5Sespie       else
4278*c87b03e5Sespie 	{
4279*c87b03e5Sespie 	  if (prevlabels == NULL)
4280*c87b03e5Sespie 	    {
4281*c87b03e5Sespie 	      prevlabels = labels = args;
4282*c87b03e5Sespie 	    }
4283*c87b03e5Sespie 	  else
4284*c87b03e5Sespie 	    {
4285*c87b03e5Sespie 	      ffebld_set_trail (prevlabels, args);
4286*c87b03e5Sespie 	      prevlabels = args;
4287*c87b03e5Sespie 	    }
4288*c87b03e5Sespie 	}
4289*c87b03e5Sespie     }
4290*c87b03e5Sespie   if (prevlabels == NULL)
4291*c87b03e5Sespie     labels = NULL;
4292*c87b03e5Sespie   else
4293*c87b03e5Sespie     ffebld_set_trail (prevlabels, NULL);
4294*c87b03e5Sespie   if (prevargs == NULL)
4295*c87b03e5Sespie     ffebld_set_right (expr, NULL);
4296*c87b03e5Sespie   else
4297*c87b03e5Sespie     ffebld_set_trail (prevargs, NULL);
4298*c87b03e5Sespie 
4299*c87b03e5Sespie   ffeste_start_stmt_ ();
4300*c87b03e5Sespie 
4301*c87b03e5Sespie   /* No temporaries are actually needed at this level, but we go
4302*c87b03e5Sespie      through the motions anyway, just to be sure in case they do
4303*c87b03e5Sespie      get made.  Temporaries needed for arguments should be in the
4304*c87b03e5Sespie      scopes of inner blocks, and if clean-up actions are supported,
4305*c87b03e5Sespie      such as CALL-ing an intrinsic that writes to an argument of one
4306*c87b03e5Sespie      type when a variable of a different type is provided (requiring
4307*c87b03e5Sespie      assignment to the variable from a temporary after the library
4308*c87b03e5Sespie      routine returns), the clean-up must be done by the expression
4309*c87b03e5Sespie      evaluator, generally, to handle alternate returns (which we hope
4310*c87b03e5Sespie      won't ever be supported by intrinsics, but might be a similar
4311*c87b03e5Sespie      issue, such as CALL-ing an F90-style subroutine with an INTERFACE
4312*c87b03e5Sespie      block).  That implies the expression evaluator will have to
4313*c87b03e5Sespie      recognize the need for its own temporary anyway, meaning it'll
4314*c87b03e5Sespie      construct a block within the one constructed here.  */
4315*c87b03e5Sespie 
4316*c87b03e5Sespie   ffecom_prepare_expr (expr);
4317*c87b03e5Sespie 
4318*c87b03e5Sespie   ffecom_prepare_end ();
4319*c87b03e5Sespie 
4320*c87b03e5Sespie   if (labels == NULL)
4321*c87b03e5Sespie     expand_expr_stmt (ffecom_expr (expr));
4322*c87b03e5Sespie   else
4323*c87b03e5Sespie     {
4324*c87b03e5Sespie       tree texpr;
4325*c87b03e5Sespie       tree value;
4326*c87b03e5Sespie       tree tlabel;
4327*c87b03e5Sespie       int caseno;
4328*c87b03e5Sespie       int pushok;
4329*c87b03e5Sespie       tree duplicate;
4330*c87b03e5Sespie       ffebld label;
4331*c87b03e5Sespie 
4332*c87b03e5Sespie       texpr = ffecom_expr (expr);
4333*c87b03e5Sespie       expand_start_case (0, texpr, TREE_TYPE (texpr), "CALL statement");
4334*c87b03e5Sespie 
4335*c87b03e5Sespie       for (caseno = 1, label = labels;
4336*c87b03e5Sespie 	   label != NULL;
4337*c87b03e5Sespie 	   ++caseno, label = ffebld_trail (label))
4338*c87b03e5Sespie 	{
4339*c87b03e5Sespie 	  value = build_int_2 (caseno, 0);
4340*c87b03e5Sespie 	  tlabel = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
4341*c87b03e5Sespie 
4342*c87b03e5Sespie 	  pushok = pushcase (value, convert, tlabel, &duplicate);
4343*c87b03e5Sespie 	  assert (pushok == 0);
4344*c87b03e5Sespie 
4345*c87b03e5Sespie 	  tlabel
4346*c87b03e5Sespie 	    = ffecom_lookup_label (ffebld_labter (ffebld_head (label)));
4347*c87b03e5Sespie 	  if ((tlabel == NULL_TREE)
4348*c87b03e5Sespie 	      || (TREE_CODE (tlabel) == ERROR_MARK))
4349*c87b03e5Sespie 	    continue;
4350*c87b03e5Sespie 	  TREE_USED (tlabel) = 1;
4351*c87b03e5Sespie 	  expand_goto (tlabel);
4352*c87b03e5Sespie 	}
4353*c87b03e5Sespie 
4354*c87b03e5Sespie       expand_end_case (texpr);
4355*c87b03e5Sespie     }
4356*c87b03e5Sespie 
4357*c87b03e5Sespie   ffeste_end_stmt_ ();
4358*c87b03e5Sespie }
4359*c87b03e5Sespie 
4360*c87b03e5Sespie /* END FUNCTION.  */
4361*c87b03e5Sespie 
4362*c87b03e5Sespie void
ffeste_R1221()4363*c87b03e5Sespie ffeste_R1221 ()
4364*c87b03e5Sespie {
4365*c87b03e5Sespie }
4366*c87b03e5Sespie 
4367*c87b03e5Sespie /* END SUBROUTINE.  */
4368*c87b03e5Sespie 
4369*c87b03e5Sespie void
ffeste_R1225()4370*c87b03e5Sespie ffeste_R1225 ()
4371*c87b03e5Sespie {
4372*c87b03e5Sespie }
4373*c87b03e5Sespie 
4374*c87b03e5Sespie /* ENTRY statement.  */
4375*c87b03e5Sespie 
4376*c87b03e5Sespie void
ffeste_R1226(ffesymbol entry)4377*c87b03e5Sespie ffeste_R1226 (ffesymbol entry)
4378*c87b03e5Sespie {
4379*c87b03e5Sespie   tree label;
4380*c87b03e5Sespie 
4381*c87b03e5Sespie   ffeste_check_simple_ ();
4382*c87b03e5Sespie 
4383*c87b03e5Sespie   label = ffesymbol_hook (entry).length_tree;
4384*c87b03e5Sespie 
4385*c87b03e5Sespie   ffeste_emit_line_note_ ();
4386*c87b03e5Sespie 
4387*c87b03e5Sespie   if (label == error_mark_node)
4388*c87b03e5Sespie     return;
4389*c87b03e5Sespie 
4390*c87b03e5Sespie   DECL_INITIAL (label) = error_mark_node;
4391*c87b03e5Sespie   emit_nop ();
4392*c87b03e5Sespie   expand_label (label);
4393*c87b03e5Sespie }
4394*c87b03e5Sespie 
4395*c87b03e5Sespie /* RETURN statement.  */
4396*c87b03e5Sespie 
4397*c87b03e5Sespie void
ffeste_R1227(ffestw block UNUSED,ffebld expr)4398*c87b03e5Sespie ffeste_R1227 (ffestw block UNUSED, ffebld expr)
4399*c87b03e5Sespie {
4400*c87b03e5Sespie   tree rtn;
4401*c87b03e5Sespie 
4402*c87b03e5Sespie   ffeste_check_simple_ ();
4403*c87b03e5Sespie 
4404*c87b03e5Sespie   ffeste_emit_line_note_ ();
4405*c87b03e5Sespie 
4406*c87b03e5Sespie   ffeste_start_stmt_ ();
4407*c87b03e5Sespie 
4408*c87b03e5Sespie   ffecom_prepare_return_expr (expr);
4409*c87b03e5Sespie 
4410*c87b03e5Sespie   ffecom_prepare_end ();
4411*c87b03e5Sespie 
4412*c87b03e5Sespie   rtn = ffecom_return_expr (expr);
4413*c87b03e5Sespie 
4414*c87b03e5Sespie   if ((rtn == NULL_TREE)
4415*c87b03e5Sespie       || (rtn == error_mark_node))
4416*c87b03e5Sespie     expand_null_return ();
4417*c87b03e5Sespie   else
4418*c87b03e5Sespie     {
4419*c87b03e5Sespie       tree result = DECL_RESULT (current_function_decl);
4420*c87b03e5Sespie 
4421*c87b03e5Sespie       if ((result != error_mark_node)
4422*c87b03e5Sespie 	  && (TREE_TYPE (result) != error_mark_node))
4423*c87b03e5Sespie 	expand_return (ffecom_modify (NULL_TREE,
4424*c87b03e5Sespie 				      result,
4425*c87b03e5Sespie 				      convert (TREE_TYPE (result),
4426*c87b03e5Sespie 					       rtn)));
4427*c87b03e5Sespie       else
4428*c87b03e5Sespie 	expand_null_return ();
4429*c87b03e5Sespie     }
4430*c87b03e5Sespie 
4431*c87b03e5Sespie   ffeste_end_stmt_ ();
4432*c87b03e5Sespie }
4433*c87b03e5Sespie 
4434*c87b03e5Sespie /* REWRITE statement -- start.  */
4435*c87b03e5Sespie 
4436*c87b03e5Sespie #if FFESTR_VXT
4437*c87b03e5Sespie void
ffeste_V018_start(ffestpRewriteStmt * info,ffestvFormat format)4438*c87b03e5Sespie ffeste_V018_start (ffestpRewriteStmt *info, ffestvFormat format)
4439*c87b03e5Sespie {
4440*c87b03e5Sespie   ffeste_check_start_ ();
4441*c87b03e5Sespie }
4442*c87b03e5Sespie 
4443*c87b03e5Sespie /* REWRITE statement -- I/O item.  */
4444*c87b03e5Sespie 
4445*c87b03e5Sespie void
ffeste_V018_item(ffebld expr)4446*c87b03e5Sespie ffeste_V018_item (ffebld expr)
4447*c87b03e5Sespie {
4448*c87b03e5Sespie   ffeste_check_item_ ();
4449*c87b03e5Sespie }
4450*c87b03e5Sespie 
4451*c87b03e5Sespie /* REWRITE statement -- end.  */
4452*c87b03e5Sespie 
4453*c87b03e5Sespie void
ffeste_V018_finish()4454*c87b03e5Sespie ffeste_V018_finish ()
4455*c87b03e5Sespie {
4456*c87b03e5Sespie   ffeste_check_finish_ ();
4457*c87b03e5Sespie }
4458*c87b03e5Sespie 
4459*c87b03e5Sespie /* ACCEPT statement -- start.  */
4460*c87b03e5Sespie 
4461*c87b03e5Sespie void
ffeste_V019_start(ffestpAcceptStmt * info,ffestvFormat format)4462*c87b03e5Sespie ffeste_V019_start (ffestpAcceptStmt *info, ffestvFormat format)
4463*c87b03e5Sespie {
4464*c87b03e5Sespie   ffeste_check_start_ ();
4465*c87b03e5Sespie }
4466*c87b03e5Sespie 
4467*c87b03e5Sespie /* ACCEPT statement -- I/O item.  */
4468*c87b03e5Sespie 
4469*c87b03e5Sespie void
ffeste_V019_item(ffebld expr)4470*c87b03e5Sespie ffeste_V019_item (ffebld expr)
4471*c87b03e5Sespie {
4472*c87b03e5Sespie   ffeste_check_item_ ();
4473*c87b03e5Sespie }
4474*c87b03e5Sespie 
4475*c87b03e5Sespie /* ACCEPT statement -- end.  */
4476*c87b03e5Sespie 
4477*c87b03e5Sespie void
ffeste_V019_finish()4478*c87b03e5Sespie ffeste_V019_finish ()
4479*c87b03e5Sespie {
4480*c87b03e5Sespie   ffeste_check_finish_ ();
4481*c87b03e5Sespie }
4482*c87b03e5Sespie 
4483*c87b03e5Sespie #endif
4484*c87b03e5Sespie /* TYPE statement -- start.  */
4485*c87b03e5Sespie 
4486*c87b03e5Sespie void
ffeste_V020_start(ffestpTypeStmt * info UNUSED,ffestvFormat format UNUSED)4487*c87b03e5Sespie ffeste_V020_start (ffestpTypeStmt *info UNUSED,
4488*c87b03e5Sespie 		   ffestvFormat format UNUSED)
4489*c87b03e5Sespie {
4490*c87b03e5Sespie   ffeste_check_start_ ();
4491*c87b03e5Sespie }
4492*c87b03e5Sespie 
4493*c87b03e5Sespie /* TYPE statement -- I/O item.  */
4494*c87b03e5Sespie 
4495*c87b03e5Sespie void
ffeste_V020_item(ffebld expr UNUSED)4496*c87b03e5Sespie ffeste_V020_item (ffebld expr UNUSED)
4497*c87b03e5Sespie {
4498*c87b03e5Sespie   ffeste_check_item_ ();
4499*c87b03e5Sespie }
4500*c87b03e5Sespie 
4501*c87b03e5Sespie /* TYPE statement -- end.  */
4502*c87b03e5Sespie 
4503*c87b03e5Sespie void
ffeste_V020_finish()4504*c87b03e5Sespie ffeste_V020_finish ()
4505*c87b03e5Sespie {
4506*c87b03e5Sespie   ffeste_check_finish_ ();
4507*c87b03e5Sespie }
4508*c87b03e5Sespie 
4509*c87b03e5Sespie /* DELETE statement.  */
4510*c87b03e5Sespie 
4511*c87b03e5Sespie #if FFESTR_VXT
4512*c87b03e5Sespie void
ffeste_V021(ffestpDeleteStmt * info)4513*c87b03e5Sespie ffeste_V021 (ffestpDeleteStmt *info)
4514*c87b03e5Sespie {
4515*c87b03e5Sespie   ffeste_check_simple_ ();
4516*c87b03e5Sespie }
4517*c87b03e5Sespie 
4518*c87b03e5Sespie /* UNLOCK statement.  */
4519*c87b03e5Sespie 
4520*c87b03e5Sespie void
ffeste_V022(ffestpBeruStmt * info)4521*c87b03e5Sespie ffeste_V022 (ffestpBeruStmt *info)
4522*c87b03e5Sespie {
4523*c87b03e5Sespie   ffeste_check_simple_ ();
4524*c87b03e5Sespie }
4525*c87b03e5Sespie 
4526*c87b03e5Sespie /* ENCODE statement -- start.  */
4527*c87b03e5Sespie 
4528*c87b03e5Sespie void
ffeste_V023_start(ffestpVxtcodeStmt * info)4529*c87b03e5Sespie ffeste_V023_start (ffestpVxtcodeStmt *info)
4530*c87b03e5Sespie {
4531*c87b03e5Sespie   ffeste_check_start_ ();
4532*c87b03e5Sespie }
4533*c87b03e5Sespie 
4534*c87b03e5Sespie /* ENCODE statement -- I/O item.  */
4535*c87b03e5Sespie 
4536*c87b03e5Sespie void
ffeste_V023_item(ffebld expr)4537*c87b03e5Sespie ffeste_V023_item (ffebld expr)
4538*c87b03e5Sespie {
4539*c87b03e5Sespie   ffeste_check_item_ ();
4540*c87b03e5Sespie }
4541*c87b03e5Sespie 
4542*c87b03e5Sespie /* ENCODE statement -- end.  */
4543*c87b03e5Sespie 
4544*c87b03e5Sespie void
ffeste_V023_finish()4545*c87b03e5Sespie ffeste_V023_finish ()
4546*c87b03e5Sespie {
4547*c87b03e5Sespie   ffeste_check_finish_ ();
4548*c87b03e5Sespie }
4549*c87b03e5Sespie 
4550*c87b03e5Sespie /* DECODE statement -- start.  */
4551*c87b03e5Sespie 
4552*c87b03e5Sespie void
ffeste_V024_start(ffestpVxtcodeStmt * info)4553*c87b03e5Sespie ffeste_V024_start (ffestpVxtcodeStmt *info)
4554*c87b03e5Sespie {
4555*c87b03e5Sespie   ffeste_check_start_ ();
4556*c87b03e5Sespie }
4557*c87b03e5Sespie 
4558*c87b03e5Sespie /* DECODE statement -- I/O item.  */
4559*c87b03e5Sespie 
4560*c87b03e5Sespie void
ffeste_V024_item(ffebld expr)4561*c87b03e5Sespie ffeste_V024_item (ffebld expr)
4562*c87b03e5Sespie {
4563*c87b03e5Sespie   ffeste_check_item_ ();
4564*c87b03e5Sespie }
4565*c87b03e5Sespie 
4566*c87b03e5Sespie /* DECODE statement -- end.  */
4567*c87b03e5Sespie 
4568*c87b03e5Sespie void
ffeste_V024_finish()4569*c87b03e5Sespie ffeste_V024_finish ()
4570*c87b03e5Sespie {
4571*c87b03e5Sespie   ffeste_check_finish_ ();
4572*c87b03e5Sespie }
4573*c87b03e5Sespie 
4574*c87b03e5Sespie /* DEFINEFILE statement -- start.  */
4575*c87b03e5Sespie 
4576*c87b03e5Sespie void
ffeste_V025_start()4577*c87b03e5Sespie ffeste_V025_start ()
4578*c87b03e5Sespie {
4579*c87b03e5Sespie   ffeste_check_start_ ();
4580*c87b03e5Sespie }
4581*c87b03e5Sespie 
4582*c87b03e5Sespie /* DEFINE FILE statement -- item.  */
4583*c87b03e5Sespie 
4584*c87b03e5Sespie void
ffeste_V025_item(ffebld u,ffebld m,ffebld n,ffebld asv)4585*c87b03e5Sespie ffeste_V025_item (ffebld u, ffebld m, ffebld n, ffebld asv)
4586*c87b03e5Sespie {
4587*c87b03e5Sespie   ffeste_check_item_ ();
4588*c87b03e5Sespie }
4589*c87b03e5Sespie 
4590*c87b03e5Sespie /* DEFINE FILE statement -- end.  */
4591*c87b03e5Sespie 
4592*c87b03e5Sespie void
ffeste_V025_finish()4593*c87b03e5Sespie ffeste_V025_finish ()
4594*c87b03e5Sespie {
4595*c87b03e5Sespie   ffeste_check_finish_ ();
4596*c87b03e5Sespie }
4597*c87b03e5Sespie 
4598*c87b03e5Sespie /* FIND statement.  */
4599*c87b03e5Sespie 
4600*c87b03e5Sespie void
ffeste_V026(ffestpFindStmt * info)4601*c87b03e5Sespie ffeste_V026 (ffestpFindStmt *info)
4602*c87b03e5Sespie {
4603*c87b03e5Sespie   ffeste_check_simple_ ();
4604*c87b03e5Sespie }
4605*c87b03e5Sespie 
4606*c87b03e5Sespie #endif
4607*c87b03e5Sespie 
4608*c87b03e5Sespie #ifdef ENABLE_CHECKING
4609*c87b03e5Sespie void
ffeste_terminate_2(void)4610*c87b03e5Sespie ffeste_terminate_2 (void)
4611*c87b03e5Sespie {
4612*c87b03e5Sespie   assert (! ffeste_top_block_);
4613*c87b03e5Sespie }
4614*c87b03e5Sespie #endif
4615*c87b03e5Sespie 
4616*c87b03e5Sespie #include "gt-f-ste.h"
4617