1 /* stc.c -- Implementation File (module.c template V1.0)
2 Copyright (C) 1995-1997 Free Software Foundation, Inc.
3 Contributed by James Craig Burley (burley@gnu.ai.mit.edu).
5 This file is part of GNU Fortran.
7 GNU Fortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Fortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Fortran; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 Verifies the proper semantics for statements, checking expressions already
27 semantically analyzed individually, collectively, checking label defs and
28 refs, and so on. Uses ffebad to indicate errors in semantics.
30 In many cases, both a token and a keyword (ffestrFirst, ffestrSecond,
31 or ffestrOther) is provided. ONLY USE THE TOKEN as a pointer to the
32 source-code location for an error message or similar; use the keyword
33 as the semantic matching for the token, since the token's text might
34 not match the keyword's code. For example, INTENT(IN OUT) A in free
35 source form passes to ffestc_R519_start the token "IN" but the keyword
36 FFESTR_otherINOUT, and the latter is correct.
38 Generally, either a single ffestc function handles an entire statement,
39 in which case its name is ffestc_xyz_, or more than one function is
40 needed, in which case its names are ffestc_xyz_start_,
41 ffestc_xyz_item_ or ffestc_xyz_item_abc_, and ffestc_xyz_finish_.
42 The caller must call _start_ before calling any _item_ functions, and
43 must call _finish_ afterwards. If it is clearly a syntactic matter as
44 to restrictions on the number and variety of _item_ calls, then the caller
45 should report any errors and ffestc_ should presume it has been taken
46 care of and handle any semantic problems with grace and no error messages.
47 If the permitted number and variety of _item_ calls has some basis in
48 semantics, then the caller should not generate any messages and ffestc
49 should do all the checking.
51 A few ffestc functions have names rather than grammar numbers, like
52 ffestc_elsewhere and ffestc_end. These are cases where the actual
53 statement depends on its context rather than just its form; ELSE WHERE
54 may be the obvious (WHERE...ELSE WHERE...END WHERE) or something a little
55 more subtle (WHERE: IF THEN...ELSE WHERE...END IF WHERE). The actual
56 ffestc functions do exist and do work, but may or may not be invoked
57 by ffestb depending on whether some form of resolution is possible.
58 For example, ffestc_R1103 end-program-stmt is reachable directly when
59 END PROGRAM [name] is specified, or via ffestc_end when END is specified
60 and the context is a main program. So ffestc_xyz_ should make a quick
61 determination of the context and pick the appropriate ffestc_Nxyz_
62 function to invoke, without a lot of ceremony.
87 /* Externals defined here. */
89 ffeexprContext ffestc_iolist_context_ = FFEEXPR_contextIOLIST;
90 /* Valid only from READ/WRITE start to finish. */
92 /* Simple definitions and enumerations. */
96 FFESTC_orderOK_, /* Statement ok in this context, process. */
97 FFESTC_orderBAD_, /* Statement not ok in this context, don't
99 FFESTC_orderBADOK_, /* Don't process but push block if
106 FFESTC_stateletSIMPLE_, /* Expecting simple/start. */
107 FFESTC_stateletATTRIB_, /* Expecting attrib/item/itemstart. */
108 FFESTC_stateletITEM_, /* Expecting item/itemstart/finish. */
109 FFESTC_stateletITEMVALS_, /* Expecting itemvalue/itemendvals. */
113 /* Internal typedefs. */
116 /* Private include files. */
119 /* Internal structure definitions. */
121 union ffestc_local_u_
125 ffebld initlist; /* For list of one sym in INTEGER I/3/ case. */
126 ffetargetCharacterSize stmt_size;
127 ffetargetCharacterSize size;
128 ffeinfoBasictype basic_type;
129 ffeinfoKindtype stmt_kind_type;
130 ffeinfoKindtype kind_type;
131 bool per_var_kind_ok;
132 char is_R426; /* 1=R426, 2=R501. */
137 ffebld objlist; /* For list of target objects. */
138 ffebldListBottom list_bottom; /* For building lists. */
143 ffebldListBottom list_bottom; /* For building lists. */
149 ffesymbol symbol; /* NML symbol. */
154 ffelexToken t; /* First token in list. */
155 ffeequiv eq; /* Current equivalence being built up. */
156 ffebld list; /* List of expressions in equivalence. */
157 ffebldListBottom bottom;
158 bool ok; /* TRUE while current list still being
160 bool save; /* TRUE if any var in list is SAVEd. */
165 ffesymbol symbol; /* BCB/NCB symbol. */
170 ffesymbol symbol; /* SFN symbol. */
176 char list_state; /* 0=>no field names allowed, 1=>error
177 reported already, 2=>field names req'd,
178 3=>have a field name. */
182 }; /* Merge with the one in ffestc later. */
184 /* Static objects accessed by functions in this module. */
186 static bool ffestc_ok_; /* _start_ fn's send this to _xyz_ fn's. */
187 static bool ffestc_parent_ok_; /* Parent sym for baby sym fn's ok. */
188 static char ffestc_namelist_; /* 0=>not namelist, 1=>namelist, 2=>error. */
189 static union ffestc_local_u_ ffestc_local_;
190 static ffestcStatelet_ ffestc_statelet_ = FFESTC_stateletSIMPLE_;
191 static ffestwShriek ffestc_shriek_after1_ = NULL;
192 static unsigned long ffestc_blocknum_ = 0; /* Next block# to assign. */
193 static int ffestc_entry_num_;
194 static int ffestc_sfdummy_argno_;
195 static int ffestc_saved_entry_num_;
196 static ffelab ffestc_label_;
198 /* Static functions (internal). */
200 static void ffestc_R544_equiv_ (ffebld expr, ffelexToken t);
201 static void ffestc_establish_declinfo_ (ffebld kind, ffelexToken kindt,
202 ffebld len, ffelexToken lent);
203 static void ffestc_establish_declstmt_ (ffestpType type, ffelexToken typet,
204 ffebld kind, ffelexToken kindt,
205 ffebld len, ffelexToken lent);
206 static void ffestc_establish_impletter_ (ffelexToken first, ffelexToken last);
207 static ffeinfoKindtype ffestc_kindtype_kind_ (ffeinfoBasictype bt,
208 ffetargetCharacterSize val);
209 static ffeinfoKindtype ffestc_kindtype_star_ (ffeinfoBasictype bt,
210 ffetargetCharacterSize val);
211 static void ffestc_labeldef_any_ (void);
212 static bool ffestc_labeldef_begin_ (void);
213 static void ffestc_labeldef_branch_begin_ (void);
214 static void ffestc_labeldef_branch_end_ (void);
215 static void ffestc_labeldef_endif_ (void);
216 static void ffestc_labeldef_format_ (void);
217 static void ffestc_labeldef_invalid_ (void);
218 static void ffestc_labeldef_notloop_ (void);
219 static void ffestc_labeldef_notloop_begin_ (void);
220 static void ffestc_labeldef_useless_ (void);
221 static bool ffestc_labelref_is_assignable_ (ffelexToken label_token,
223 static bool ffestc_labelref_is_branch_ (ffelexToken label_token,
225 static bool ffestc_labelref_is_format_ (ffelexToken label_token,
227 static bool ffestc_labelref_is_loopend_ (ffelexToken label_token,
230 static ffestcOrder_ ffestc_order_access_ (void);
232 static ffestcOrder_ ffestc_order_actiondo_ (void);
233 static ffestcOrder_ ffestc_order_actionif_ (void);
234 static ffestcOrder_ ffestc_order_actionwhere_ (void);
235 static void ffestc_order_any_ (void);
236 static void ffestc_order_bad_ (void);
237 static ffestcOrder_ ffestc_order_blockdata_ (void);
238 static ffestcOrder_ ffestc_order_blockspec_ (void);
240 static ffestcOrder_ ffestc_order_component_ (void);
243 static ffestcOrder_ ffestc_order_contains_ (void);
245 static ffestcOrder_ ffestc_order_data_ (void);
246 static ffestcOrder_ ffestc_order_data77_ (void);
248 static ffestcOrder_ ffestc_order_derivedtype_ (void);
250 static ffestcOrder_ ffestc_order_do_ (void);
251 static ffestcOrder_ ffestc_order_entry_ (void);
252 static ffestcOrder_ ffestc_order_exec_ (void);
253 static ffestcOrder_ ffestc_order_format_ (void);
254 static ffestcOrder_ ffestc_order_function_ (void);
255 static ffestcOrder_ ffestc_order_iface_ (void);
256 static ffestcOrder_ ffestc_order_ifthen_ (void);
257 static ffestcOrder_ ffestc_order_implicit_ (void);
258 static ffestcOrder_ ffestc_order_implicitnone_ (void);
260 static ffestcOrder_ ffestc_order_interface_ (void);
263 static ffestcOrder_ ffestc_order_map_ (void);
266 static ffestcOrder_ ffestc_order_module_ (void);
268 static ffestcOrder_ ffestc_order_parameter_ (void);
269 static ffestcOrder_ ffestc_order_program_ (void);
270 static ffestcOrder_ ffestc_order_progspec_ (void);
272 static ffestcOrder_ ffestc_order_record_ (void);
274 static ffestcOrder_ ffestc_order_selectcase_ (void);
275 static ffestcOrder_ ffestc_order_sfunc_ (void);
277 static ffestcOrder_ ffestc_order_spec_ (void);
280 static ffestcOrder_ ffestc_order_structure_ (void);
282 static ffestcOrder_ ffestc_order_subroutine_ (void);
284 static ffestcOrder_ ffestc_order_type_ (void);
286 static ffestcOrder_ ffestc_order_typedecl_ (void);
288 static ffestcOrder_ ffestc_order_union_ (void);
290 static ffestcOrder_ ffestc_order_unit_ (void);
292 static ffestcOrder_ ffestc_order_use_ (void);
295 static ffestcOrder_ ffestc_order_vxtstructure_ (void);
298 static ffestcOrder_ ffestc_order_where_ (void);
300 static void ffestc_promote_dummy_ (ffelexToken t);
301 static void ffestc_promote_execdummy_ (ffelexToken t);
302 static void ffestc_promote_sfdummy_ (ffelexToken t);
303 static void ffestc_shriek_begin_program_ (void);
305 static void ffestc_shriek_begin_uses_ (void);
307 static void ffestc_shriek_blockdata_ (bool ok);
308 static void ffestc_shriek_do_ (bool ok);
309 static void ffestc_shriek_end_program_ (bool ok);
311 static void ffestc_shriek_end_uses_ (bool ok);
313 static void ffestc_shriek_function_ (bool ok);
314 static void ffestc_shriek_if_ (bool ok);
315 static void ffestc_shriek_ifthen_ (bool ok);
317 static void ffestc_shriek_interface_ (bool ok);
320 static void ffestc_shriek_map_ (bool ok);
323 static void ffestc_shriek_module_ (bool ok);
325 static void ffestc_shriek_select_ (bool ok);
327 static void ffestc_shriek_structure_ (bool ok);
329 static void ffestc_shriek_subroutine_ (bool ok);
331 static void ffestc_shriek_type_ (bool ok);
334 static void ffestc_shriek_union_ (bool ok);
337 static void ffestc_shriek_where_ (bool ok);
340 static void ffestc_shriek_wherethen_ (bool ok);
342 static int ffestc_subr_binsrch_ (char **list, int size, ffestpFile *spec,
344 static ffestvFormat ffestc_subr_format_ (ffestpFile *spec);
345 static bool ffestc_subr_is_branch_ (ffestpFile *spec);
346 static bool ffestc_subr_is_format_ (ffestpFile *spec);
347 static bool ffestc_subr_is_present_ (char *name, ffestpFile *spec);
348 static int ffestc_subr_speccmp_ (char *string, ffestpFile *spec,
349 char **target, int *length);
350 static ffestvUnit ffestc_subr_unit_ (ffestpFile *spec);
351 static void ffestc_try_shriek_do_ (void);
353 /* Internal macros. */
355 #define ffestc_check_simple_() \
356 assert(ffestc_statelet_ == FFESTC_stateletSIMPLE_)
357 #define ffestc_check_start_() \
358 assert(ffestc_statelet_ == FFESTC_stateletSIMPLE_); \
359 ffestc_statelet_ = FFESTC_stateletATTRIB_
360 #define ffestc_check_attrib_() \
361 assert(ffestc_statelet_ == FFESTC_stateletATTRIB_)
362 #define ffestc_check_item_() \
363 assert(ffestc_statelet_ == FFESTC_stateletATTRIB_ \
364 || ffestc_statelet_ == FFESTC_stateletITEM_); \
365 ffestc_statelet_ = FFESTC_stateletITEM_
366 #define ffestc_check_item_startvals_() \
367 assert(ffestc_statelet_ == FFESTC_stateletATTRIB_ \
368 || ffestc_statelet_ == FFESTC_stateletITEM_); \
369 ffestc_statelet_ = FFESTC_stateletITEMVALS_
370 #define ffestc_check_item_value_() \
371 assert(ffestc_statelet_ == FFESTC_stateletITEMVALS_)
372 #define ffestc_check_item_endvals_() \
373 assert(ffestc_statelet_ == FFESTC_stateletITEMVALS_); \
374 ffestc_statelet_ = FFESTC_stateletITEM_
375 #define ffestc_check_finish_() \
376 assert(ffestc_statelet_ == FFESTC_stateletATTRIB_ \
377 || ffestc_statelet_ == FFESTC_stateletITEM_); \
378 ffestc_statelet_ = FFESTC_stateletSIMPLE_
379 #define ffestc_order_action_() ffestc_order_exec_()
381 #define ffestc_order_interfacespec_() ffestc_order_derivedtype_()
383 #define ffestc_shriek_if_lost_ ffestc_shriek_if_
385 #define ffestc_shriek_where_lost_ ffestc_shriek_where_
388 /* ffestc_establish_declinfo_ -- Determine specific type/params info for entity
390 ffestc_establish_declinfo_(kind,kind_token,len,len_token);
392 Must be called after _declstmt_ called to establish base type. */
395 ffestc_establish_declinfo_ (ffebld kind, ffelexToken kindt, ffebld len,
398 ffeinfoBasictype bt = ffestc_local_.decl.basic_type;
400 ffetargetCharacterSize val;
403 kt = ffestc_local_.decl.stmt_kind_type;
404 else if (!ffestc_local_.decl.per_var_kind_ok)
406 ffebad_start (FFEBAD_KINDTYPE);
407 ffebad_here (0, ffelex_token_where_line (kindt),
408 ffelex_token_where_column (kindt));
409 ffebad_here (1, ffelex_token_where_line (ffesta_tokens[0]),
410 ffelex_token_where_column (ffesta_tokens[0]));
412 kt = ffestc_local_.decl.stmt_kind_type;
418 assert (ffelex_token_type (kindt) == FFELEX_typeNUMBER);
419 val = atol (ffelex_token_text (kindt));
420 kt = ffestc_kindtype_star_ (bt, val);
422 else if (ffebld_op (kind) == FFEBLD_opANY)
423 kt = ffestc_local_.decl.stmt_kind_type;
426 assert (ffebld_op (kind) == FFEBLD_opCONTER);
427 assert (ffeinfo_basictype (ffebld_info (kind))
428 == FFEINFO_basictypeINTEGER);
429 assert (ffeinfo_kindtype (ffebld_info (kind))
430 == FFEINFO_kindtypeINTEGERDEFAULT);
431 val = ffebld_constant_integerdefault (ffebld_conter (kind));
432 kt = ffestc_kindtype_kind_ (bt, val);
435 if (kt == FFEINFO_kindtypeNONE)
436 { /* Not valid kind type. */
437 ffebad_start (FFEBAD_KINDTYPE);
438 ffebad_here (0, ffelex_token_where_line (kindt),
439 ffelex_token_where_column (kindt));
440 ffebad_here (1, ffelex_token_where_line (ffesta_tokens[0]),
441 ffelex_token_where_column (ffesta_tokens[0]));
443 kt = ffestc_local_.decl.stmt_kind_type;
447 ffestc_local_.decl.kind_type = kt;
449 /* Now check length specification for CHARACTER data type. */
451 if (((len == NULL) && (lent == NULL))
452 || (bt != FFEINFO_basictypeCHARACTER))
453 val = ffestc_local_.decl.stmt_size;
458 assert (ffelex_token_type (lent) == FFELEX_typeNUMBER);
459 val = atol (ffelex_token_text (lent));
461 else if (ffebld_op (len) == FFEBLD_opSTAR)
462 val = FFETARGET_charactersizeNONE;
463 else if (ffebld_op (len) == FFEBLD_opANY)
464 val = FFETARGET_charactersizeNONE;
467 assert (ffebld_op (len) == FFEBLD_opCONTER);
468 assert (ffeinfo_basictype (ffebld_info (len))
469 == FFEINFO_basictypeINTEGER);
470 assert (ffeinfo_kindtype (ffebld_info (len))
471 == FFEINFO_kindtypeINTEGERDEFAULT);
472 val = ffebld_constant_integerdefault (ffebld_conter (len));
476 if ((val == 0) && !(0 && ffe_is_90 ()))
479 ffebad_start (FFEBAD_ZERO_SIZE);
480 ffebad_here (0, ffelex_token_where_line (lent), ffelex_token_where_column (lent));
483 ffestc_local_.decl.size = val;
486 /* ffestc_establish_declstmt_ -- Establish host-specific type/params info
488 ffestc_establish_declstmt_(type,type_token,kind,kind_token,len,
492 ffestc_establish_declstmt_ (ffestpType type, ffelexToken typet, ffebld kind,
493 ffelexToken kindt, ffebld len, ffelexToken lent)
496 ffeinfoKindtype ktd; /* Default kindtype. */
498 ffetargetCharacterSize val;
499 bool per_var_kind_ok = TRUE;
501 /* Determine basictype and default kindtype. */
505 case FFESTP_typeINTEGER:
506 bt = FFEINFO_basictypeINTEGER;
507 ktd = FFEINFO_kindtypeINTEGERDEFAULT;
510 case FFESTP_typeBYTE:
511 bt = FFEINFO_basictypeINTEGER;
512 ktd = FFEINFO_kindtypeINTEGER2;
515 case FFESTP_typeWORD:
516 bt = FFEINFO_basictypeINTEGER;
517 ktd = FFEINFO_kindtypeINTEGER3;
520 case FFESTP_typeREAL:
521 bt = FFEINFO_basictypeREAL;
522 ktd = FFEINFO_kindtypeREALDEFAULT;
525 case FFESTP_typeCOMPLEX:
526 bt = FFEINFO_basictypeCOMPLEX;
527 ktd = FFEINFO_kindtypeREALDEFAULT;
530 case FFESTP_typeLOGICAL:
531 bt = FFEINFO_basictypeLOGICAL;
532 ktd = FFEINFO_kindtypeLOGICALDEFAULT;
535 case FFESTP_typeCHARACTER:
536 bt = FFEINFO_basictypeCHARACTER;
537 ktd = FFEINFO_kindtypeCHARACTERDEFAULT;
540 case FFESTP_typeDBLPRCSN:
541 bt = FFEINFO_basictypeREAL;
542 ktd = FFEINFO_kindtypeREALDOUBLE;
543 per_var_kind_ok = FALSE;
546 case FFESTP_typeDBLCMPLX:
547 bt = FFEINFO_basictypeCOMPLEX;
548 #if FFETARGET_okCOMPLEX2
549 ktd = FFEINFO_kindtypeREALDOUBLE;
551 ktd = FFEINFO_kindtypeREALDEFAULT;
552 ffebad_start (FFEBAD_BAD_DBLCMPLX);
553 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
554 ffelex_token_where_column (ffesta_tokens[0]));
557 per_var_kind_ok = FALSE;
561 assert ("Unexpected type (F90 TYPE?)!" == NULL);
562 bt = FFEINFO_basictypeNONE;
563 ktd = FFEINFO_kindtypeNONE;
570 { /* Not necessarily default kind type. */
572 { /* Shouldn't happen for CHARACTER. */
573 assert (ffelex_token_type (kindt) == FFELEX_typeNUMBER);
574 val = atol (ffelex_token_text (kindt));
575 kt = ffestc_kindtype_star_ (bt, val);
577 else if (ffebld_op (kind) == FFEBLD_opANY)
581 assert (ffebld_op (kind) == FFEBLD_opCONTER);
582 assert (ffeinfo_basictype (ffebld_info (kind))
583 == FFEINFO_basictypeINTEGER);
584 assert (ffeinfo_kindtype (ffebld_info (kind))
585 == FFEINFO_kindtypeINTEGERDEFAULT);
586 val = ffebld_constant_integerdefault (ffebld_conter (kind));
587 kt = ffestc_kindtype_kind_ (bt, val);
590 if (kt == FFEINFO_kindtypeNONE)
591 { /* Not valid kind type. */
592 ffebad_start (FFEBAD_KINDTYPE);
593 ffebad_here (0, ffelex_token_where_line (kindt),
594 ffelex_token_where_column (kindt));
595 ffebad_here (1, ffelex_token_where_line (typet),
596 ffelex_token_where_column (typet));
602 ffestc_local_.decl.basic_type = bt;
603 ffestc_local_.decl.stmt_kind_type = kt;
604 ffestc_local_.decl.per_var_kind_ok = per_var_kind_ok;
606 /* Now check length specification for CHARACTER data type. */
608 if (((len == NULL) && (lent == NULL))
609 || (type != FFESTP_typeCHARACTER))
610 val = (type == FFESTP_typeCHARACTER) ? 1 : FFETARGET_charactersizeNONE;
615 assert (ffelex_token_type (lent) == FFELEX_typeNUMBER);
616 val = atol (ffelex_token_text (lent));
618 else if (ffebld_op (len) == FFEBLD_opSTAR)
619 val = FFETARGET_charactersizeNONE;
620 else if (ffebld_op (len) == FFEBLD_opANY)
621 val = FFETARGET_charactersizeNONE;
624 assert (ffebld_op (len) == FFEBLD_opCONTER);
625 assert (ffeinfo_basictype (ffebld_info (len))
626 == FFEINFO_basictypeINTEGER);
627 assert (ffeinfo_kindtype (ffebld_info (len))
628 == FFEINFO_kindtypeINTEGERDEFAULT);
629 val = ffebld_constant_integerdefault (ffebld_conter (len));
633 if ((val == 0) && !(0 && ffe_is_90 ()))
636 ffebad_start (FFEBAD_ZERO_SIZE);
637 ffebad_here (0, ffelex_token_where_line (lent), ffelex_token_where_column (lent));
640 ffestc_local_.decl.stmt_size = val;
643 /* ffestc_establish_impletter_ -- Establish type/params for IMPLICIT letter(s)
645 ffestc_establish_impletter_(first_letter_token,last_letter_token); */
648 ffestc_establish_impletter_ (ffelexToken first, ffelexToken last)
650 bool ok = FALSE; /* Stays FALSE if first letter > last. */
654 ok = ffeimplic_establish_initial (c = *(ffelex_token_text (first)),
655 ffestc_local_.decl.basic_type,
656 ffestc_local_.decl.kind_type,
657 ffestc_local_.decl.size);
660 for (c = *(ffelex_token_text (first));
661 c <= *(ffelex_token_text (last));
664 ok = ffeimplic_establish_initial (c,
665 ffestc_local_.decl.basic_type,
666 ffestc_local_.decl.kind_type,
667 ffestc_local_.decl.size);
680 ffebad_start (FFEBAD_BAD_IMPLICIT);
681 ffebad_here (0, ffelex_token_where_line (first), ffelex_token_where_column (first));
687 /* ffestc_init_3 -- Initialize ffestc for new program unit
694 ffestv_save_state_ = FFESTV_savestateNONE;
695 ffestc_entry_num_ = 0;
696 ffestv_num_label_defines_ = 0;
699 /* ffestc_init_4 -- Initialize ffestc for new scoping unit
703 For SUBROUTINEs/FUNCTIONs within INTERFACE/END INTERFACE, derived-TYPE-
704 defs, and statement function defs. */
709 ffestc_saved_entry_num_ = ffestc_entry_num_;
710 ffestc_entry_num_ = 0;
713 /* ffestc_kindtype_kind_ -- Determine kindtype from basictype and KIND= value
717 ffetargetCharacterSize val;
718 kt = ffestc_kindtype_kind_(bt,val);
719 if (kt == FFEINFO_kindtypeNONE)
720 // unsupported/invalid KIND= value for type */
722 static ffeinfoKindtype
723 ffestc_kindtype_kind_ (ffeinfoBasictype bt, ffetargetCharacterSize val)
729 base_type = ffeinfo_type (bt, 1); /* ~~ */
730 assert (base_type != NULL);
732 type = ffetype_lookup_kind (base_type, (int) val);
734 return FFEINFO_kindtypeNONE;
736 for (kt = 1; kt < FFEINFO_kindtype; ++kt)
737 if (ffeinfo_type (bt, kt) == type)
740 return FFEINFO_kindtypeNONE;
743 /* ffestc_kindtype_star_ -- Determine kindtype from basictype and * value
747 ffetargetCharacterSize val;
748 kt = ffestc_kindtype_star_(bt,val);
749 if (kt == FFEINFO_kindtypeNONE)
750 // unsupported/invalid * value for type */
752 static ffeinfoKindtype
753 ffestc_kindtype_star_ (ffeinfoBasictype bt, ffetargetCharacterSize val)
759 base_type = ffeinfo_type (bt, 1); /* ~~ */
760 assert (base_type != NULL);
762 type = ffetype_lookup_star (base_type, (int) val);
764 return FFEINFO_kindtypeNONE;
766 for (kt = 1; kt < FFEINFO_kindtype; ++kt)
767 if (ffeinfo_type (bt, kt) == type)
770 return FFEINFO_kindtypeNONE;
773 /* Define label as usable for anything without complaint. */
776 ffestc_labeldef_any_ ()
778 if ((ffesta_label_token == NULL)
779 || !ffestc_labeldef_begin_ ())
782 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
783 ffestd_labeldef_any (ffestc_label_);
785 ffestc_labeldef_branch_end_ ();
788 /* ffestc_labeldef_begin_ -- Define label as unknown, initially
790 ffestc_labeldef_begin_(); */
793 ffestc_labeldef_begin_ ()
795 ffelabValue label_value;
798 label_value = (ffelabValue) atol (ffelex_token_text (ffesta_label_token));
799 if ((label_value == 0) || (label_value > FFELAB_valueMAX))
801 ffebad_start (FFEBAD_LABEL_NUMBER_INVALID);
802 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
803 ffelex_token_where_column (ffesta_label_token));
807 label = ffelab_find (label_value);
810 label = ffestc_label_ = ffelab_new (label_value);
811 ffestv_num_label_defines_++;
812 ffelab_set_definition_line (label,
813 ffewhere_line_use (ffelex_token_where_line (ffesta_label_token)));
814 ffelab_set_definition_column (label,
815 ffewhere_column_use (ffelex_token_where_column (ffesta_label_token)));
820 if (ffewhere_line_is_unknown (ffelab_definition_line (label)))
822 ffestv_num_label_defines_++;
823 ffestc_label_ = label;
824 ffelab_set_definition_line (label,
825 ffewhere_line_use (ffelex_token_where_line (ffesta_label_token)));
826 ffelab_set_definition_column (label,
827 ffewhere_column_use (ffelex_token_where_column (ffesta_label_token)));
832 ffebad_start (FFEBAD_LABEL_ALREADY_DEFINED);
833 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
834 ffelex_token_where_column (ffesta_label_token));
835 ffebad_here (1, ffelab_definition_line (label),
836 ffelab_definition_column (label));
837 ffebad_string (ffelex_token_text (ffesta_label_token));
840 ffelex_token_kill (ffesta_label_token);
841 ffesta_label_token = NULL;
845 /* ffestc_labeldef_branch_begin_ -- Define label as a branch target one
847 ffestc_labeldef_branch_begin_(); */
850 ffestc_labeldef_branch_begin_ ()
852 if ((ffesta_label_token == NULL)
853 || (ffestc_shriek_after1_ != NULL)
854 || !ffestc_labeldef_begin_ ())
857 switch (ffelab_type (ffestc_label_))
859 case FFELAB_typeUNKNOWN:
860 case FFELAB_typeASSIGNABLE:
861 ffelab_set_type (ffestc_label_, FFELAB_typeNOTLOOP);
862 ffelab_set_blocknum (ffestc_label_,
863 ffestw_blocknum (ffestw_stack_top ()));
864 ffestd_labeldef_branch (ffestc_label_);
867 case FFELAB_typeNOTLOOP:
868 if (ffelab_blocknum (ffestc_label_)
869 < ffestw_blocknum (ffestw_stack_top ()))
871 ffebad_start (FFEBAD_LABEL_BLOCK);
872 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
873 ffelex_token_where_column (ffesta_label_token));
874 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
875 ffelab_firstref_column (ffestc_label_));
878 ffelab_set_blocknum (ffestc_label_,
879 ffestw_blocknum (ffestw_stack_top ()));
880 ffestd_labeldef_branch (ffestc_label_);
883 case FFELAB_typeLOOPEND:
884 if ((ffestw_state (ffestw_stack_top ()) != FFESTV_stateDO)
885 || (ffestw_label (ffestw_stack_top ()) != ffestc_label_))
886 { /* Unterminated block. */
887 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
888 ffestd_labeldef_any (ffestc_label_);
890 ffebad_start (FFEBAD_LABEL_DO_BLOCK_END);
891 ffebad_here (0, ffelab_doref_line (ffestc_label_),
892 ffelab_doref_column (ffestc_label_));
893 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
894 ffebad_here (2, ffelex_token_where_line (ffesta_label_token),
895 ffelex_token_where_column (ffesta_label_token));
899 ffestd_labeldef_branch (ffestc_label_);
900 /* Leave something around for _branch_end_() to handle. */
903 case FFELAB_typeFORMAT:
904 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
905 ffestd_labeldef_any (ffestc_label_);
907 ffebad_start (FFEBAD_LABEL_USE_DEF);
908 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
909 ffelex_token_where_column (ffesta_label_token));
910 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
911 ffelab_firstref_column (ffestc_label_));
916 assert ("bad label" == NULL);
922 ffestc_try_shriek_do_ ();
924 ffelex_token_kill (ffesta_label_token);
925 ffesta_label_token = NULL;
928 /* Define possible end of labeled-DO-loop. Call only after calling
929 ffestc_labeldef_branch_begin_, or when other branch_* functions
930 recognize that a label might also be serving as a branch end (in
931 which case they must issue a diagnostic). */
934 ffestc_labeldef_branch_end_ ()
936 if (ffesta_label_token == NULL)
939 assert (ffestc_label_ != NULL);
940 assert ((ffelab_type (ffestc_label_) == FFELAB_typeLOOPEND)
941 || (ffelab_type (ffestc_label_) == FFELAB_typeANY));
943 while ((ffestw_state (ffestw_stack_top ()) == FFESTV_stateDO)
944 && (ffestw_label (ffestw_stack_top ()) == ffestc_label_))
945 ffestc_shriek_do_ (TRUE);
947 ffestc_try_shriek_do_ ();
949 ffelex_token_kill (ffesta_label_token);
950 ffesta_label_token = NULL;
953 /* ffestc_labeldef_endif_ -- Define label as an END IF one
955 ffestc_labeldef_endif_(); */
958 ffestc_labeldef_endif_ ()
960 if ((ffesta_label_token == NULL)
961 || (ffestc_shriek_after1_ != NULL)
962 || !ffestc_labeldef_begin_ ())
965 switch (ffelab_type (ffestc_label_))
967 case FFELAB_typeUNKNOWN:
968 case FFELAB_typeASSIGNABLE:
969 ffelab_set_type (ffestc_label_, FFELAB_typeENDIF);
970 ffelab_set_blocknum (ffestc_label_,
971 ffestw_blocknum (ffestw_previous (ffestw_stack_top ())));
972 ffestd_labeldef_endif (ffestc_label_);
975 case FFELAB_typeNOTLOOP:
976 if (ffelab_blocknum (ffestc_label_)
977 < ffestw_blocknum (ffestw_previous (ffestw_stack_top ())))
979 ffebad_start (FFEBAD_LABEL_BLOCK);
980 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
981 ffelex_token_where_column (ffesta_label_token));
982 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
983 ffelab_firstref_column (ffestc_label_));
986 ffelab_set_blocknum (ffestc_label_,
987 ffestw_blocknum (ffestw_previous (ffestw_stack_top ())));
988 ffestd_labeldef_endif (ffestc_label_);
991 case FFELAB_typeLOOPEND:
992 if ((ffestw_state (ffestw_stack_top ()) != FFESTV_stateDO)
993 || (ffestw_label (ffestw_stack_top ()) != ffestc_label_))
994 { /* Unterminated block. */
995 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
996 ffestd_labeldef_any (ffestc_label_);
998 ffebad_start (FFEBAD_LABEL_DO_BLOCK_END);
999 ffebad_here (0, ffelab_doref_line (ffestc_label_),
1000 ffelab_doref_column (ffestc_label_));
1001 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
1002 ffebad_here (2, ffelex_token_where_line (ffesta_label_token),
1003 ffelex_token_where_column (ffesta_label_token));
1007 ffestd_labeldef_endif (ffestc_label_);
1008 ffebad_start (FFEBAD_LABEL_USE_DEF);
1009 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1010 ffelex_token_where_column (ffesta_label_token));
1011 ffebad_here (1, ffelab_doref_line (ffestc_label_),
1012 ffelab_doref_column (ffestc_label_));
1014 ffestc_labeldef_branch_end_ ();
1017 case FFELAB_typeFORMAT:
1018 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1019 ffestd_labeldef_any (ffestc_label_);
1021 ffebad_start (FFEBAD_LABEL_USE_DEF);
1022 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1023 ffelex_token_where_column (ffesta_label_token));
1024 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
1025 ffelab_firstref_column (ffestc_label_));
1030 assert ("bad label" == NULL);
1032 case FFELAB_typeANY:
1036 ffestc_try_shriek_do_ ();
1038 ffelex_token_kill (ffesta_label_token);
1039 ffesta_label_token = NULL;
1042 /* ffestc_labeldef_format_ -- Define label as a FORMAT one
1044 ffestc_labeldef_format_(); */
1047 ffestc_labeldef_format_ ()
1049 if ((ffesta_label_token == NULL)
1050 || (ffestc_shriek_after1_ != NULL))
1052 ffebad_start (FFEBAD_FORMAT_NO_LABEL_DEF);
1053 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
1054 ffelex_token_where_column (ffesta_tokens[0]));
1059 if (!ffestc_labeldef_begin_ ())
1062 switch (ffelab_type (ffestc_label_))
1064 case FFELAB_typeUNKNOWN:
1065 case FFELAB_typeASSIGNABLE:
1066 ffelab_set_type (ffestc_label_, FFELAB_typeFORMAT);
1067 ffestd_labeldef_format (ffestc_label_);
1070 case FFELAB_typeFORMAT:
1071 ffestd_labeldef_format (ffestc_label_);
1074 case FFELAB_typeLOOPEND:
1075 if ((ffestw_state (ffestw_stack_top ()) != FFESTV_stateDO)
1076 || (ffestw_label (ffestw_stack_top ()) != ffestc_label_))
1077 { /* Unterminated block. */
1078 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1079 ffestd_labeldef_any (ffestc_label_);
1081 ffebad_start (FFEBAD_LABEL_DO_BLOCK_END);
1082 ffebad_here (0, ffelab_doref_line (ffestc_label_),
1083 ffelab_doref_column (ffestc_label_));
1084 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
1085 ffebad_here (2, ffelex_token_where_line (ffesta_label_token),
1086 ffelex_token_where_column (ffesta_label_token));
1090 ffestd_labeldef_format (ffestc_label_);
1091 ffebad_start (FFEBAD_LABEL_USE_DEF);
1092 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1093 ffelex_token_where_column (ffesta_label_token));
1094 ffebad_here (1, ffelab_doref_line (ffestc_label_),
1095 ffelab_doref_column (ffestc_label_));
1097 ffestc_labeldef_branch_end_ ();
1100 case FFELAB_typeNOTLOOP:
1101 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1102 ffestd_labeldef_any (ffestc_label_);
1104 ffebad_start (FFEBAD_LABEL_USE_DEF);
1105 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1106 ffelex_token_where_column (ffesta_label_token));
1107 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
1108 ffelab_firstref_column (ffestc_label_));
1113 assert ("bad label" == NULL);
1115 case FFELAB_typeANY:
1119 ffestc_try_shriek_do_ ();
1121 ffelex_token_kill (ffesta_label_token);
1122 ffesta_label_token = NULL;
1125 /* ffestc_labeldef_invalid_ -- Label definition invalid, complain if present
1127 ffestc_labeldef_invalid_(); */
1130 ffestc_labeldef_invalid_ ()
1132 if ((ffesta_label_token == NULL)
1133 || (ffestc_shriek_after1_ != NULL)
1134 || !ffestc_labeldef_begin_ ())
1137 ffebad_start (FFEBAD_INVALID_LABEL_DEF);
1138 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1139 ffelex_token_where_column (ffesta_label_token));
1142 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1143 ffestd_labeldef_any (ffestc_label_);
1145 ffestc_try_shriek_do_ ();
1147 ffelex_token_kill (ffesta_label_token);
1148 ffesta_label_token = NULL;
1151 /* Define label as a non-loop-ending one on a statement that can't
1152 be in the "then" part of a logical IF, such as a block-IF statement. */
1155 ffestc_labeldef_notloop_ ()
1157 if (ffesta_label_token == NULL)
1160 assert (ffestc_shriek_after1_ == NULL);
1162 if (!ffestc_labeldef_begin_ ())
1165 switch (ffelab_type (ffestc_label_))
1167 case FFELAB_typeUNKNOWN:
1168 case FFELAB_typeASSIGNABLE:
1169 ffelab_set_type (ffestc_label_, FFELAB_typeNOTLOOP);
1170 ffelab_set_blocknum (ffestc_label_,
1171 ffestw_blocknum (ffestw_stack_top ()));
1172 ffestd_labeldef_notloop (ffestc_label_);
1175 case FFELAB_typeNOTLOOP:
1176 if (ffelab_blocknum (ffestc_label_)
1177 < ffestw_blocknum (ffestw_stack_top ()))
1179 ffebad_start (FFEBAD_LABEL_BLOCK);
1180 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1181 ffelex_token_where_column (ffesta_label_token));
1182 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
1183 ffelab_firstref_column (ffestc_label_));
1186 ffelab_set_blocknum (ffestc_label_,
1187 ffestw_blocknum (ffestw_stack_top ()));
1188 ffestd_labeldef_notloop (ffestc_label_);
1191 case FFELAB_typeLOOPEND:
1192 if ((ffestw_state (ffestw_stack_top ()) != FFESTV_stateDO)
1193 || (ffestw_label (ffestw_stack_top ()) != ffestc_label_))
1194 { /* Unterminated block. */
1195 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1196 ffestd_labeldef_any (ffestc_label_);
1198 ffebad_start (FFEBAD_LABEL_DO_BLOCK_END);
1199 ffebad_here (0, ffelab_doref_line (ffestc_label_),
1200 ffelab_doref_column (ffestc_label_));
1201 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
1202 ffebad_here (2, ffelex_token_where_line (ffesta_label_token),
1203 ffelex_token_where_column (ffesta_label_token));
1207 ffestd_labeldef_notloop (ffestc_label_);
1208 ffebad_start (FFEBAD_LABEL_USE_DEF);
1209 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1210 ffelex_token_where_column (ffesta_label_token));
1211 ffebad_here (1, ffelab_doref_line (ffestc_label_),
1212 ffelab_doref_column (ffestc_label_));
1214 ffestc_labeldef_branch_end_ ();
1217 case FFELAB_typeFORMAT:
1218 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1219 ffestd_labeldef_any (ffestc_label_);
1221 ffebad_start (FFEBAD_LABEL_USE_DEF);
1222 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1223 ffelex_token_where_column (ffesta_label_token));
1224 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
1225 ffelab_firstref_column (ffestc_label_));
1230 assert ("bad label" == NULL);
1232 case FFELAB_typeANY:
1236 ffestc_try_shriek_do_ ();
1238 ffelex_token_kill (ffesta_label_token);
1239 ffesta_label_token = NULL;
1242 /* Define label as a non-loop-ending one. Use this when it is
1243 possible that the pending label is inhibited because we're in
1244 the midst of a logical-IF, and thus _branch_end_ is going to
1245 be called after the current statement to resolve a potential
1246 loop-ending label. */
1249 ffestc_labeldef_notloop_begin_ ()
1251 if ((ffesta_label_token == NULL)
1252 || (ffestc_shriek_after1_ != NULL)
1253 || !ffestc_labeldef_begin_ ())
1256 switch (ffelab_type (ffestc_label_))
1258 case FFELAB_typeUNKNOWN:
1259 case FFELAB_typeASSIGNABLE:
1260 ffelab_set_type (ffestc_label_, FFELAB_typeNOTLOOP);
1261 ffelab_set_blocknum (ffestc_label_,
1262 ffestw_blocknum (ffestw_stack_top ()));
1263 ffestd_labeldef_notloop (ffestc_label_);
1266 case FFELAB_typeNOTLOOP:
1267 if (ffelab_blocknum (ffestc_label_)
1268 < ffestw_blocknum (ffestw_stack_top ()))
1270 ffebad_start (FFEBAD_LABEL_BLOCK);
1271 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1272 ffelex_token_where_column (ffesta_label_token));
1273 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
1274 ffelab_firstref_column (ffestc_label_));
1277 ffelab_set_blocknum (ffestc_label_,
1278 ffestw_blocknum (ffestw_stack_top ()));
1279 ffestd_labeldef_notloop (ffestc_label_);
1282 case FFELAB_typeLOOPEND:
1283 if ((ffestw_state (ffestw_stack_top ()) != FFESTV_stateDO)
1284 || (ffestw_label (ffestw_stack_top ()) != ffestc_label_))
1285 { /* Unterminated block. */
1286 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1287 ffestd_labeldef_any (ffestc_label_);
1289 ffebad_start (FFEBAD_LABEL_DO_BLOCK_END);
1290 ffebad_here (0, ffelab_doref_line (ffestc_label_),
1291 ffelab_doref_column (ffestc_label_));
1292 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
1293 ffebad_here (2, ffelex_token_where_line (ffesta_label_token),
1294 ffelex_token_where_column (ffesta_label_token));
1298 ffestd_labeldef_branch (ffestc_label_);
1299 ffebad_start (FFEBAD_LABEL_USE_DEF);
1300 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1301 ffelex_token_where_column (ffesta_label_token));
1302 ffebad_here (1, ffelab_doref_line (ffestc_label_),
1303 ffelab_doref_column (ffestc_label_));
1307 case FFELAB_typeFORMAT:
1308 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1309 ffestd_labeldef_any (ffestc_label_);
1311 ffebad_start (FFEBAD_LABEL_USE_DEF);
1312 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1313 ffelex_token_where_column (ffesta_label_token));
1314 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
1315 ffelab_firstref_column (ffestc_label_));
1320 assert ("bad label" == NULL);
1322 case FFELAB_typeANY:
1326 ffestc_try_shriek_do_ ();
1328 ffelex_token_kill (ffesta_label_token);
1329 ffesta_label_token = NULL;
1332 /* ffestc_labeldef_useless_ -- Define label as a useless one
1334 ffestc_labeldef_useless_(); */
1337 ffestc_labeldef_useless_ ()
1339 if ((ffesta_label_token == NULL)
1340 || (ffestc_shriek_after1_ != NULL)
1341 || !ffestc_labeldef_begin_ ())
1344 switch (ffelab_type (ffestc_label_))
1346 case FFELAB_typeUNKNOWN:
1347 ffelab_set_type (ffestc_label_, FFELAB_typeUSELESS);
1348 ffestd_labeldef_useless (ffestc_label_);
1351 case FFELAB_typeLOOPEND:
1352 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1353 ffestd_labeldef_any (ffestc_label_);
1355 if ((ffestw_state (ffestw_stack_top ()) != FFESTV_stateDO)
1356 || (ffestw_label (ffestw_stack_top ()) != ffestc_label_))
1357 { /* Unterminated block. */
1358 ffebad_start (FFEBAD_LABEL_DO_BLOCK_END);
1359 ffebad_here (0, ffelab_doref_line (ffestc_label_),
1360 ffelab_doref_column (ffestc_label_));
1361 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
1362 ffebad_here (2, ffelex_token_where_line (ffesta_label_token),
1363 ffelex_token_where_column (ffesta_label_token));
1367 ffebad_start (FFEBAD_LABEL_USE_DEF);
1368 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1369 ffelex_token_where_column (ffesta_label_token));
1370 ffebad_here (1, ffelab_doref_line (ffestc_label_),
1371 ffelab_doref_column (ffestc_label_));
1373 ffestc_labeldef_branch_end_ ();
1376 case FFELAB_typeASSIGNABLE:
1377 case FFELAB_typeFORMAT:
1378 case FFELAB_typeNOTLOOP:
1379 ffelab_set_type (ffestc_label_, FFELAB_typeANY);
1380 ffestd_labeldef_any (ffestc_label_);
1382 ffebad_start (FFEBAD_LABEL_USE_DEF);
1383 ffebad_here (0, ffelex_token_where_line (ffesta_label_token),
1384 ffelex_token_where_column (ffesta_label_token));
1385 ffebad_here (1, ffelab_firstref_line (ffestc_label_),
1386 ffelab_firstref_column (ffestc_label_));
1391 assert ("bad label" == NULL);
1393 case FFELAB_typeANY:
1397 ffestc_try_shriek_do_ ();
1399 ffelex_token_kill (ffesta_label_token);
1400 ffesta_label_token = NULL;
1403 /* ffestc_labelref_is_assignable_ -- Reference to label in ASSIGN stmt
1405 if (ffestc_labelref_is_assignable_(label_token,&label))
1406 // label ref is ok, label is filled in with ffelab object */
1409 ffestc_labelref_is_assignable_ (ffelexToken label_token, ffelab *x_label)
1412 ffelabValue label_value;
1414 label_value = (ffelabValue) atol (ffelex_token_text (label_token));
1415 if ((label_value == 0) || (label_value > FFELAB_valueMAX))
1417 ffebad_start (FFEBAD_LABEL_NUMBER_INVALID);
1418 ffebad_here (0, ffelex_token_where_line (label_token),
1419 ffelex_token_where_column (label_token));
1424 label = ffelab_find (label_value);
1427 label = ffelab_new (label_value);
1428 ffelab_set_firstref_line (label,
1429 ffewhere_line_use (ffelex_token_where_line (label_token)));
1430 ffelab_set_firstref_column (label,
1431 ffewhere_column_use (ffelex_token_where_column (label_token)));
1434 switch (ffelab_type (label))
1436 case FFELAB_typeUNKNOWN:
1437 ffelab_set_type (label, FFELAB_typeASSIGNABLE);
1440 case FFELAB_typeASSIGNABLE:
1441 case FFELAB_typeLOOPEND:
1442 case FFELAB_typeFORMAT:
1443 case FFELAB_typeNOTLOOP:
1444 case FFELAB_typeENDIF:
1447 case FFELAB_typeUSELESS:
1448 ffelab_set_type (label, FFELAB_typeANY);
1449 ffestd_labeldef_any (label);
1451 ffebad_start (FFEBAD_LABEL_USE_DEF);
1452 ffebad_here (0, ffelab_firstref_line (label), ffelab_firstref_column (label));
1453 ffebad_here (1, ffelex_token_where_line (label_token),
1454 ffelex_token_where_column (label_token));
1457 ffestc_try_shriek_do_ ();
1462 assert ("bad label" == NULL);
1464 case FFELAB_typeANY:
1472 /* ffestc_labelref_is_branch_ -- Reference to label in branch stmt
1474 if (ffestc_labelref_is_branch_(label_token,&label))
1475 // label ref is ok, label is filled in with ffelab object */
1478 ffestc_labelref_is_branch_ (ffelexToken label_token, ffelab *x_label)
1481 ffelabValue label_value;
1483 unsigned long blocknum;
1485 label_value = (ffelabValue) atol (ffelex_token_text (label_token));
1486 if ((label_value == 0) || (label_value > FFELAB_valueMAX))
1488 ffebad_start (FFEBAD_LABEL_NUMBER_INVALID);
1489 ffebad_here (0, ffelex_token_where_line (label_token),
1490 ffelex_token_where_column (label_token));
1495 label = ffelab_find (label_value);
1498 label = ffelab_new (label_value);
1499 ffelab_set_firstref_line (label,
1500 ffewhere_line_use (ffelex_token_where_line (label_token)));
1501 ffelab_set_firstref_column (label,
1502 ffewhere_column_use (ffelex_token_where_column (label_token)));
1505 switch (ffelab_type (label))
1507 case FFELAB_typeUNKNOWN:
1508 case FFELAB_typeASSIGNABLE:
1509 ffelab_set_type (label, FFELAB_typeNOTLOOP);
1510 ffelab_set_blocknum (label, ffestw_blocknum (ffestw_stack_top ()));
1513 case FFELAB_typeLOOPEND:
1514 if (ffelab_blocknum (label) != 0)
1515 break; /* Already taken care of. */
1516 for (block = ffestw_top_do (ffestw_stack_top ());
1517 (block != NULL) && (ffestw_label (block) != label);
1518 block = ffestw_top_do (ffestw_previous (block)))
1519 ; /* Find most recent DO <label> ancestor. */
1521 { /* Reference to within a (dead) block. */
1522 ffebad_start (FFEBAD_LABEL_BLOCK);
1523 ffebad_here (0, ffelab_definition_line (label),
1524 ffelab_definition_column (label));
1525 ffebad_here (1, ffelex_token_where_line (label_token),
1526 ffelex_token_where_column (label_token));
1530 ffelab_set_blocknum (label, ffestw_blocknum (block));
1531 ffelab_set_firstref_line (label,
1532 ffewhere_line_use (ffelex_token_where_line (label_token)));
1533 ffelab_set_firstref_column (label,
1534 ffewhere_column_use (ffelex_token_where_column (label_token)));
1537 case FFELAB_typeNOTLOOP:
1538 case FFELAB_typeENDIF:
1539 if (ffelab_blocknum (label) == ffestw_blocknum (ffestw_stack_top ()))
1541 blocknum = ffelab_blocknum (label);
1542 for (block = ffestw_stack_top ();
1543 ffestw_blocknum (block) > blocknum;
1544 block = ffestw_previous (block))
1545 ; /* Find most recent common ancestor. */
1546 if (ffelab_blocknum (label) == ffestw_blocknum (block))
1547 break; /* Check again. */
1548 if (!ffewhere_line_is_unknown (ffelab_definition_line (label)))
1549 { /* Reference to within a (dead) block. */
1550 ffebad_start (FFEBAD_LABEL_BLOCK);
1551 ffebad_here (0, ffelab_definition_line (label),
1552 ffelab_definition_column (label));
1553 ffebad_here (1, ffelex_token_where_line (label_token),
1554 ffelex_token_where_column (label_token));
1558 ffelab_set_blocknum (label, ffestw_blocknum (block));
1561 case FFELAB_typeFORMAT:
1562 if (ffewhere_line_is_unknown (ffelab_definition_line (label)))
1564 ffelab_set_type (label, FFELAB_typeANY);
1565 ffestd_labeldef_any (label);
1567 ffebad_start (FFEBAD_LABEL_USE_USE);
1568 ffebad_here (0, ffelab_firstref_line (label), ffelab_firstref_column (label));
1569 ffebad_here (1, ffelex_token_where_line (label_token),
1570 ffelex_token_where_column (label_token));
1573 ffestc_try_shriek_do_ ();
1578 case FFELAB_typeUSELESS:
1579 ffelab_set_type (label, FFELAB_typeANY);
1580 ffestd_labeldef_any (label);
1582 ffebad_start (FFEBAD_LABEL_USE_DEF);
1583 ffebad_here (0, ffelab_definition_line (label), ffelab_definition_column (label));
1584 ffebad_here (1, ffelex_token_where_line (label_token),
1585 ffelex_token_where_column (label_token));
1588 ffestc_try_shriek_do_ ();
1593 assert ("bad label" == NULL);
1595 case FFELAB_typeANY:
1603 /* ffestc_labelref_is_format_ -- Reference to label in [FMT=] specification
1605 if (ffestc_labelref_is_format_(label_token,&label))
1606 // label ref is ok, label is filled in with ffelab object */
1609 ffestc_labelref_is_format_ (ffelexToken label_token, ffelab *x_label)
1612 ffelabValue label_value;
1614 label_value = (ffelabValue) atol (ffelex_token_text (label_token));
1615 if ((label_value == 0) || (label_value > FFELAB_valueMAX))
1617 ffebad_start (FFEBAD_LABEL_NUMBER_INVALID);
1618 ffebad_here (0, ffelex_token_where_line (label_token),
1619 ffelex_token_where_column (label_token));
1624 label = ffelab_find (label_value);
1627 label = ffelab_new (label_value);
1628 ffelab_set_firstref_line (label,
1629 ffewhere_line_use (ffelex_token_where_line (label_token)));
1630 ffelab_set_firstref_column (label,
1631 ffewhere_column_use (ffelex_token_where_column (label_token)));
1634 switch (ffelab_type (label))
1636 case FFELAB_typeUNKNOWN:
1637 case FFELAB_typeASSIGNABLE:
1638 ffelab_set_type (label, FFELAB_typeFORMAT);
1641 case FFELAB_typeFORMAT:
1644 case FFELAB_typeLOOPEND:
1645 case FFELAB_typeNOTLOOP:
1646 if (ffewhere_line_is_unknown (ffelab_definition_line (label)))
1648 ffelab_set_type (label, FFELAB_typeANY);
1649 ffestd_labeldef_any (label);
1651 ffebad_start (FFEBAD_LABEL_USE_USE);
1652 ffebad_here (0, ffelab_firstref_line (label), ffelab_firstref_column (label));
1653 ffebad_here (1, ffelex_token_where_line (label_token),
1654 ffelex_token_where_column (label_token));
1657 ffestc_try_shriek_do_ ();
1662 case FFELAB_typeUSELESS:
1663 case FFELAB_typeENDIF:
1664 ffelab_set_type (label, FFELAB_typeANY);
1665 ffestd_labeldef_any (label);
1667 ffebad_start (FFEBAD_LABEL_USE_DEF);
1668 ffebad_here (0, ffelab_definition_line (label), ffelab_definition_column (label));
1669 ffebad_here (1, ffelex_token_where_line (label_token),
1670 ffelex_token_where_column (label_token));
1673 ffestc_try_shriek_do_ ();
1678 assert ("bad label" == NULL);
1680 case FFELAB_typeANY:
1684 ffestc_try_shriek_do_ ();
1690 /* ffestc_labelref_is_loopend_ -- Reference to label in DO stmt
1692 if (ffestc_labelref_is_loopend_(label_token,&label))
1693 // label ref is ok, label is filled in with ffelab object */
1696 ffestc_labelref_is_loopend_ (ffelexToken label_token, ffelab *x_label)
1699 ffelabValue label_value;
1701 label_value = (ffelabValue) atol (ffelex_token_text (label_token));
1702 if ((label_value == 0) || (label_value > FFELAB_valueMAX))
1704 ffebad_start (FFEBAD_LABEL_NUMBER_INVALID);
1705 ffebad_here (0, ffelex_token_where_line (label_token),
1706 ffelex_token_where_column (label_token));
1711 label = ffelab_find (label_value);
1714 label = ffelab_new (label_value);
1715 ffelab_set_doref_line (label,
1716 ffewhere_line_use (ffelex_token_where_line (label_token)));
1717 ffelab_set_doref_column (label,
1718 ffewhere_column_use (ffelex_token_where_column (label_token)));
1721 switch (ffelab_type (label))
1723 case FFELAB_typeASSIGNABLE:
1724 ffelab_set_doref_line (label,
1725 ffewhere_line_use (ffelex_token_where_line (label_token)));
1726 ffelab_set_doref_column (label,
1727 ffewhere_column_use (ffelex_token_where_column (label_token)));
1728 ffewhere_line_kill (ffelab_firstref_line (label));
1729 ffelab_set_firstref_line (label, ffewhere_line_unknown ());
1730 ffewhere_column_kill (ffelab_firstref_column (label));
1731 ffelab_set_firstref_column (label, ffewhere_column_unknown ());
1733 case FFELAB_typeUNKNOWN:
1734 ffelab_set_type (label, FFELAB_typeLOOPEND);
1735 ffelab_set_blocknum (label, 0);
1738 case FFELAB_typeLOOPEND:
1739 if (!ffewhere_line_is_unknown (ffelab_definition_line (label)))
1740 { /* Def must follow all refs. */
1741 ffelab_set_type (label, FFELAB_typeANY);
1742 ffestd_labeldef_any (label);
1744 ffebad_start (FFEBAD_LABEL_DEF_DO);
1745 ffebad_here (0, ffelab_definition_line (label),
1746 ffelab_definition_column (label));
1747 ffebad_here (1, ffelex_token_where_line (label_token),
1748 ffelex_token_where_column (label_token));
1751 ffestc_try_shriek_do_ ();
1755 if (ffelab_blocknum (label) != 0)
1756 { /* Had a branch ref earlier, can't go inside
1758 ffelab_set_type (label, FFELAB_typeANY);
1759 ffestd_labeldef_any (label);
1761 ffebad_start (FFEBAD_LABEL_USE_USE);
1762 ffebad_here (0, ffelab_firstref_line (label),
1763 ffelab_firstref_column (label));
1764 ffebad_here (1, ffelex_token_where_line (label_token),
1765 ffelex_token_where_column (label_token));
1768 ffestc_try_shriek_do_ ();
1772 if ((ffestw_state (ffestw_stack_top ()) != FFESTV_stateDO)
1773 || (ffestw_label (ffestw_stack_top ()) != label))
1774 { /* Top of stack interrupts flow between two
1775 DOs specifying label. */
1776 ffelab_set_type (label, FFELAB_typeANY);
1777 ffestd_labeldef_any (label);
1779 ffebad_start (FFEBAD_LABEL_DO_BLOCK_DO);
1780 ffebad_here (0, ffelab_doref_line (label),
1781 ffelab_doref_column (label));
1782 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
1783 ffebad_here (2, ffelex_token_where_line (label_token),
1784 ffelex_token_where_column (label_token));
1787 ffestc_try_shriek_do_ ();
1793 case FFELAB_typeNOTLOOP:
1794 case FFELAB_typeFORMAT:
1795 if (ffewhere_line_is_unknown (ffelab_definition_line (label)))
1797 ffelab_set_type (label, FFELAB_typeANY);
1798 ffestd_labeldef_any (label);
1800 ffebad_start (FFEBAD_LABEL_USE_USE);
1801 ffebad_here (0, ffelab_firstref_line (label), ffelab_firstref_column (label));
1802 ffebad_here (1, ffelex_token_where_line (label_token),
1803 ffelex_token_where_column (label_token));
1806 ffestc_try_shriek_do_ ();
1811 case FFELAB_typeUSELESS:
1812 case FFELAB_typeENDIF:
1813 ffelab_set_type (label, FFELAB_typeANY);
1814 ffestd_labeldef_any (label);
1816 ffebad_start (FFEBAD_LABEL_USE_DEF);
1817 ffebad_here (0, ffelab_definition_line (label), ffelab_definition_column (label));
1818 ffebad_here (1, ffelex_token_where_line (label_token),
1819 ffelex_token_where_column (label_token));
1822 ffestc_try_shriek_do_ ();
1827 assert ("bad label" == NULL);
1829 case FFELAB_typeANY:
1837 /* ffestc_order_access_ -- Check ordering on <access> statement
1839 if (ffestc_order_access_() != FFESTC_orderOK_)
1844 ffestc_order_access_ ()
1848 switch (ffestw_state (ffestw_stack_top ()))
1850 case FFESTV_stateNIL:
1851 ffestc_shriek_begin_program_ ();
1852 goto recurse; /* :::::::::::::::::::: */
1854 case FFESTV_stateMODULE0:
1855 case FFESTV_stateMODULE1:
1856 case FFESTV_stateMODULE2:
1857 ffestw_update (NULL);
1858 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE3);
1859 return FFESTC_orderOK_;
1861 case FFESTV_stateMODULE3:
1862 return FFESTC_orderOK_;
1864 case FFESTV_stateUSE:
1866 ffestc_shriek_end_uses_ (TRUE);
1868 goto recurse; /* :::::::::::::::::::: */
1870 case FFESTV_stateWHERE:
1871 ffestc_order_bad_ ();
1873 ffestc_shriek_where_ (FALSE);
1875 return FFESTC_orderBAD_;
1877 case FFESTV_stateIF:
1878 ffestc_order_bad_ ();
1879 ffestc_shriek_if_ (FALSE);
1880 return FFESTC_orderBAD_;
1883 ffestc_order_bad_ ();
1884 return FFESTC_orderBAD_;
1889 /* ffestc_order_actiondo_ -- Check ordering on <actiondo> statement
1891 if (ffestc_order_actiondo_() != FFESTC_orderOK_)
1895 ffestc_order_actiondo_ ()
1899 switch (ffestw_state (ffestw_stack_top ()))
1901 case FFESTV_stateNIL:
1902 ffestc_shriek_begin_program_ ();
1903 goto recurse; /* :::::::::::::::::::: */
1905 case FFESTV_stateDO:
1906 return FFESTC_orderOK_;
1908 case FFESTV_stateIFTHEN:
1909 case FFESTV_stateSELECT1:
1910 if (ffestw_top_do (ffestw_stack_top ()) == NULL)
1912 return FFESTC_orderOK_;
1914 case FFESTV_stateIF:
1915 if (ffestw_top_do (ffestw_stack_top ()) == NULL)
1917 ffestc_shriek_after1_ = ffestc_shriek_if_;
1918 return FFESTC_orderOK_;
1920 case FFESTV_stateUSE:
1922 ffestc_shriek_end_uses_ (TRUE);
1924 goto recurse; /* :::::::::::::::::::: */
1926 case FFESTV_stateWHERE:
1927 ffestc_order_bad_ ();
1929 ffestc_shriek_where_ (FALSE);
1931 return FFESTC_orderBAD_;
1936 ffestc_order_bad_ ();
1937 return FFESTC_orderBAD_;
1940 /* ffestc_order_actionif_ -- Check ordering on <actionif> statement
1942 if (ffestc_order_actionif_() != FFESTC_orderOK_)
1946 ffestc_order_actionif_ ()
1952 switch (ffestw_state (ffestw_stack_top ()))
1954 case FFESTV_stateNIL:
1955 ffestc_shriek_begin_program_ ();
1956 goto recurse; /* :::::::::::::::::::: */
1958 case FFESTV_statePROGRAM0:
1959 case FFESTV_statePROGRAM1:
1960 case FFESTV_statePROGRAM2:
1961 case FFESTV_statePROGRAM3:
1962 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM4);
1966 case FFESTV_stateSUBROUTINE0:
1967 case FFESTV_stateSUBROUTINE1:
1968 case FFESTV_stateSUBROUTINE2:
1969 case FFESTV_stateSUBROUTINE3:
1970 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE4);
1974 case FFESTV_stateFUNCTION0:
1975 case FFESTV_stateFUNCTION1:
1976 case FFESTV_stateFUNCTION2:
1977 case FFESTV_stateFUNCTION3:
1978 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION4);
1982 case FFESTV_statePROGRAM4:
1983 case FFESTV_stateSUBROUTINE4:
1984 case FFESTV_stateFUNCTION4:
1988 case FFESTV_stateIFTHEN:
1989 case FFESTV_stateDO:
1990 case FFESTV_stateSELECT1:
1991 return FFESTC_orderOK_;
1993 case FFESTV_stateIF:
1994 ffestc_shriek_after1_ = ffestc_shriek_if_;
1995 return FFESTC_orderOK_;
1997 case FFESTV_stateUSE:
1999 ffestc_shriek_end_uses_ (TRUE);
2001 goto recurse; /* :::::::::::::::::::: */
2003 case FFESTV_stateWHERE:
2004 ffestc_order_bad_ ();
2006 ffestc_shriek_where_ (FALSE);
2008 return FFESTC_orderBAD_;
2011 ffestc_order_bad_ ();
2012 return FFESTC_orderBAD_;
2015 switch (ffestw_state (ffestw_previous (ffestw_stack_top ())))
2017 case FFESTV_stateINTERFACE0:
2018 ffestc_order_bad_ ();
2020 ffestw_update (NULL);
2021 return FFESTC_orderBAD_;
2025 ffestw_update (NULL);
2026 return FFESTC_orderOK_;
2030 /* ffestc_order_actionwhere_ -- Check ordering on <actionwhere> statement
2032 if (ffestc_order_actionwhere_() != FFESTC_orderOK_)
2036 ffestc_order_actionwhere_ ()
2042 switch (ffestw_state (ffestw_stack_top ()))
2044 case FFESTV_stateNIL:
2045 ffestc_shriek_begin_program_ ();
2046 goto recurse; /* :::::::::::::::::::: */
2048 case FFESTV_statePROGRAM0:
2049 case FFESTV_statePROGRAM1:
2050 case FFESTV_statePROGRAM2:
2051 case FFESTV_statePROGRAM3:
2052 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM4);
2056 case FFESTV_stateSUBROUTINE0:
2057 case FFESTV_stateSUBROUTINE1:
2058 case FFESTV_stateSUBROUTINE2:
2059 case FFESTV_stateSUBROUTINE3:
2060 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE4);
2064 case FFESTV_stateFUNCTION0:
2065 case FFESTV_stateFUNCTION1:
2066 case FFESTV_stateFUNCTION2:
2067 case FFESTV_stateFUNCTION3:
2068 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION4);
2072 case FFESTV_statePROGRAM4:
2073 case FFESTV_stateSUBROUTINE4:
2074 case FFESTV_stateFUNCTION4:
2078 case FFESTV_stateWHERETHEN:
2079 case FFESTV_stateIFTHEN:
2080 case FFESTV_stateDO:
2081 case FFESTV_stateSELECT1:
2082 return FFESTC_orderOK_;
2084 case FFESTV_stateWHERE:
2086 ffestc_shriek_after1_ = ffestc_shriek_where_;
2088 return FFESTC_orderOK_;
2090 case FFESTV_stateIF:
2091 ffestc_shriek_after1_ = ffestc_shriek_if_;
2092 return FFESTC_orderOK_;
2094 case FFESTV_stateUSE:
2096 ffestc_shriek_end_uses_ (TRUE);
2098 goto recurse; /* :::::::::::::::::::: */
2101 ffestc_order_bad_ ();
2102 return FFESTC_orderBAD_;
2105 switch (ffestw_state (ffestw_previous (ffestw_stack_top ())))
2107 case FFESTV_stateINTERFACE0:
2108 ffestc_order_bad_ ();
2110 ffestw_update (NULL);
2111 return FFESTC_orderBAD_;
2115 ffestw_update (NULL);
2116 return FFESTC_orderOK_;
2120 /* Check ordering on "any" statement. Like _actionwhere_, but
2121 doesn't produce any diagnostics. */
2124 ffestc_order_any_ ()
2130 switch (ffestw_state (ffestw_stack_top ()))
2132 case FFESTV_stateNIL:
2133 ffestc_shriek_begin_program_ ();
2134 goto recurse; /* :::::::::::::::::::: */
2136 case FFESTV_statePROGRAM0:
2137 case FFESTV_statePROGRAM1:
2138 case FFESTV_statePROGRAM2:
2139 case FFESTV_statePROGRAM3:
2140 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM4);
2144 case FFESTV_stateSUBROUTINE0:
2145 case FFESTV_stateSUBROUTINE1:
2146 case FFESTV_stateSUBROUTINE2:
2147 case FFESTV_stateSUBROUTINE3:
2148 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE4);
2152 case FFESTV_stateFUNCTION0:
2153 case FFESTV_stateFUNCTION1:
2154 case FFESTV_stateFUNCTION2:
2155 case FFESTV_stateFUNCTION3:
2156 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION4);
2160 case FFESTV_statePROGRAM4:
2161 case FFESTV_stateSUBROUTINE4:
2162 case FFESTV_stateFUNCTION4:
2166 case FFESTV_stateWHERETHEN:
2167 case FFESTV_stateIFTHEN:
2168 case FFESTV_stateDO:
2169 case FFESTV_stateSELECT1:
2172 case FFESTV_stateWHERE:
2174 ffestc_shriek_after1_ = ffestc_shriek_where_;
2178 case FFESTV_stateIF:
2179 ffestc_shriek_after1_ = ffestc_shriek_if_;
2182 case FFESTV_stateUSE:
2184 ffestc_shriek_end_uses_ (TRUE);
2186 goto recurse; /* :::::::::::::::::::: */
2192 switch (ffestw_state (ffestw_previous (ffestw_stack_top ())))
2194 case FFESTV_stateINTERFACE0:
2196 ffestw_update (NULL);
2201 ffestw_update (NULL);
2206 /* ffestc_order_bad_ -- Whine about statement ordering violation
2208 ffestc_order_bad_();
2210 Uses current ffesta_tokens[0] and, if available, info on where current
2211 state started to produce generic message. Someday we should do
2212 fancier things than this, but this just gets things creaking along for
2216 ffestc_order_bad_ ()
2218 if (ffewhere_line_is_unknown (ffestw_line (ffestw_stack_top ())))
2220 ffebad_start (FFEBAD_ORDER_1);
2221 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
2222 ffelex_token_where_column (ffesta_tokens[0]));
2227 ffebad_start (FFEBAD_ORDER_2);
2228 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
2229 ffelex_token_where_column (ffesta_tokens[0]));
2230 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
2233 ffestc_labeldef_useless_ (); /* Any label definition is useless. */
2236 /* ffestc_order_blockdata_ -- Check ordering on <blockdata> statement
2238 if (ffestc_order_blockdata_() != FFESTC_orderOK_)
2242 ffestc_order_blockdata_ ()
2246 switch (ffestw_state (ffestw_stack_top ()))
2248 case FFESTV_stateBLOCKDATA0:
2249 case FFESTV_stateBLOCKDATA1:
2250 case FFESTV_stateBLOCKDATA2:
2251 case FFESTV_stateBLOCKDATA3:
2252 case FFESTV_stateBLOCKDATA4:
2253 case FFESTV_stateBLOCKDATA5:
2254 return FFESTC_orderOK_;
2256 case FFESTV_stateUSE:
2258 ffestc_shriek_end_uses_ (TRUE);
2260 goto recurse; /* :::::::::::::::::::: */
2262 case FFESTV_stateWHERE:
2263 ffestc_order_bad_ ();
2265 ffestc_shriek_where_ (FALSE);
2267 return FFESTC_orderBAD_;
2269 case FFESTV_stateIF:
2270 ffestc_order_bad_ ();
2271 ffestc_shriek_if_ (FALSE);
2272 return FFESTC_orderBAD_;
2275 ffestc_order_bad_ ();
2276 return FFESTC_orderBAD_;
2280 /* ffestc_order_blockspec_ -- Check ordering on <blockspec> statement
2282 if (ffestc_order_blockspec_() != FFESTC_orderOK_)
2286 ffestc_order_blockspec_ ()
2290 switch (ffestw_state (ffestw_stack_top ()))
2292 case FFESTV_stateNIL:
2293 ffestc_shriek_begin_program_ ();
2294 goto recurse; /* :::::::::::::::::::: */
2296 case FFESTV_statePROGRAM0:
2297 case FFESTV_statePROGRAM1:
2298 case FFESTV_statePROGRAM2:
2299 ffestw_update (NULL);
2300 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM3);
2301 return FFESTC_orderOK_;
2303 case FFESTV_stateSUBROUTINE0:
2304 case FFESTV_stateSUBROUTINE1:
2305 case FFESTV_stateSUBROUTINE2:
2306 ffestw_update (NULL);
2307 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE3);
2308 return FFESTC_orderOK_;
2310 case FFESTV_stateFUNCTION0:
2311 case FFESTV_stateFUNCTION1:
2312 case FFESTV_stateFUNCTION2:
2313 ffestw_update (NULL);
2314 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION3);
2315 return FFESTC_orderOK_;
2317 case FFESTV_stateMODULE0:
2318 case FFESTV_stateMODULE1:
2319 case FFESTV_stateMODULE2:
2320 ffestw_update (NULL);
2321 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE3);
2322 return FFESTC_orderOK_;
2324 case FFESTV_stateBLOCKDATA0:
2325 case FFESTV_stateBLOCKDATA1:
2326 case FFESTV_stateBLOCKDATA2:
2327 ffestw_update (NULL);
2328 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA3);
2329 return FFESTC_orderOK_;
2331 case FFESTV_statePROGRAM3:
2332 case FFESTV_stateSUBROUTINE3:
2333 case FFESTV_stateFUNCTION3:
2334 case FFESTV_stateMODULE3:
2335 case FFESTV_stateBLOCKDATA3:
2336 return FFESTC_orderOK_;
2338 case FFESTV_stateUSE:
2340 ffestc_shriek_end_uses_ (TRUE);
2342 goto recurse; /* :::::::::::::::::::: */
2344 case FFESTV_stateWHERE:
2345 ffestc_order_bad_ ();
2347 ffestc_shriek_where_ (FALSE);
2349 return FFESTC_orderBAD_;
2351 case FFESTV_stateIF:
2352 ffestc_order_bad_ ();
2353 ffestc_shriek_if_ (FALSE);
2354 return FFESTC_orderBAD_;
2357 ffestc_order_bad_ ();
2358 return FFESTC_orderBAD_;
2362 /* ffestc_order_component_ -- Check ordering on <component-decl> statement
2364 if (ffestc_order_component_() != FFESTC_orderOK_)
2369 ffestc_order_component_ ()
2371 switch (ffestw_state (ffestw_stack_top ()))
2373 case FFESTV_stateTYPE:
2374 case FFESTV_stateSTRUCTURE:
2375 case FFESTV_stateMAP:
2376 return FFESTC_orderOK_;
2378 case FFESTV_stateWHERE:
2379 ffestc_order_bad_ ();
2380 ffestc_shriek_where_ (FALSE);
2381 return FFESTC_orderBAD_;
2383 case FFESTV_stateIF:
2384 ffestc_order_bad_ ();
2385 ffestc_shriek_if_ (FALSE);
2386 return FFESTC_orderBAD_;
2389 ffestc_order_bad_ ();
2390 return FFESTC_orderBAD_;
2395 /* ffestc_order_contains_ -- Check ordering on CONTAINS statement
2397 if (ffestc_order_contains_() != FFESTC_orderOK_)
2402 ffestc_order_contains_ ()
2406 switch (ffestw_state (ffestw_stack_top ()))
2408 case FFESTV_stateNIL:
2409 ffestc_shriek_begin_program_ ();
2410 goto recurse; /* :::::::::::::::::::: */
2412 case FFESTV_statePROGRAM0:
2413 case FFESTV_statePROGRAM1:
2414 case FFESTV_statePROGRAM2:
2415 case FFESTV_statePROGRAM3:
2416 case FFESTV_statePROGRAM4:
2417 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM5);
2420 case FFESTV_stateSUBROUTINE0:
2421 case FFESTV_stateSUBROUTINE1:
2422 case FFESTV_stateSUBROUTINE2:
2423 case FFESTV_stateSUBROUTINE3:
2424 case FFESTV_stateSUBROUTINE4:
2425 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE5);
2428 case FFESTV_stateFUNCTION0:
2429 case FFESTV_stateFUNCTION1:
2430 case FFESTV_stateFUNCTION2:
2431 case FFESTV_stateFUNCTION3:
2432 case FFESTV_stateFUNCTION4:
2433 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION5);
2436 case FFESTV_stateMODULE0:
2437 case FFESTV_stateMODULE1:
2438 case FFESTV_stateMODULE2:
2439 case FFESTV_stateMODULE3:
2440 case FFESTV_stateMODULE4:
2441 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE5);
2444 case FFESTV_stateUSE:
2445 ffestc_shriek_end_uses_ (TRUE);
2446 goto recurse; /* :::::::::::::::::::: */
2448 case FFESTV_stateWHERE:
2449 ffestc_order_bad_ ();
2450 ffestc_shriek_where_ (FALSE);
2451 return FFESTC_orderBAD_;
2453 case FFESTV_stateIF:
2454 ffestc_order_bad_ ();
2455 ffestc_shriek_if_ (FALSE);
2456 return FFESTC_orderBAD_;
2459 ffestc_order_bad_ ();
2460 return FFESTC_orderBAD_;
2463 switch (ffestw_state (ffestw_previous (ffestw_stack_top ())))
2465 case FFESTV_stateNIL:
2466 ffestw_update (NULL);
2467 return FFESTC_orderOK_;
2470 ffestc_order_bad_ ();
2471 ffestw_update (NULL);
2472 return FFESTC_orderBAD_;
2477 /* ffestc_order_data_ -- Check ordering on DATA statement
2479 if (ffestc_order_data_() != FFESTC_orderOK_)
2483 ffestc_order_data_ ()
2487 switch (ffestw_state (ffestw_stack_top ()))
2489 case FFESTV_stateNIL:
2490 ffestc_shriek_begin_program_ ();
2491 goto recurse; /* :::::::::::::::::::: */
2493 case FFESTV_statePROGRAM0:
2494 case FFESTV_statePROGRAM1:
2495 ffestw_update (NULL);
2496 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM2);
2497 return FFESTC_orderOK_;
2499 case FFESTV_stateSUBROUTINE0:
2500 case FFESTV_stateSUBROUTINE1:
2501 ffestw_update (NULL);
2502 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE2);
2503 return FFESTC_orderOK_;
2505 case FFESTV_stateFUNCTION0:
2506 case FFESTV_stateFUNCTION1:
2507 ffestw_update (NULL);
2508 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION2);
2509 return FFESTC_orderOK_;
2511 case FFESTV_stateBLOCKDATA0:
2512 case FFESTV_stateBLOCKDATA1:
2513 ffestw_update (NULL);
2514 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA2);
2515 return FFESTC_orderOK_;
2517 case FFESTV_statePROGRAM2:
2518 case FFESTV_stateSUBROUTINE2:
2519 case FFESTV_stateFUNCTION2:
2520 case FFESTV_stateBLOCKDATA2:
2521 case FFESTV_statePROGRAM3:
2522 case FFESTV_stateSUBROUTINE3:
2523 case FFESTV_stateFUNCTION3:
2524 case FFESTV_stateBLOCKDATA3:
2525 case FFESTV_statePROGRAM4:
2526 case FFESTV_stateSUBROUTINE4:
2527 case FFESTV_stateFUNCTION4:
2528 case FFESTV_stateBLOCKDATA4:
2529 case FFESTV_stateWHERETHEN:
2530 case FFESTV_stateIFTHEN:
2531 case FFESTV_stateDO:
2532 case FFESTV_stateSELECT0:
2533 case FFESTV_stateSELECT1:
2534 return FFESTC_orderOK_;
2536 case FFESTV_stateUSE:
2538 ffestc_shriek_end_uses_ (TRUE);
2540 goto recurse; /* :::::::::::::::::::: */
2542 case FFESTV_stateWHERE:
2543 ffestc_order_bad_ ();
2545 ffestc_shriek_where_ (FALSE);
2547 return FFESTC_orderBAD_;
2549 case FFESTV_stateIF:
2550 ffestc_order_bad_ ();
2551 ffestc_shriek_if_ (FALSE);
2552 return FFESTC_orderBAD_;
2555 ffestc_order_bad_ ();
2556 return FFESTC_orderBAD_;
2560 /* ffestc_order_data77_ -- Check ordering on pedantic-F77 DATA statement
2562 if (ffestc_order_data77_() != FFESTC_orderOK_)
2566 ffestc_order_data77_ ()
2570 switch (ffestw_state (ffestw_stack_top ()))
2572 case FFESTV_stateNIL:
2573 ffestc_shriek_begin_program_ ();
2574 goto recurse; /* :::::::::::::::::::: */
2576 case FFESTV_statePROGRAM0:
2577 case FFESTV_statePROGRAM1:
2578 case FFESTV_statePROGRAM2:
2579 case FFESTV_statePROGRAM3:
2580 ffestw_update (NULL);
2581 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM4);
2582 return FFESTC_orderOK_;
2584 case FFESTV_stateSUBROUTINE0:
2585 case FFESTV_stateSUBROUTINE1:
2586 case FFESTV_stateSUBROUTINE2:
2587 case FFESTV_stateSUBROUTINE3:
2588 ffestw_update (NULL);
2589 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE4);
2590 return FFESTC_orderOK_;
2592 case FFESTV_stateFUNCTION0:
2593 case FFESTV_stateFUNCTION1:
2594 case FFESTV_stateFUNCTION2:
2595 case FFESTV_stateFUNCTION3:
2596 ffestw_update (NULL);
2597 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION4);
2598 return FFESTC_orderOK_;
2600 case FFESTV_stateBLOCKDATA0:
2601 case FFESTV_stateBLOCKDATA1:
2602 case FFESTV_stateBLOCKDATA2:
2603 case FFESTV_stateBLOCKDATA3:
2604 ffestw_update (NULL);
2605 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA4);
2606 return FFESTC_orderOK_;
2608 case FFESTV_statePROGRAM4:
2609 case FFESTV_stateSUBROUTINE4:
2610 case FFESTV_stateFUNCTION4:
2611 case FFESTV_stateBLOCKDATA4:
2612 return FFESTC_orderOK_;
2614 case FFESTV_stateWHERETHEN:
2615 case FFESTV_stateIFTHEN:
2616 case FFESTV_stateDO:
2617 case FFESTV_stateSELECT0:
2618 case FFESTV_stateSELECT1:
2619 return FFESTC_orderOK_;
2621 case FFESTV_stateUSE:
2623 ffestc_shriek_end_uses_ (TRUE);
2625 goto recurse; /* :::::::::::::::::::: */
2627 case FFESTV_stateWHERE:
2628 ffestc_order_bad_ ();
2630 ffestc_shriek_where_ (FALSE);
2632 return FFESTC_orderBAD_;
2634 case FFESTV_stateIF:
2635 ffestc_order_bad_ ();
2636 ffestc_shriek_if_ (FALSE);
2637 return FFESTC_orderBAD_;
2640 ffestc_order_bad_ ();
2641 return FFESTC_orderBAD_;
2645 /* ffestc_order_derivedtype_ -- Check ordering on derived TYPE statement
2647 if (ffestc_order_derivedtype_() != FFESTC_orderOK_)
2652 ffestc_order_derivedtype_ ()
2656 switch (ffestw_state (ffestw_stack_top ()))
2658 case FFESTV_stateNIL:
2659 ffestc_shriek_begin_program_ ();
2660 goto recurse; /* :::::::::::::::::::: */
2662 case FFESTV_statePROGRAM0:
2663 case FFESTV_statePROGRAM1:
2664 case FFESTV_statePROGRAM2:
2665 ffestw_update (NULL);
2666 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM3);
2667 return FFESTC_orderOK_;
2669 case FFESTV_stateSUBROUTINE0:
2670 case FFESTV_stateSUBROUTINE1:
2671 case FFESTV_stateSUBROUTINE2:
2672 ffestw_update (NULL);
2673 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE3);
2674 return FFESTC_orderOK_;
2676 case FFESTV_stateFUNCTION0:
2677 case FFESTV_stateFUNCTION1:
2678 case FFESTV_stateFUNCTION2:
2679 ffestw_update (NULL);
2680 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION3);
2681 return FFESTC_orderOK_;
2683 case FFESTV_stateMODULE0:
2684 case FFESTV_stateMODULE1:
2685 case FFESTV_stateMODULE2:
2686 ffestw_update (NULL);
2687 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE3);
2688 return FFESTC_orderOK_;
2690 case FFESTV_statePROGRAM3:
2691 case FFESTV_stateSUBROUTINE3:
2692 case FFESTV_stateFUNCTION3:
2693 case FFESTV_stateMODULE3:
2694 return FFESTC_orderOK_;
2696 case FFESTV_stateUSE:
2697 ffestc_shriek_end_uses_ (TRUE);
2698 goto recurse; /* :::::::::::::::::::: */
2700 case FFESTV_stateWHERE:
2701 ffestc_order_bad_ ();
2702 ffestc_shriek_where_ (FALSE);
2703 return FFESTC_orderBAD_;
2705 case FFESTV_stateIF:
2706 ffestc_order_bad_ ();
2707 ffestc_shriek_if_ (FALSE);
2708 return FFESTC_orderBAD_;
2711 ffestc_order_bad_ ();
2712 return FFESTC_orderBAD_;
2717 /* ffestc_order_do_ -- Check ordering on <do> statement
2719 if (ffestc_order_do_() != FFESTC_orderOK_)
2725 switch (ffestw_state (ffestw_stack_top ()))
2727 case FFESTV_stateDO:
2728 return FFESTC_orderOK_;
2730 case FFESTV_stateWHERE:
2731 ffestc_order_bad_ ();
2733 ffestc_shriek_where_ (FALSE);
2735 return FFESTC_orderBAD_;
2737 case FFESTV_stateIF:
2738 ffestc_order_bad_ ();
2739 ffestc_shriek_if_ (FALSE);
2740 return FFESTC_orderBAD_;
2743 ffestc_order_bad_ ();
2744 return FFESTC_orderBAD_;
2748 /* ffestc_order_entry_ -- Check ordering on ENTRY statement
2750 if (ffestc_order_entry_() != FFESTC_orderOK_)
2754 ffestc_order_entry_ ()
2758 switch (ffestw_state (ffestw_stack_top ()))
2760 case FFESTV_stateNIL:
2761 ffestc_shriek_begin_program_ ();
2762 goto recurse; /* :::::::::::::::::::: */
2764 case FFESTV_stateSUBROUTINE0:
2765 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE1);
2768 case FFESTV_stateFUNCTION0:
2769 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION1);
2772 case FFESTV_stateSUBROUTINE1:
2773 case FFESTV_stateSUBROUTINE2:
2774 case FFESTV_stateFUNCTION1:
2775 case FFESTV_stateFUNCTION2:
2776 case FFESTV_stateSUBROUTINE3:
2777 case FFESTV_stateFUNCTION3:
2778 case FFESTV_stateSUBROUTINE4:
2779 case FFESTV_stateFUNCTION4:
2782 case FFESTV_stateUSE:
2784 ffestc_shriek_end_uses_ (TRUE);
2786 goto recurse; /* :::::::::::::::::::: */
2788 case FFESTV_stateWHERE:
2789 ffestc_order_bad_ ();
2791 ffestc_shriek_where_ (FALSE);
2793 return FFESTC_orderBAD_;
2795 case FFESTV_stateIF:
2796 ffestc_order_bad_ ();
2797 ffestc_shriek_if_ (FALSE);
2798 return FFESTC_orderBAD_;
2801 ffestc_order_bad_ ();
2802 return FFESTC_orderBAD_;
2805 switch (ffestw_state (ffestw_previous (ffestw_stack_top ())))
2807 case FFESTV_stateNIL:
2808 case FFESTV_stateMODULE5:
2809 ffestw_update (NULL);
2810 return FFESTC_orderOK_;
2813 ffestc_order_bad_ ();
2814 ffestw_update (NULL);
2815 return FFESTC_orderBAD_;
2819 /* ffestc_order_exec_ -- Check ordering on <exec> statement
2821 if (ffestc_order_exec_() != FFESTC_orderOK_)
2825 ffestc_order_exec_ ()
2831 switch (ffestw_state (ffestw_stack_top ()))
2833 case FFESTV_stateNIL:
2834 ffestc_shriek_begin_program_ ();
2835 goto recurse; /* :::::::::::::::::::: */
2837 case FFESTV_statePROGRAM0:
2838 case FFESTV_statePROGRAM1:
2839 case FFESTV_statePROGRAM2:
2840 case FFESTV_statePROGRAM3:
2841 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM4);
2845 case FFESTV_stateSUBROUTINE0:
2846 case FFESTV_stateSUBROUTINE1:
2847 case FFESTV_stateSUBROUTINE2:
2848 case FFESTV_stateSUBROUTINE3:
2849 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE4);
2853 case FFESTV_stateFUNCTION0:
2854 case FFESTV_stateFUNCTION1:
2855 case FFESTV_stateFUNCTION2:
2856 case FFESTV_stateFUNCTION3:
2857 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION4);
2861 case FFESTV_statePROGRAM4:
2862 case FFESTV_stateSUBROUTINE4:
2863 case FFESTV_stateFUNCTION4:
2867 case FFESTV_stateIFTHEN:
2868 case FFESTV_stateDO:
2869 case FFESTV_stateSELECT1:
2870 return FFESTC_orderOK_;
2872 case FFESTV_stateUSE:
2874 ffestc_shriek_end_uses_ (TRUE);
2876 goto recurse; /* :::::::::::::::::::: */
2878 case FFESTV_stateWHERE:
2879 ffestc_order_bad_ ();
2881 ffestc_shriek_where_ (FALSE);
2883 return FFESTC_orderBAD_;
2885 case FFESTV_stateIF:
2886 ffestc_order_bad_ ();
2887 ffestc_shriek_if_ (FALSE);
2888 return FFESTC_orderBAD_;
2891 ffestc_order_bad_ ();
2892 return FFESTC_orderBAD_;
2895 switch (ffestw_state (ffestw_previous (ffestw_stack_top ())))
2897 case FFESTV_stateINTERFACE0:
2898 ffestc_order_bad_ ();
2900 ffestw_update (NULL);
2901 return FFESTC_orderBAD_;
2905 ffestw_update (NULL);
2906 return FFESTC_orderOK_;
2910 /* ffestc_order_format_ -- Check ordering on FORMAT statement
2912 if (ffestc_order_format_() != FFESTC_orderOK_)
2916 ffestc_order_format_ ()
2920 switch (ffestw_state (ffestw_stack_top ()))
2922 case FFESTV_stateNIL:
2923 ffestc_shriek_begin_program_ ();
2924 goto recurse; /* :::::::::::::::::::: */
2926 case FFESTV_statePROGRAM0:
2927 ffestw_update (NULL);
2928 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM1);
2929 return FFESTC_orderOK_;
2931 case FFESTV_stateSUBROUTINE0:
2932 ffestw_update (NULL);
2933 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE1);
2934 return FFESTC_orderOK_;
2936 case FFESTV_stateFUNCTION0:
2937 ffestw_update (NULL);
2938 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION1);
2939 return FFESTC_orderOK_;
2941 case FFESTV_statePROGRAM1:
2942 case FFESTV_statePROGRAM2:
2943 case FFESTV_stateSUBROUTINE1:
2944 case FFESTV_stateSUBROUTINE2:
2945 case FFESTV_stateFUNCTION1:
2946 case FFESTV_stateFUNCTION2:
2947 case FFESTV_statePROGRAM3:
2948 case FFESTV_stateSUBROUTINE3:
2949 case FFESTV_stateFUNCTION3:
2950 case FFESTV_statePROGRAM4:
2951 case FFESTV_stateSUBROUTINE4:
2952 case FFESTV_stateFUNCTION4:
2953 case FFESTV_stateWHERETHEN:
2954 case FFESTV_stateIFTHEN:
2955 case FFESTV_stateDO:
2956 case FFESTV_stateSELECT0:
2957 case FFESTV_stateSELECT1:
2958 return FFESTC_orderOK_;
2960 case FFESTV_stateUSE:
2962 ffestc_shriek_end_uses_ (TRUE);
2964 goto recurse; /* :::::::::::::::::::: */
2966 case FFESTV_stateWHERE:
2967 ffestc_order_bad_ ();
2969 ffestc_shriek_where_ (FALSE);
2971 return FFESTC_orderBAD_;
2973 case FFESTV_stateIF:
2974 ffestc_order_bad_ ();
2975 ffestc_shriek_if_ (FALSE);
2976 return FFESTC_orderBAD_;
2979 ffestc_order_bad_ ();
2980 return FFESTC_orderBAD_;
2984 /* ffestc_order_function_ -- Check ordering on <function> statement
2986 if (ffestc_order_function_() != FFESTC_orderOK_)
2990 ffestc_order_function_ ()
2994 switch (ffestw_state (ffestw_stack_top ()))
2996 case FFESTV_stateFUNCTION0:
2997 case FFESTV_stateFUNCTION1:
2998 case FFESTV_stateFUNCTION2:
2999 case FFESTV_stateFUNCTION3:
3000 case FFESTV_stateFUNCTION4:
3001 case FFESTV_stateFUNCTION5:
3002 return FFESTC_orderOK_;
3004 case FFESTV_stateUSE:
3006 ffestc_shriek_end_uses_ (TRUE);
3008 goto recurse; /* :::::::::::::::::::: */
3010 case FFESTV_stateWHERE:
3011 ffestc_order_bad_ ();
3013 ffestc_shriek_where_ (FALSE);
3015 return FFESTC_orderBAD_;
3017 case FFESTV_stateIF:
3018 ffestc_order_bad_ ();
3019 ffestc_shriek_if_ (FALSE);
3020 return FFESTC_orderBAD_;
3023 ffestc_order_bad_ ();
3024 return FFESTC_orderBAD_;
3028 /* ffestc_order_iface_ -- Check ordering on <iface> statement
3030 if (ffestc_order_iface_() != FFESTC_orderOK_)
3034 ffestc_order_iface_ ()
3036 switch (ffestw_state (ffestw_stack_top ()))
3038 case FFESTV_stateNIL:
3039 case FFESTV_statePROGRAM5:
3040 case FFESTV_stateSUBROUTINE5:
3041 case FFESTV_stateFUNCTION5:
3042 case FFESTV_stateMODULE5:
3043 case FFESTV_stateINTERFACE0:
3044 return FFESTC_orderOK_;
3046 case FFESTV_stateWHERE:
3047 ffestc_order_bad_ ();
3049 ffestc_shriek_where_ (FALSE);
3051 return FFESTC_orderBAD_;
3053 case FFESTV_stateIF:
3054 ffestc_order_bad_ ();
3055 ffestc_shriek_if_ (FALSE);
3056 return FFESTC_orderBAD_;
3059 ffestc_order_bad_ ();
3060 return FFESTC_orderBAD_;
3064 /* ffestc_order_ifthen_ -- Check ordering on <ifthen> statement
3066 if (ffestc_order_ifthen_() != FFESTC_orderOK_)
3070 ffestc_order_ifthen_ ()
3072 switch (ffestw_state (ffestw_stack_top ()))
3074 case FFESTV_stateIFTHEN:
3075 return FFESTC_orderOK_;
3077 case FFESTV_stateWHERE:
3078 ffestc_order_bad_ ();
3080 ffestc_shriek_where_ (FALSE);
3082 return FFESTC_orderBAD_;
3084 case FFESTV_stateIF:
3085 ffestc_order_bad_ ();
3086 ffestc_shriek_if_ (FALSE);
3087 return FFESTC_orderBAD_;
3090 ffestc_order_bad_ ();
3091 return FFESTC_orderBAD_;
3095 /* ffestc_order_implicit_ -- Check ordering on IMPLICIT statement
3097 if (ffestc_order_implicit_() != FFESTC_orderOK_)
3101 ffestc_order_implicit_ ()
3105 switch (ffestw_state (ffestw_stack_top ()))
3107 case FFESTV_stateNIL:
3108 ffestc_shriek_begin_program_ ();
3109 goto recurse; /* :::::::::::::::::::: */
3111 case FFESTV_statePROGRAM0:
3112 case FFESTV_statePROGRAM1:
3113 ffestw_update (NULL);
3114 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM2);
3115 return FFESTC_orderOK_;
3117 case FFESTV_stateSUBROUTINE0:
3118 case FFESTV_stateSUBROUTINE1:
3119 ffestw_update (NULL);
3120 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE2);
3121 return FFESTC_orderOK_;
3123 case FFESTV_stateFUNCTION0:
3124 case FFESTV_stateFUNCTION1:
3125 ffestw_update (NULL);
3126 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION2);
3127 return FFESTC_orderOK_;
3129 case FFESTV_stateMODULE0:
3130 case FFESTV_stateMODULE1:
3131 ffestw_update (NULL);
3132 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE2);
3133 return FFESTC_orderOK_;
3135 case FFESTV_stateBLOCKDATA0:
3136 case FFESTV_stateBLOCKDATA1:
3137 ffestw_update (NULL);
3138 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA2);
3139 return FFESTC_orderOK_;
3141 case FFESTV_statePROGRAM2:
3142 case FFESTV_stateSUBROUTINE2:
3143 case FFESTV_stateFUNCTION2:
3144 case FFESTV_stateMODULE2:
3145 case FFESTV_stateBLOCKDATA2:
3146 return FFESTC_orderOK_;
3148 case FFESTV_stateUSE:
3150 ffestc_shriek_end_uses_ (TRUE);
3152 goto recurse; /* :::::::::::::::::::: */
3154 case FFESTV_stateWHERE:
3155 ffestc_order_bad_ ();
3157 ffestc_shriek_where_ (FALSE);
3159 return FFESTC_orderBAD_;
3161 case FFESTV_stateIF:
3162 ffestc_order_bad_ ();
3163 ffestc_shriek_if_ (FALSE);
3164 return FFESTC_orderBAD_;
3167 ffestc_order_bad_ ();
3168 return FFESTC_orderBAD_;
3172 /* ffestc_order_implicitnone_ -- Check ordering on IMPLICIT NONE statement
3174 if (ffestc_order_implicitnone_() != FFESTC_orderOK_)
3178 ffestc_order_implicitnone_ ()
3182 switch (ffestw_state (ffestw_stack_top ()))
3184 case FFESTV_stateNIL:
3185 ffestc_shriek_begin_program_ ();
3186 goto recurse; /* :::::::::::::::::::: */
3188 case FFESTV_statePROGRAM0:
3189 case FFESTV_statePROGRAM1:
3190 ffestw_update (NULL);
3191 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM3);
3192 return FFESTC_orderOK_;
3194 case FFESTV_stateSUBROUTINE0:
3195 case FFESTV_stateSUBROUTINE1:
3196 ffestw_update (NULL);
3197 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE3);
3198 return FFESTC_orderOK_;
3200 case FFESTV_stateFUNCTION0:
3201 case FFESTV_stateFUNCTION1:
3202 ffestw_update (NULL);
3203 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION3);
3204 return FFESTC_orderOK_;
3206 case FFESTV_stateMODULE0:
3207 case FFESTV_stateMODULE1:
3208 ffestw_update (NULL);
3209 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE3);
3210 return FFESTC_orderOK_;
3212 case FFESTV_stateBLOCKDATA0:
3213 case FFESTV_stateBLOCKDATA1:
3214 ffestw_update (NULL);
3215 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA3);
3216 return FFESTC_orderOK_;
3218 case FFESTV_stateUSE:
3220 ffestc_shriek_end_uses_ (TRUE);
3222 goto recurse; /* :::::::::::::::::::: */
3224 case FFESTV_stateWHERE:
3225 ffestc_order_bad_ ();
3227 ffestc_shriek_where_ (FALSE);
3229 return FFESTC_orderBAD_;
3231 case FFESTV_stateIF:
3232 ffestc_order_bad_ ();
3233 ffestc_shriek_if_ (FALSE);
3234 return FFESTC_orderBAD_;
3237 ffestc_order_bad_ ();
3238 return FFESTC_orderBAD_;
3242 /* ffestc_order_interface_ -- Check ordering on <interface> statement
3244 if (ffestc_order_interface_() != FFESTC_orderOK_)
3249 ffestc_order_interface_ ()
3251 switch (ffestw_state (ffestw_stack_top ()))
3253 case FFESTV_stateINTERFACE0:
3254 case FFESTV_stateINTERFACE1:
3255 return FFESTC_orderOK_;
3257 case FFESTV_stateWHERE:
3258 ffestc_order_bad_ ();
3259 ffestc_shriek_where_ (FALSE);
3260 return FFESTC_orderBAD_;
3262 case FFESTV_stateIF:
3263 ffestc_order_bad_ ();
3264 ffestc_shriek_if_ (FALSE);
3265 return FFESTC_orderBAD_;
3268 ffestc_order_bad_ ();
3269 return FFESTC_orderBAD_;
3274 /* ffestc_order_map_ -- Check ordering on <map> statement
3276 if (ffestc_order_map_() != FFESTC_orderOK_)
3281 ffestc_order_map_ ()
3283 switch (ffestw_state (ffestw_stack_top ()))
3285 case FFESTV_stateMAP:
3286 return FFESTC_orderOK_;
3288 case FFESTV_stateWHERE:
3289 ffestc_order_bad_ ();
3290 ffestc_shriek_where_ (FALSE);
3291 return FFESTC_orderBAD_;
3293 case FFESTV_stateIF:
3294 ffestc_order_bad_ ();
3295 ffestc_shriek_if_ (FALSE);
3296 return FFESTC_orderBAD_;
3299 ffestc_order_bad_ ();
3300 return FFESTC_orderBAD_;
3305 /* ffestc_order_module_ -- Check ordering on <module> statement
3307 if (ffestc_order_module_() != FFESTC_orderOK_)
3312 ffestc_order_module_ ()
3316 switch (ffestw_state (ffestw_stack_top ()))
3318 case FFESTV_stateMODULE0:
3319 case FFESTV_stateMODULE1:
3320 case FFESTV_stateMODULE2:
3321 case FFESTV_stateMODULE3:
3322 case FFESTV_stateMODULE4:
3323 case FFESTV_stateMODULE5:
3324 return FFESTC_orderOK_;
3326 case FFESTV_stateUSE:
3327 ffestc_shriek_end_uses_ (TRUE);
3328 goto recurse; /* :::::::::::::::::::: */
3330 case FFESTV_stateWHERE:
3331 ffestc_order_bad_ ();
3332 ffestc_shriek_where_ (FALSE);
3333 return FFESTC_orderBAD_;
3335 case FFESTV_stateIF:
3336 ffestc_order_bad_ ();
3337 ffestc_shriek_if_ (FALSE);
3338 return FFESTC_orderBAD_;
3341 ffestc_order_bad_ ();
3342 return FFESTC_orderBAD_;
3347 /* ffestc_order_parameter_ -- Check ordering on <parameter> statement
3349 if (ffestc_order_parameter_() != FFESTC_orderOK_)
3353 ffestc_order_parameter_ ()
3357 switch (ffestw_state (ffestw_stack_top ()))
3359 case FFESTV_stateNIL:
3360 ffestc_shriek_begin_program_ ();
3361 goto recurse; /* :::::::::::::::::::: */
3363 case FFESTV_statePROGRAM0:
3364 case FFESTV_statePROGRAM1:
3365 ffestw_update (NULL);
3366 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM2);
3367 return FFESTC_orderOK_;
3369 case FFESTV_stateSUBROUTINE0:
3370 case FFESTV_stateSUBROUTINE1:
3371 ffestw_update (NULL);
3372 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE2);
3373 return FFESTC_orderOK_;
3375 case FFESTV_stateFUNCTION0:
3376 case FFESTV_stateFUNCTION1:
3377 ffestw_update (NULL);
3378 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION2);
3379 return FFESTC_orderOK_;
3381 case FFESTV_stateMODULE0:
3382 case FFESTV_stateMODULE1:
3383 ffestw_update (NULL);
3384 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE2);
3385 return FFESTC_orderOK_;
3387 case FFESTV_stateBLOCKDATA0:
3388 case FFESTV_stateBLOCKDATA1:
3389 ffestw_update (NULL);
3390 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA2);
3391 return FFESTC_orderOK_;
3393 case FFESTV_statePROGRAM2:
3394 case FFESTV_stateSUBROUTINE2:
3395 case FFESTV_stateFUNCTION2:
3396 case FFESTV_stateMODULE2:
3397 case FFESTV_stateBLOCKDATA2:
3398 case FFESTV_statePROGRAM3:
3399 case FFESTV_stateSUBROUTINE3:
3400 case FFESTV_stateFUNCTION3:
3401 case FFESTV_stateMODULE3:
3402 case FFESTV_stateBLOCKDATA3:
3403 case FFESTV_stateTYPE: /* GNU extension here! */
3404 case FFESTV_stateSTRUCTURE:
3405 case FFESTV_stateUNION:
3406 case FFESTV_stateMAP:
3407 return FFESTC_orderOK_;
3409 case FFESTV_stateUSE:
3411 ffestc_shriek_end_uses_ (TRUE);
3413 goto recurse; /* :::::::::::::::::::: */
3415 case FFESTV_stateWHERE:
3416 ffestc_order_bad_ ();
3418 ffestc_shriek_where_ (FALSE);
3420 return FFESTC_orderBAD_;
3422 case FFESTV_stateIF:
3423 ffestc_order_bad_ ();
3424 ffestc_shriek_if_ (FALSE);
3425 return FFESTC_orderBAD_;
3428 ffestc_order_bad_ ();
3429 return FFESTC_orderBAD_;
3433 /* ffestc_order_program_ -- Check ordering on <program> statement
3435 if (ffestc_order_program_() != FFESTC_orderOK_)
3439 ffestc_order_program_ ()
3443 switch (ffestw_state (ffestw_stack_top ()))
3445 case FFESTV_stateNIL:
3446 ffestc_shriek_begin_program_ ();
3447 goto recurse; /* :::::::::::::::::::: */
3449 case FFESTV_statePROGRAM0:
3450 case FFESTV_statePROGRAM1:
3451 case FFESTV_statePROGRAM2:
3452 case FFESTV_statePROGRAM3:
3453 case FFESTV_statePROGRAM4:
3454 case FFESTV_statePROGRAM5:
3455 return FFESTC_orderOK_;
3457 case FFESTV_stateUSE:
3459 ffestc_shriek_end_uses_ (TRUE);
3461 goto recurse; /* :::::::::::::::::::: */
3463 case FFESTV_stateWHERE:
3464 ffestc_order_bad_ ();
3466 ffestc_shriek_where_ (FALSE);
3468 return FFESTC_orderBAD_;
3470 case FFESTV_stateIF:
3471 ffestc_order_bad_ ();
3472 ffestc_shriek_if_ (FALSE);
3473 return FFESTC_orderBAD_;
3476 ffestc_order_bad_ ();
3477 return FFESTC_orderBAD_;
3481 /* ffestc_order_progspec_ -- Check ordering on <progspec> statement
3483 if (ffestc_order_progspec_() != FFESTC_orderOK_)
3487 ffestc_order_progspec_ ()
3491 switch (ffestw_state (ffestw_stack_top ()))
3493 case FFESTV_stateNIL:
3494 ffestc_shriek_begin_program_ ();
3495 goto recurse; /* :::::::::::::::::::: */
3497 case FFESTV_statePROGRAM0:
3498 case FFESTV_statePROGRAM1:
3499 case FFESTV_statePROGRAM2:
3500 ffestw_update (NULL);
3501 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM3);
3502 return FFESTC_orderOK_;
3504 case FFESTV_stateSUBROUTINE0:
3505 case FFESTV_stateSUBROUTINE1:
3506 case FFESTV_stateSUBROUTINE2:
3507 ffestw_update (NULL);
3508 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE3);
3509 return FFESTC_orderOK_;
3511 case FFESTV_stateFUNCTION0:
3512 case FFESTV_stateFUNCTION1:
3513 case FFESTV_stateFUNCTION2:
3514 ffestw_update (NULL);
3515 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION3);
3516 return FFESTC_orderOK_;
3518 case FFESTV_stateMODULE0:
3519 case FFESTV_stateMODULE1:
3520 case FFESTV_stateMODULE2:
3521 ffestw_update (NULL);
3522 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE3);
3523 return FFESTC_orderOK_;
3525 case FFESTV_statePROGRAM3:
3526 case FFESTV_stateSUBROUTINE3:
3527 case FFESTV_stateFUNCTION3:
3528 case FFESTV_stateMODULE3:
3529 return FFESTC_orderOK_;
3531 case FFESTV_stateBLOCKDATA0:
3532 case FFESTV_stateBLOCKDATA1:
3533 case FFESTV_stateBLOCKDATA2:
3534 ffestw_update (NULL);
3535 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA2);
3536 if (ffe_is_pedantic ())
3538 ffebad_start (FFEBAD_BLOCKDATA_STMT);
3539 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
3540 ffelex_token_where_column (ffesta_tokens[0]));
3541 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
3544 return FFESTC_orderOK_;
3546 case FFESTV_stateUSE:
3548 ffestc_shriek_end_uses_ (TRUE);
3550 goto recurse; /* :::::::::::::::::::: */
3552 case FFESTV_stateWHERE:
3553 ffestc_order_bad_ ();
3555 ffestc_shriek_where_ (FALSE);
3557 return FFESTC_orderBAD_;
3559 case FFESTV_stateIF:
3560 ffestc_order_bad_ ();
3561 ffestc_shriek_if_ (FALSE);
3562 return FFESTC_orderBAD_;
3565 ffestc_order_bad_ ();
3566 return FFESTC_orderBAD_;
3570 /* ffestc_order_record_ -- Check ordering on RECORD statement
3572 if (ffestc_order_record_() != FFESTC_orderOK_)
3577 ffestc_order_record_ ()
3581 switch (ffestw_state (ffestw_stack_top ()))
3583 case FFESTV_stateNIL:
3584 ffestc_shriek_begin_program_ ();
3585 goto recurse; /* :::::::::::::::::::: */
3587 case FFESTV_statePROGRAM0:
3588 case FFESTV_statePROGRAM1:
3589 case FFESTV_statePROGRAM2:
3590 ffestw_update (NULL);
3591 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM3);
3592 return FFESTC_orderOK_;
3594 case FFESTV_stateSUBROUTINE0:
3595 case FFESTV_stateSUBROUTINE1:
3596 case FFESTV_stateSUBROUTINE2:
3597 ffestw_update (NULL);
3598 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE3);
3599 return FFESTC_orderOK_;
3601 case FFESTV_stateFUNCTION0:
3602 case FFESTV_stateFUNCTION1:
3603 case FFESTV_stateFUNCTION2:
3604 ffestw_update (NULL);
3605 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION3);
3606 return FFESTC_orderOK_;
3608 case FFESTV_stateMODULE0:
3609 case FFESTV_stateMODULE1:
3610 case FFESTV_stateMODULE2:
3611 ffestw_update (NULL);
3612 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE3);
3613 return FFESTC_orderOK_;
3615 case FFESTV_stateBLOCKDATA0:
3616 case FFESTV_stateBLOCKDATA1:
3617 case FFESTV_stateBLOCKDATA2:
3618 ffestw_update (NULL);
3619 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA3);
3620 return FFESTC_orderOK_;
3622 case FFESTV_statePROGRAM3:
3623 case FFESTV_stateSUBROUTINE3:
3624 case FFESTV_stateFUNCTION3:
3625 case FFESTV_stateMODULE3:
3626 case FFESTV_stateBLOCKDATA3:
3627 case FFESTV_stateSTRUCTURE:
3628 case FFESTV_stateMAP:
3629 return FFESTC_orderOK_;
3631 case FFESTV_stateUSE:
3633 ffestc_shriek_end_uses_ (TRUE);
3635 goto recurse; /* :::::::::::::::::::: */
3637 case FFESTV_stateWHERE:
3638 ffestc_order_bad_ ();
3640 ffestc_shriek_where_ (FALSE);
3642 return FFESTC_orderBAD_;
3644 case FFESTV_stateIF:
3645 ffestc_order_bad_ ();
3646 ffestc_shriek_if_ (FALSE);
3647 return FFESTC_orderBAD_;
3650 ffestc_order_bad_ ();
3651 return FFESTC_orderBAD_;
3656 /* ffestc_order_selectcase_ -- Check ordering on <selectcase> statement
3658 if (ffestc_order_selectcase_() != FFESTC_orderOK_)
3662 ffestc_order_selectcase_ ()
3664 switch (ffestw_state (ffestw_stack_top ()))
3666 case FFESTV_stateSELECT0:
3667 case FFESTV_stateSELECT1:
3668 return FFESTC_orderOK_;
3670 case FFESTV_stateWHERE:
3671 ffestc_order_bad_ ();
3673 ffestc_shriek_where_ (FALSE);
3675 return FFESTC_orderBAD_;
3677 case FFESTV_stateIF:
3678 ffestc_order_bad_ ();
3679 ffestc_shriek_if_ (FALSE);
3680 return FFESTC_orderBAD_;
3683 ffestc_order_bad_ ();
3684 return FFESTC_orderBAD_;
3688 /* ffestc_order_sfunc_ -- Check ordering on statement-function definition
3690 if (ffestc_order_sfunc_() != FFESTC_orderOK_)
3694 ffestc_order_sfunc_ ()
3698 switch (ffestw_state (ffestw_stack_top ()))
3700 case FFESTV_stateNIL:
3701 ffestc_shriek_begin_program_ ();
3702 goto recurse; /* :::::::::::::::::::: */
3704 case FFESTV_statePROGRAM0:
3705 case FFESTV_statePROGRAM1:
3706 case FFESTV_statePROGRAM2:
3707 ffestw_update (NULL);
3708 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM3);
3709 return FFESTC_orderOK_;
3711 case FFESTV_stateSUBROUTINE0:
3712 case FFESTV_stateSUBROUTINE1:
3713 case FFESTV_stateSUBROUTINE2:
3714 ffestw_update (NULL);
3715 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE3);
3716 return FFESTC_orderOK_;
3718 case FFESTV_stateFUNCTION0:
3719 case FFESTV_stateFUNCTION1:
3720 case FFESTV_stateFUNCTION2:
3721 ffestw_update (NULL);
3722 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION3);
3723 return FFESTC_orderOK_;
3725 case FFESTV_statePROGRAM3:
3726 case FFESTV_stateSUBROUTINE3:
3727 case FFESTV_stateFUNCTION3:
3728 return FFESTC_orderOK_;
3730 case FFESTV_stateUSE:
3732 ffestc_shriek_end_uses_ (TRUE);
3734 goto recurse; /* :::::::::::::::::::: */
3736 case FFESTV_stateWHERE:
3737 ffestc_order_bad_ ();
3739 ffestc_shriek_where_ (FALSE);
3741 return FFESTC_orderBAD_;
3743 case FFESTV_stateIF:
3744 ffestc_order_bad_ ();
3745 ffestc_shriek_if_ (FALSE);
3746 return FFESTC_orderBAD_;
3749 ffestc_order_bad_ ();
3750 return FFESTC_orderBAD_;
3754 /* ffestc_order_spec_ -- Check ordering on <spec> statement
3756 if (ffestc_order_spec_() != FFESTC_orderOK_)
3761 ffestc_order_spec_ ()
3765 switch (ffestw_state (ffestw_stack_top ()))
3767 case FFESTV_stateNIL:
3768 ffestc_shriek_begin_program_ ();
3769 goto recurse; /* :::::::::::::::::::: */
3771 case FFESTV_stateSUBROUTINE0:
3772 case FFESTV_stateSUBROUTINE1:
3773 case FFESTV_stateSUBROUTINE2:
3774 ffestw_update (NULL);
3775 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE3);
3776 return FFESTC_orderOK_;
3778 case FFESTV_stateFUNCTION0:
3779 case FFESTV_stateFUNCTION1:
3780 case FFESTV_stateFUNCTION2:
3781 ffestw_update (NULL);
3782 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION3);
3783 return FFESTC_orderOK_;
3785 case FFESTV_stateMODULE0:
3786 case FFESTV_stateMODULE1:
3787 case FFESTV_stateMODULE2:
3788 ffestw_update (NULL);
3789 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE3);
3790 return FFESTC_orderOK_;
3792 case FFESTV_stateSUBROUTINE3:
3793 case FFESTV_stateFUNCTION3:
3794 case FFESTV_stateMODULE3:
3795 return FFESTC_orderOK_;
3797 case FFESTV_stateUSE:
3799 ffestc_shriek_end_uses_ (TRUE);
3801 goto recurse; /* :::::::::::::::::::: */
3803 case FFESTV_stateWHERE:
3804 ffestc_order_bad_ ();
3806 ffestc_shriek_where_ (FALSE);
3808 return FFESTC_orderBAD_;
3810 case FFESTV_stateIF:
3811 ffestc_order_bad_ ();
3812 ffestc_shriek_if_ (FALSE);
3813 return FFESTC_orderBAD_;
3816 ffestc_order_bad_ ();
3817 return FFESTC_orderBAD_;
3822 /* ffestc_order_structure_ -- Check ordering on <structure> statement
3824 if (ffestc_order_structure_() != FFESTC_orderOK_)
3829 ffestc_order_structure_ ()
3831 switch (ffestw_state (ffestw_stack_top ()))
3833 case FFESTV_stateSTRUCTURE:
3834 return FFESTC_orderOK_;
3836 case FFESTV_stateWHERE:
3837 ffestc_order_bad_ ();
3839 ffestc_shriek_where_ (FALSE);
3841 return FFESTC_orderBAD_;
3843 case FFESTV_stateIF:
3844 ffestc_order_bad_ ();
3845 ffestc_shriek_if_ (FALSE);
3846 return FFESTC_orderBAD_;
3849 ffestc_order_bad_ ();
3850 return FFESTC_orderBAD_;
3855 /* ffestc_order_subroutine_ -- Check ordering on <subroutine> statement
3857 if (ffestc_order_subroutine_() != FFESTC_orderOK_)
3861 ffestc_order_subroutine_ ()
3865 switch (ffestw_state (ffestw_stack_top ()))
3867 case FFESTV_stateSUBROUTINE0:
3868 case FFESTV_stateSUBROUTINE1:
3869 case FFESTV_stateSUBROUTINE2:
3870 case FFESTV_stateSUBROUTINE3:
3871 case FFESTV_stateSUBROUTINE4:
3872 case FFESTV_stateSUBROUTINE5:
3873 return FFESTC_orderOK_;
3875 case FFESTV_stateUSE:
3877 ffestc_shriek_end_uses_ (TRUE);
3879 goto recurse; /* :::::::::::::::::::: */
3881 case FFESTV_stateWHERE:
3882 ffestc_order_bad_ ();
3884 ffestc_shriek_where_ (FALSE);
3886 return FFESTC_orderBAD_;
3888 case FFESTV_stateIF:
3889 ffestc_order_bad_ ();
3890 ffestc_shriek_if_ (FALSE);
3891 return FFESTC_orderBAD_;
3894 ffestc_order_bad_ ();
3895 return FFESTC_orderBAD_;
3899 /* ffestc_order_type_ -- Check ordering on <type> statement
3901 if (ffestc_order_type_() != FFESTC_orderOK_)
3906 ffestc_order_type_ ()
3908 switch (ffestw_state (ffestw_stack_top ()))
3910 case FFESTV_stateTYPE:
3911 return FFESTC_orderOK_;
3913 case FFESTV_stateWHERE:
3914 ffestc_order_bad_ ();
3915 ffestc_shriek_where_ (FALSE);
3916 return FFESTC_orderBAD_;
3918 case FFESTV_stateIF:
3919 ffestc_order_bad_ ();
3920 ffestc_shriek_if_ (FALSE);
3921 return FFESTC_orderBAD_;
3924 ffestc_order_bad_ ();
3925 return FFESTC_orderBAD_;
3930 /* ffestc_order_typedecl_ -- Check ordering on <typedecl> statement
3932 if (ffestc_order_typedecl_() != FFESTC_orderOK_)
3936 ffestc_order_typedecl_ ()
3940 switch (ffestw_state (ffestw_stack_top ()))
3942 case FFESTV_stateNIL:
3943 ffestc_shriek_begin_program_ ();
3944 goto recurse; /* :::::::::::::::::::: */
3946 case FFESTV_statePROGRAM0:
3947 case FFESTV_statePROGRAM1:
3948 case FFESTV_statePROGRAM2:
3949 ffestw_update (NULL);
3950 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM3);
3951 return FFESTC_orderOK_;
3953 case FFESTV_stateSUBROUTINE0:
3954 case FFESTV_stateSUBROUTINE1:
3955 case FFESTV_stateSUBROUTINE2:
3956 ffestw_update (NULL);
3957 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE3);
3958 return FFESTC_orderOK_;
3960 case FFESTV_stateFUNCTION0:
3961 case FFESTV_stateFUNCTION1:
3962 case FFESTV_stateFUNCTION2:
3963 ffestw_update (NULL);
3964 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION3);
3965 return FFESTC_orderOK_;
3967 case FFESTV_stateMODULE0:
3968 case FFESTV_stateMODULE1:
3969 case FFESTV_stateMODULE2:
3970 ffestw_update (NULL);
3971 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE3);
3972 return FFESTC_orderOK_;
3974 case FFESTV_stateBLOCKDATA0:
3975 case FFESTV_stateBLOCKDATA1:
3976 case FFESTV_stateBLOCKDATA2:
3977 ffestw_update (NULL);
3978 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA3);
3979 return FFESTC_orderOK_;
3981 case FFESTV_statePROGRAM3:
3982 case FFESTV_stateSUBROUTINE3:
3983 case FFESTV_stateFUNCTION3:
3984 case FFESTV_stateMODULE3:
3985 case FFESTV_stateBLOCKDATA3:
3986 return FFESTC_orderOK_;
3988 case FFESTV_stateUSE:
3990 ffestc_shriek_end_uses_ (TRUE);
3992 goto recurse; /* :::::::::::::::::::: */
3994 case FFESTV_stateWHERE:
3995 ffestc_order_bad_ ();
3997 ffestc_shriek_where_ (FALSE);
3999 return FFESTC_orderBAD_;
4001 case FFESTV_stateIF:
4002 ffestc_order_bad_ ();
4003 ffestc_shriek_if_ (FALSE);
4004 return FFESTC_orderBAD_;
4007 ffestc_order_bad_ ();
4008 return FFESTC_orderBAD_;
4012 /* ffestc_order_union_ -- Check ordering on <union> statement
4014 if (ffestc_order_union_() != FFESTC_orderOK_)
4019 ffestc_order_union_ ()
4021 switch (ffestw_state (ffestw_stack_top ()))
4023 case FFESTV_stateUNION:
4024 return FFESTC_orderOK_;
4026 case FFESTV_stateWHERE:
4027 ffestc_order_bad_ ();
4029 ffestc_shriek_where_ (FALSE);
4031 return FFESTC_orderBAD_;
4033 case FFESTV_stateIF:
4034 ffestc_order_bad_ ();
4035 ffestc_shriek_if_ (FALSE);
4036 return FFESTC_orderBAD_;
4039 ffestc_order_bad_ ();
4040 return FFESTC_orderBAD_;
4045 /* ffestc_order_unit_ -- Check ordering on <unit> statement
4047 if (ffestc_order_unit_() != FFESTC_orderOK_)
4051 ffestc_order_unit_ ()
4053 switch (ffestw_state (ffestw_stack_top ()))
4055 case FFESTV_stateNIL:
4056 return FFESTC_orderOK_;
4058 case FFESTV_stateWHERE:
4059 ffestc_order_bad_ ();
4061 ffestc_shriek_where_ (FALSE);
4063 return FFESTC_orderBAD_;
4065 case FFESTV_stateIF:
4066 ffestc_order_bad_ ();
4067 ffestc_shriek_if_ (FALSE);
4068 return FFESTC_orderBAD_;
4071 ffestc_order_bad_ ();
4072 return FFESTC_orderBAD_;
4076 /* ffestc_order_use_ -- Check ordering on USE statement
4078 if (ffestc_order_use_() != FFESTC_orderOK_)
4083 ffestc_order_use_ ()
4087 switch (ffestw_state (ffestw_stack_top ()))
4089 case FFESTV_stateNIL:
4090 ffestc_shriek_begin_program_ ();
4091 goto recurse; /* :::::::::::::::::::: */
4093 case FFESTV_statePROGRAM0:
4094 ffestw_update (NULL);
4095 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM1);
4096 ffestc_shriek_begin_uses_ ();
4097 goto recurse; /* :::::::::::::::::::: */
4099 case FFESTV_stateSUBROUTINE0:
4100 ffestw_update (NULL);
4101 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE1);
4102 ffestc_shriek_begin_uses_ ();
4103 goto recurse; /* :::::::::::::::::::: */
4105 case FFESTV_stateFUNCTION0:
4106 ffestw_update (NULL);
4107 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION1);
4108 ffestc_shriek_begin_uses_ ();
4109 goto recurse; /* :::::::::::::::::::: */
4111 case FFESTV_stateMODULE0:
4112 ffestw_update (NULL);
4113 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE1);
4114 ffestc_shriek_begin_uses_ ();
4115 goto recurse; /* :::::::::::::::::::: */
4117 case FFESTV_stateUSE:
4118 return FFESTC_orderOK_;
4120 case FFESTV_stateWHERE:
4121 ffestc_order_bad_ ();
4122 ffestc_shriek_where_ (FALSE);
4123 return FFESTC_orderBAD_;
4125 case FFESTV_stateIF:
4126 ffestc_order_bad_ ();
4127 ffestc_shriek_if_ (FALSE);
4128 return FFESTC_orderBAD_;
4131 ffestc_order_bad_ ();
4132 return FFESTC_orderBAD_;
4137 /* ffestc_order_vxtstructure_ -- Check ordering on STRUCTURE statement
4139 if (ffestc_order_vxtstructure_() != FFESTC_orderOK_)
4144 ffestc_order_vxtstructure_ ()
4148 switch (ffestw_state (ffestw_stack_top ()))
4150 case FFESTV_stateNIL:
4151 ffestc_shriek_begin_program_ ();
4152 goto recurse; /* :::::::::::::::::::: */
4154 case FFESTV_statePROGRAM0:
4155 case FFESTV_statePROGRAM1:
4156 case FFESTV_statePROGRAM2:
4157 ffestw_update (NULL);
4158 ffestw_set_state (ffestw_stack_top (), FFESTV_statePROGRAM3);
4159 return FFESTC_orderOK_;
4161 case FFESTV_stateSUBROUTINE0:
4162 case FFESTV_stateSUBROUTINE1:
4163 case FFESTV_stateSUBROUTINE2:
4164 ffestw_update (NULL);
4165 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSUBROUTINE3);
4166 return FFESTC_orderOK_;
4168 case FFESTV_stateFUNCTION0:
4169 case FFESTV_stateFUNCTION1:
4170 case FFESTV_stateFUNCTION2:
4171 ffestw_update (NULL);
4172 ffestw_set_state (ffestw_stack_top (), FFESTV_stateFUNCTION3);
4173 return FFESTC_orderOK_;
4175 case FFESTV_stateMODULE0:
4176 case FFESTV_stateMODULE1:
4177 case FFESTV_stateMODULE2:
4178 ffestw_update (NULL);
4179 ffestw_set_state (ffestw_stack_top (), FFESTV_stateMODULE3);
4180 return FFESTC_orderOK_;
4182 case FFESTV_stateBLOCKDATA0:
4183 case FFESTV_stateBLOCKDATA1:
4184 case FFESTV_stateBLOCKDATA2:
4185 ffestw_update (NULL);
4186 ffestw_set_state (ffestw_stack_top (), FFESTV_stateBLOCKDATA3);
4187 return FFESTC_orderOK_;
4189 case FFESTV_statePROGRAM3:
4190 case FFESTV_stateSUBROUTINE3:
4191 case FFESTV_stateFUNCTION3:
4192 case FFESTV_stateMODULE3:
4193 case FFESTV_stateBLOCKDATA3:
4194 case FFESTV_stateSTRUCTURE:
4195 case FFESTV_stateMAP:
4196 return FFESTC_orderOK_;
4198 case FFESTV_stateUSE:
4200 ffestc_shriek_end_uses_ (TRUE);
4202 goto recurse; /* :::::::::::::::::::: */
4204 case FFESTV_stateWHERE:
4205 ffestc_order_bad_ ();
4207 ffestc_shriek_where_ (FALSE);
4209 return FFESTC_orderBAD_;
4211 case FFESTV_stateIF:
4212 ffestc_order_bad_ ();
4213 ffestc_shriek_if_ (FALSE);
4214 return FFESTC_orderBAD_;
4217 ffestc_order_bad_ ();
4218 return FFESTC_orderBAD_;
4223 /* ffestc_order_where_ -- Check ordering on <where> statement
4225 if (ffestc_order_where_() != FFESTC_orderOK_)
4230 ffestc_order_where_ ()
4232 switch (ffestw_state (ffestw_stack_top ()))
4234 case FFESTV_stateWHERETHEN:
4235 return FFESTC_orderOK_;
4237 case FFESTV_stateWHERE:
4238 ffestc_order_bad_ ();
4239 ffestc_shriek_where_ (FALSE);
4240 return FFESTC_orderBAD_;
4242 case FFESTV_stateIF:
4243 ffestc_order_bad_ ();
4244 ffestc_shriek_if_ (FALSE);
4245 return FFESTC_orderBAD_;
4248 ffestc_order_bad_ ();
4249 return FFESTC_orderBAD_;
4254 /* Invoked for each token in dummy arg list of FUNCTION, SUBROUTINE, and
4255 ENTRY (prior to the first executable statement). */
4258 ffestc_promote_dummy_ (ffelexToken t)
4268 if (ffelex_token_type (t) == FFELEX_typeASTERISK)
4270 ffebld_append_item (&ffestc_local_.dummy.list_bottom,
4271 ffebld_new_star ());
4272 return; /* Don't bother with alternate returns! */
4275 s = ffesymbol_declare_local (t, FALSE);
4276 sa = ffesymbol_attrs (s);
4278 /* Figure out what kind of object we've got based on previous declarations
4279 of or references to the object. */
4283 if (sa & FFESYMBOL_attrsANY)
4285 else if (sa & FFESYMBOL_attrsDUMMY)
4287 if (ffestc_entry_num_ == ffesymbol_maxentrynum (s))
4288 { /* Seen this one twice in this list! */
4289 na = FFESYMBOL_attrsetNONE;
4293 sfref_ok = TRUE; /* Ok for sym to be ref'd in sfuncdef
4294 previously, since already declared as a
4297 else if (!(sa & ~(FFESYMBOL_attrsADJUSTABLE
4298 | FFESYMBOL_attrsADJUSTS
4299 | FFESYMBOL_attrsANY
4300 | FFESYMBOL_attrsANYLEN
4301 | FFESYMBOL_attrsANYSIZE
4302 | FFESYMBOL_attrsARRAY
4303 | FFESYMBOL_attrsDUMMY
4304 | FFESYMBOL_attrsEXTERNAL
4305 | FFESYMBOL_attrsSFARG
4306 | FFESYMBOL_attrsTYPE)))
4307 na = sa | FFESYMBOL_attrsDUMMY;
4309 na = FFESYMBOL_attrsetNONE;
4311 if (!ffesymbol_is_specable (s)
4313 || (ffesymbol_where (s) != FFEINFO_whereDUMMY)))
4314 na = FFESYMBOL_attrsetNONE; /* Can't dcl sym ref'd in sfuncdef. */
4316 /* Now see what we've got for a new object: NONE means a new error cropped
4317 up; ANY means an old error to be ignored; otherwise, everything's ok,
4318 update the object (symbol) and continue on. */
4320 if (na == FFESYMBOL_attrsetNONE)
4321 ffesymbol_error (s, t);
4322 else if (!(na & FFESYMBOL_attrsANY))
4324 ffesymbol_set_attrs (s, na);
4325 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
4326 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
4327 ffesymbol_set_maxentrynum (s, ffestc_entry_num_);
4328 ffesymbol_set_numentries (s, ffesymbol_numentries (s) + 1);
4329 e = ffebld_new_symter (s, FFEINTRIN_genNONE, FFEINTRIN_specNONE,
4332 ffeinfo_new (FFEINFO_basictypeNONE,
4333 FFEINFO_kindtypeNONE,
4337 FFETARGET_charactersizeNONE));
4338 ffebld_append_item (&ffestc_local_.dummy.list_bottom, e);
4339 ffesymbol_signal_unreported (s);
4343 /* ffestc_promote_execdummy_ -- Declare token as dummy variable in exec context
4345 ffestc_promote_execdummy_(t);
4347 Invoked for each token in dummy arg list of ENTRY when the statement
4348 follows the first executable statement. */
4351 ffestc_promote_execdummy_ (ffelexToken t)
4364 if (ffelex_token_type (t) == FFELEX_typeASTERISK)
4366 ffebld_append_item (&ffestc_local_.dummy.list_bottom,
4367 ffebld_new_star ());
4368 return; /* Don't bother with alternate returns! */
4371 s = ffesymbol_declare_local (t, FALSE);
4372 na = sa = ffesymbol_attrs (s);
4373 ss = ffesymbol_state (s);
4374 kind = ffesymbol_kind (s);
4375 where = ffesymbol_where (s);
4377 if (ffestc_entry_num_ == ffesymbol_maxentrynum (s))
4378 { /* Seen this one twice in this list! */
4379 na = FFESYMBOL_attrsetNONE;
4382 /* Figure out what kind of object we've got based on previous declarations
4383 of or references to the object. */
4385 ns = FFESYMBOL_stateUNDERSTOOD; /* Assume we know it all know. */
4389 case FFEINFO_kindENTITY:
4390 case FFEINFO_kindFUNCTION:
4391 case FFEINFO_kindSUBROUTINE:
4392 break; /* These are fine, as far as we know. */
4394 case FFEINFO_kindNONE:
4395 if (sa & FFESYMBOL_attrsDUMMY)
4396 ns = FFESYMBOL_stateUNCERTAIN; /* Learned nothing new. */
4397 else if (sa & FFESYMBOL_attrsANYLEN)
4399 kind = FFEINFO_kindENTITY;
4400 where = FFEINFO_whereDUMMY;
4402 else if (sa & FFESYMBOL_attrsACTUALARG)
4403 na = FFESYMBOL_attrsetNONE;
4406 na = sa | FFESYMBOL_attrsDUMMY;
4407 ns = FFESYMBOL_stateUNCERTAIN;
4412 na = FFESYMBOL_attrsetNONE; /* Error. */
4418 case FFEINFO_whereDUMMY:
4419 break; /* This is fine. */
4421 case FFEINFO_whereNONE:
4422 where = FFEINFO_whereDUMMY;
4426 na = FFESYMBOL_attrsetNONE; /* Error. */
4430 /* Now see what we've got for a new object: NONE means a new error cropped
4431 up; ANY means an old error to be ignored; otherwise, everything's ok,
4432 update the object (symbol) and continue on. */
4434 if (na == FFESYMBOL_attrsetNONE)
4435 ffesymbol_error (s, t);
4436 else if (!(na & FFESYMBOL_attrsANY))
4438 ffesymbol_set_attrs (s, na);
4439 ffesymbol_set_state (s, ns);
4440 ffesymbol_set_maxentrynum (s, ffestc_entry_num_);
4441 ffesymbol_set_numentries (s, ffesymbol_numentries (s) + 1);
4442 if ((ns == FFESYMBOL_stateUNDERSTOOD)
4443 && (kind != FFEINFO_kindSUBROUTINE)
4444 && !ffeimplic_establish_symbol (s))
4446 ffesymbol_error (s, t);
4449 ffesymbol_set_info (s,
4450 ffeinfo_new (ffesymbol_basictype (s),
4451 ffesymbol_kindtype (s),
4455 ffesymbol_size (s)));
4456 e = ffebld_new_symter (s, FFEINTRIN_genNONE, FFEINTRIN_specNONE,
4458 ffebld_set_info (e, ffeinfo_use (ffesymbol_info (s)));
4459 ffebld_append_item (&ffestc_local_.dummy.list_bottom, e);
4460 s = ffecom_sym_learned (s);
4461 ffesymbol_signal_unreported (s);
4465 /* ffestc_promote_sfdummy_ -- Declare token as stmt-func dummy variable
4467 ffestc_promote_sfdummy_(t);
4469 Invoked for each token in dummy arg list of statement function.
4472 Reject arg if CHARACTER*(*). */
4475 ffestc_promote_sfdummy_ (ffelexToken t)
4478 ffesymbol sp; /* Parent symbol. */
4485 s = ffesymbol_declare_sfdummy (t); /* Sets maxentrynum to 0 for new obj;
4486 also sets sfa_dummy_parent to
4488 if (ffesymbol_state (s) != FFESYMBOL_stateNONE)
4490 ffesymbol_error (s, t); /* Dummy already in list. */
4494 sp = ffesymbol_sfdummyparent (s); /* Now flag dummy's parent as used
4496 sa = ffesymbol_attrs (sp);
4498 /* Figure out what kind of object we've got based on previous declarations
4499 of or references to the object. */
4501 if (!ffesymbol_is_specable (sp)
4502 && ((ffesymbol_kind (sp) != FFEINFO_kindENTITY)
4503 || ((ffesymbol_where (sp) != FFEINFO_whereLOCAL)
4504 && (ffesymbol_where (sp) != FFEINFO_whereCOMMON)
4505 && (ffesymbol_where (sp) != FFEINFO_whereDUMMY)
4506 && (ffesymbol_where (sp) != FFEINFO_whereNONE))))
4507 na = FFESYMBOL_attrsetNONE; /* Can't be PARAMETER etc., must be a var. */
4508 else if (sa & FFESYMBOL_attrsANY)
4510 else if (!(sa & ~(FFESYMBOL_attrsADJUSTS
4511 | FFESYMBOL_attrsCOMMON
4512 | FFESYMBOL_attrsDUMMY
4513 | FFESYMBOL_attrsEQUIV
4514 | FFESYMBOL_attrsINIT
4515 | FFESYMBOL_attrsNAMELIST
4516 | FFESYMBOL_attrsRESULT
4517 | FFESYMBOL_attrsSAVE
4518 | FFESYMBOL_attrsSFARG
4519 | FFESYMBOL_attrsTYPE)))
4520 na = sa | FFESYMBOL_attrsSFARG;
4522 na = FFESYMBOL_attrsetNONE;
4524 /* Now see what we've got for a new object: NONE means a new error cropped
4525 up; ANY means an old error to be ignored; otherwise, everything's ok,
4526 update the object (symbol) and continue on. */
4528 if (na == FFESYMBOL_attrsetNONE)
4530 ffesymbol_error (sp, t);
4531 ffesymbol_set_info (s, ffeinfo_new_any ());
4533 else if (!(na & FFESYMBOL_attrsANY))
4535 ffesymbol_set_state (sp, FFESYMBOL_stateSEEN);
4536 ffesymbol_set_attrs (sp, na);
4537 if (!ffeimplic_establish_symbol (sp)
4538 || ((ffesymbol_basictype (sp) == FFEINFO_basictypeCHARACTER)
4539 && (ffesymbol_size (sp) == FFETARGET_charactersizeNONE)))
4540 ffesymbol_error (sp, t);
4542 ffesymbol_set_info (s,
4543 ffeinfo_new (ffesymbol_basictype (sp),
4544 ffesymbol_kindtype (sp),
4548 ffesymbol_size (sp)));
4550 ffesymbol_signal_unreported (sp);
4553 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
4554 ffesymbol_set_maxentrynum (s, ffestc_sfdummy_argno_++);
4555 ffesymbol_signal_unreported (s);
4556 e = ffebld_new_symter (s, FFEINTRIN_genNONE, FFEINTRIN_specNONE,
4558 ffebld_set_info (e, ffeinfo_use (ffesymbol_info (s)));
4559 ffebld_append_item (&ffestc_local_.dummy.list_bottom, e);
4562 /* ffestc_shriek_begin_program_ -- Implicit PROGRAM statement
4564 ffestc_shriek_begin_program_();
4566 Invoked only when a PROGRAM statement is NOT present at the beginning
4567 of a main program unit. */
4570 ffestc_shriek_begin_program_ ()
4575 ffestc_blocknum_ = 0;
4576 b = ffestw_update (ffestw_push (NULL));
4577 ffestw_set_top_do (b, NULL);
4578 ffestw_set_state (b, FFESTV_statePROGRAM0);
4579 ffestw_set_blocknum (b, ffestc_blocknum_++);
4580 ffestw_set_shriek (b, ffestc_shriek_end_program_);
4581 ffestw_set_name (b, NULL);
4583 s = ffesymbol_declare_programunit (NULL,
4584 ffelex_token_where_line (ffesta_tokens[0]),
4585 ffelex_token_where_column (ffesta_tokens[0]));
4587 /* Special case: this is one symbol that won't go through
4588 ffestu_exec_transition_ when the first statement in a main program is
4589 executable, because the transition happens in ffest before ffestc is
4590 reached and triggers the implicit generation of a main program. So we
4591 do the exec transition for the implicit main program right here, just
4592 for cleanliness' sake (at the very least). */
4594 ffesymbol_set_info (s,
4595 ffeinfo_new (FFEINFO_basictypeNONE,
4596 FFEINFO_kindtypeNONE,
4598 FFEINFO_kindPROGRAM,
4600 FFETARGET_charactersizeNONE));
4601 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
4603 ffesymbol_signal_unreported (s);
4605 ffestd_R1102 (s, NULL);
4608 /* ffestc_shriek_begin_uses_ -- Start a bunch of USE statements
4610 ffestc_shriek_begin_uses_();
4612 Invoked before handling the first USE statement in a block of one or
4613 more USE statements. _end_uses_(bool ok) is invoked before handling
4614 the first statement after the block (there are no BEGIN USE and END USE
4615 statements, but the semantics of USE statements effectively requires
4616 handling them as a single block rather than one statement at a time). */
4620 ffestc_shriek_begin_uses_ ()
4624 b = ffestw_update (ffestw_push (NULL));
4625 ffestw_set_top_do (b, NULL);
4626 ffestw_set_state (b, FFESTV_stateUSE);
4627 ffestw_set_blocknum (b, 0);
4628 ffestw_set_shriek (b, ffestc_shriek_end_uses_);
4630 ffestd_begin_uses ();
4634 /* ffestc_shriek_blockdata_ -- End a BLOCK DATA
4636 ffestc_shriek_blockdata_(TRUE); */
4639 ffestc_shriek_blockdata_ (bool ok)
4641 if (!ffesta_seen_first_exec)
4643 ffesta_seen_first_exec = TRUE;
4644 ffestd_exec_begin ();
4651 if (ffestw_name (ffestw_stack_top ()) != NULL)
4652 ffelex_token_kill (ffestw_name (ffestw_stack_top ()));
4653 ffestw_kill (ffestw_pop ());
4659 /* ffestc_shriek_do_ -- End of statement following DO-term-stmt etc
4661 ffestc_shriek_do_(TRUE);
4663 Also invoked by _labeldef_branch_end_ (or, in cases
4664 of errors, other _labeldef_ functions) when the label definition is
4665 for a DO-target (LOOPEND) label, once per matching/outstanding DO
4666 block on the stack. These cases invoke this function with ok==TRUE, so
4667 only forced stack popping (via ffestc_eof()) invokes it with ok==FALSE. */
4670 ffestc_shriek_do_ (bool ok)
4674 if (((l = ffestw_label (ffestw_stack_top ())) != NULL)
4675 && (ffewhere_line_is_unknown (ffelab_definition_line (l))))
4676 { /* DO target is label that is still
4678 assert ((ffelab_type (l) == FFELAB_typeLOOPEND)
4679 || (ffelab_type (l) == FFELAB_typeANY));
4680 if (ffelab_type (l) != FFELAB_typeANY)
4682 ffelab_set_definition_line (l,
4683 ffewhere_line_use (ffelab_doref_line (l)));
4684 ffelab_set_definition_column (l,
4685 ffewhere_column_use (ffelab_doref_column (l)));
4686 ffestv_num_label_defines_++;
4688 ffestd_labeldef_branch (l);
4693 if (ffestw_name (ffestw_stack_top ()) != NULL)
4694 ffelex_token_kill (ffestw_name (ffestw_stack_top ()));
4695 if (ffestw_do_iter_var_t (ffestw_stack_top ()) != NULL)
4696 ffelex_token_kill (ffestw_do_iter_var_t (ffestw_stack_top ()));
4697 if (ffestw_do_iter_var (ffestw_stack_top ()) != NULL)
4698 ffesymbol_set_is_doiter (ffestw_do_iter_var (ffestw_stack_top ()), FALSE);
4699 ffestw_kill (ffestw_pop ());
4702 /* ffestc_shriek_end_program_ -- End a PROGRAM
4704 ffestc_shriek_end_program_(); */
4707 ffestc_shriek_end_program_ (bool ok)
4709 if (!ffesta_seen_first_exec)
4711 ffesta_seen_first_exec = TRUE;
4712 ffestd_exec_begin ();
4719 if (ffestw_name (ffestw_stack_top ()) != NULL)
4720 ffelex_token_kill (ffestw_name (ffestw_stack_top ()));
4721 ffestw_kill (ffestw_pop ());
4727 /* ffestc_shriek_end_uses_ -- End a bunch of USE statements
4729 ffestc_shriek_end_uses_(TRUE);
4731 ok==TRUE means simply not popping due to ffestc_eof()
4732 being called, because there is no formal END USES statement in Fortran. */
4736 ffestc_shriek_end_uses_ (bool ok)
4738 ffestd_end_uses (ok);
4740 ffestw_kill (ffestw_pop ());
4744 /* ffestc_shriek_function_ -- End a FUNCTION
4746 ffestc_shriek_function_(TRUE); */
4749 ffestc_shriek_function_ (bool ok)
4751 if (!ffesta_seen_first_exec)
4753 ffesta_seen_first_exec = TRUE;
4754 ffestd_exec_begin ();
4761 ffelex_token_kill (ffestw_name (ffestw_stack_top ()));
4762 ffestw_kill (ffestw_pop ());
4763 ffesta_is_entry_valid = FALSE;
4765 switch (ffestw_state (ffestw_stack_top ()))
4767 case FFESTV_stateNIL:
4777 case FFESTV_stateINTERFACE0:
4784 /* ffestc_shriek_if_ -- End of statement following logical IF
4786 ffestc_shriek_if_(TRUE);
4788 Applies ONLY to logical IF, not to IF-THEN. For example, does not
4789 ffelex_token_kill the construct name for an IF-THEN block (the name
4790 field is invalid for logical IF). ok==TRUE iff statement following
4791 logical IF (substatement) is valid; else, statement is invalid or
4792 stack forcibly popped due to ffestc_eof(). */
4795 ffestc_shriek_if_ (bool ok)
4797 ffestd_end_R807 (ok);
4799 ffestw_kill (ffestw_pop ());
4800 ffestc_shriek_after1_ = NULL;
4802 ffestc_try_shriek_do_ ();
4805 /* ffestc_shriek_ifthen_ -- End an IF-THEN
4807 ffestc_shriek_ifthen_(TRUE); */
4810 ffestc_shriek_ifthen_ (bool ok)
4814 if (ffestw_name (ffestw_stack_top ()) != NULL)
4815 ffelex_token_kill (ffestw_name (ffestw_stack_top ()));
4816 ffestw_kill (ffestw_pop ());
4818 ffestc_try_shriek_do_ ();
4821 /* ffestc_shriek_interface_ -- End an INTERFACE
4823 ffestc_shriek_interface_(TRUE); */
4827 ffestc_shriek_interface_ (bool ok)
4831 ffestw_kill (ffestw_pop ());
4833 ffestc_try_shriek_do_ ();
4837 /* ffestc_shriek_map_ -- End a MAP
4839 ffestc_shriek_map_(TRUE); */
4843 ffestc_shriek_map_ (bool ok)
4847 ffestw_kill (ffestw_pop ());
4849 ffestc_try_shriek_do_ ();
4853 /* ffestc_shriek_module_ -- End a MODULE
4855 ffestc_shriek_module_(TRUE); */
4859 ffestc_shriek_module_ (bool ok)
4861 if (!ffesta_seen_first_exec)
4863 ffesta_seen_first_exec = TRUE;
4864 ffestd_exec_begin ();
4871 ffelex_token_kill (ffestw_name (ffestw_stack_top ()));
4872 ffestw_kill (ffestw_pop ());
4879 /* ffestc_shriek_select_ -- End a SELECT
4881 ffestc_shriek_select_(TRUE); */
4884 ffestc_shriek_select_ (bool ok)
4891 if (ffestw_name (ffestw_stack_top ()) != NULL)
4892 ffelex_token_kill (ffestw_name (ffestw_stack_top ()));
4893 s = ffestw_select (ffestw_stack_top ());
4894 ffelex_token_kill (s->t);
4895 for (c = s->first_rel; c != (ffestwCase) &s->first_rel; c = c->next_rel)
4896 ffelex_token_kill (c->t);
4897 malloc_pool_kill (s->pool);
4899 ffestw_kill (ffestw_pop ());
4901 ffestc_try_shriek_do_ ();
4904 /* ffestc_shriek_structure_ -- End a STRUCTURE
4906 ffestc_shriek_structure_(TRUE); */
4910 ffestc_shriek_structure_ (bool ok)
4914 ffestw_kill (ffestw_pop ());
4916 ffestc_try_shriek_do_ ();
4920 /* ffestc_shriek_subroutine_ -- End a SUBROUTINE
4922 ffestc_shriek_subroutine_(TRUE); */
4925 ffestc_shriek_subroutine_ (bool ok)
4927 if (!ffesta_seen_first_exec)
4929 ffesta_seen_first_exec = TRUE;
4930 ffestd_exec_begin ();
4937 ffelex_token_kill (ffestw_name (ffestw_stack_top ()));
4938 ffestw_kill (ffestw_pop ());
4939 ffesta_is_entry_valid = FALSE;
4941 switch (ffestw_state (ffestw_stack_top ()))
4943 case FFESTV_stateNIL:
4953 case FFESTV_stateINTERFACE0:
4960 /* ffestc_shriek_type_ -- End a TYPE
4962 ffestc_shriek_type_(TRUE); */
4966 ffestc_shriek_type_ (bool ok)
4972 ffelex_token_kill (ffestw_name (ffestw_stack_top ()));
4973 ffestw_kill (ffestw_pop ());
4975 ffestc_try_shriek_do_ ();
4979 /* ffestc_shriek_union_ -- End a UNION
4981 ffestc_shriek_union_(TRUE); */
4985 ffestc_shriek_union_ (bool ok)
4989 ffestw_kill (ffestw_pop ());
4991 ffestc_try_shriek_do_ ();
4995 /* ffestc_shriek_where_ -- Implicit END WHERE statement
4997 ffestc_shriek_where_(TRUE);
4999 Implement the end of the current WHERE "block". ok==TRUE iff statement
5000 following WHERE (substatement) is valid; else, statement is invalid
5001 or stack forcibly popped due to ffestc_eof(). */
5005 ffestc_shriek_where_ (bool ok)
5009 ffestw_kill (ffestw_pop ());
5010 ffestc_shriek_after1_ = NULL;
5011 if (ffestw_state (ffestw_stack_top ()) == FFESTV_stateIF)
5012 ffestc_shriek_if_ (TRUE); /* "IF (x) WHERE (y) stmt" is only valid
5015 ffestc_try_shriek_do_ ();
5019 /* ffestc_shriek_wherethen_ -- End a WHERE(-THEN)
5021 ffestc_shriek_wherethen_(TRUE); */
5025 ffestc_shriek_wherethen_ (bool ok)
5027 ffestd_end_R740 (ok);
5029 ffestw_kill (ffestw_pop ());
5031 ffestc_try_shriek_do_ ();
5035 /* ffestc_subr_binsrch_ -- Binary search of char const in list of strings
5037 i = ffestc_subr_binsrch_(search_list,search_list_size,&spec,"etc");
5039 search_list contains search_list_size char *'s, spec is checked to see
5040 if it is a char constant and, if so, is binary-searched against the list.
5041 0 is returned if not found, else the "classic" index (beginning with 1)
5042 is returned. Before returning 0 where the search was performed but
5043 fruitless, if "etc" is a non-NULL char *, an error message is displayed
5044 using "etc" as the pick-one-of-these string. */
5047 ffestc_subr_binsrch_ (char **list, int size, ffestpFile *spec, char *whine)
5058 return 0; /* Nobody should pass size == 0, but for
5062 highest_tested = size;
5063 halfway = size >> 1;
5067 c = ffestc_subr_speccmp_ (*list, spec, &str, &len);
5072 next: /* :::::::::::::::::::: */
5076 offset = (halfway - lowest_tested) >> 1;
5078 goto nope; /* :::::::::::::::::::: */
5079 highest_tested = halfway;
5082 c = ffesrc_strcmp_1ns2i (ffe_case_match (), str, len, *list);
5083 goto next; /* :::::::::::::::::::: */
5089 offset = (highest_tested - halfway) >> 1;
5091 goto nope; /* :::::::::::::::::::: */
5092 lowest_tested = halfway;
5095 c = ffesrc_strcmp_1ns2i (ffe_case_match (), str, len, *list);
5096 goto next; /* :::::::::::::::::::: */
5099 assert ("unexpected return from ffesrc_strcmp_1ns2i" == NULL);
5103 nope: /* :::::::::::::::::::: */
5104 ffebad_start (FFEBAD_SPEC_VALUE);
5105 ffebad_here (0, ffelex_token_where_line (spec->value),
5106 ffelex_token_where_column (spec->value));
5107 ffebad_string (whine);
5112 /* ffestc_subr_format_ -- Return summary of format specifier
5114 ffestc_subr_format_(&specifier); */
5117 ffestc_subr_format_ (ffestpFile *spec)
5119 if (!spec->kw_or_val_present)
5120 return FFESTV_formatNONE;
5121 assert (spec->value_present);
5122 if (spec->value_is_label)
5123 return FFESTV_formatLABEL; /* Ok if not a label. */
5125 assert (spec->value != NULL);
5126 if (ffebld_op (spec->u.expr) == FFEBLD_opSTAR)
5127 return FFESTV_formatASTERISK;
5129 if (ffeinfo_kind (ffebld_info (spec->u.expr)) == FFEINFO_kindNAMELIST)
5130 return FFESTV_formatNAMELIST;
5132 if (ffeinfo_rank (ffebld_info (spec->u.expr)) != 0)
5133 return FFESTV_formatCHAREXPR; /* F77 C5. */
5135 switch (ffeinfo_basictype (ffebld_info (spec->u.expr)))
5137 case FFEINFO_basictypeINTEGER:
5138 return FFESTV_formatINTEXPR;
5140 case FFEINFO_basictypeCHARACTER:
5141 return FFESTV_formatCHAREXPR;
5143 case FFEINFO_basictypeANY:
5144 return FFESTV_formatASTERISK;
5147 assert ("bad basictype" == NULL);
5148 return FFESTV_formatINTEXPR;
5152 /* ffestc_subr_is_branch_ -- Handle specifier as branch target label
5154 ffestc_subr_is_branch_(&specifier); */
5157 ffestc_subr_is_branch_ (ffestpFile *spec)
5159 if (!spec->kw_or_val_present)
5161 assert (spec->value_present);
5162 assert (spec->value_is_label);
5163 spec->value_is_label++; /* For checking purposes only; 1=>2. */
5164 return ffestc_labelref_is_branch_ (spec->value, &spec->u.label);
5167 /* ffestc_subr_is_format_ -- Handle specifier as format target label
5169 ffestc_subr_is_format_(&specifier); */
5172 ffestc_subr_is_format_ (ffestpFile *spec)
5174 if (!spec->kw_or_val_present)
5176 assert (spec->value_present);
5177 if (!spec->value_is_label)
5178 return TRUE; /* Ok if not a label. */
5180 spec->value_is_label++; /* For checking purposes only; 1=>2. */
5181 return ffestc_labelref_is_format_ (spec->value, &spec->u.label);
5184 /* ffestc_subr_is_present_ -- Ensure specifier is present, else error
5186 ffestc_subr_is_present_("SPECIFIER",&specifier); */
5189 ffestc_subr_is_present_ (char *name, ffestpFile *spec)
5191 if (spec->kw_or_val_present)
5193 assert (spec->value_present);
5197 ffebad_start (FFEBAD_MISSING_SPECIFIER);
5198 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
5199 ffelex_token_where_column (ffesta_tokens[0]));
5200 ffebad_string (name);
5205 /* ffestc_subr_speccmp_ -- Compare string to constant expression, if present
5207 if (ffestc_subr_speccmp_("Constant",&specifier,NULL,NULL) == 0)
5208 // specifier value is present and is a char constant "CONSTANT"
5210 Like strcmp, except the return values are defined as: -1 returned in place
5211 of strcmp's generic negative value, 1 in place of it's generic positive
5212 value, and 2 when there is no character constant string to compare. Also,
5213 a case-insensitive comparison is performed, where string is assumed to
5214 already be in InitialCaps form.
5216 If a non-NULL pointer is provided as the char **target, then *target is
5217 written with NULL if 2 is returned, a pointer to the constant string
5218 value of the specifier otherwise. Similarly, length is written with
5219 0 if 2 is returned, the length of the constant string value otherwise. */
5222 ffestc_subr_speccmp_ (char *string, ffestpFile *spec, char **target,
5228 if (!spec->kw_or_val_present || !spec->value_present
5229 || (spec->u.expr == NULL)
5230 || (ffebld_op (spec->u.expr) != FFEBLD_opCONTER))
5239 if (ffebld_constant_type (c = ffebld_conter (spec->u.expr))
5240 != FFEBLD_constCHARACTERDEFAULT)
5250 *target = ffebld_constant_characterdefault (c).text;
5252 *length = ffebld_constant_characterdefault (c).length;
5254 i = ffesrc_strcmp_1ns2i (ffe_case_match (),
5255 ffebld_constant_characterdefault (c).text,
5256 ffebld_constant_characterdefault (c).length,
5261 return -1; /* Yes indeed, we reverse the strings to
5266 /* ffestc_subr_unit_ -- Return summary of unit specifier
5268 ffestc_subr_unit_(&specifier); */
5271 ffestc_subr_unit_ (ffestpFile *spec)
5273 if (!spec->kw_or_val_present)
5274 return FFESTV_unitNONE;
5275 assert (spec->value_present);
5276 assert (spec->value != NULL);
5278 if (ffebld_op (spec->u.expr) == FFEBLD_opSTAR)
5279 return FFESTV_unitASTERISK;
5281 switch (ffeinfo_basictype (ffebld_info (spec->u.expr)))
5283 case FFEINFO_basictypeINTEGER:
5284 return FFESTV_unitINTEXPR;
5286 case FFEINFO_basictypeCHARACTER:
5287 return FFESTV_unitCHAREXPR;
5289 case FFEINFO_basictypeANY:
5290 return FFESTV_unitASTERISK;
5293 assert ("bad basictype" == NULL);
5294 return FFESTV_unitINTEXPR;
5298 /* Call this function whenever it's possible that one or more top
5299 stack items are label-targeting DO blocks that have had their
5300 labels defined, but at a time when they weren't at the top of the
5301 stack. This prevents uninformative diagnostics for programs
5302 like "DO 10", "IF (...) THEN", "10 ELSE", "END IF", "END". */
5305 ffestc_try_shriek_do_ ()
5310 while ((ffestw_state (ffestw_stack_top ()) == FFESTV_stateDO)
5311 && ((lab = (ffestw_label (ffestw_stack_top ()))) != NULL)
5312 && (((ty = (ffelab_type (lab)))
5314 || (ty == FFELAB_typeUSELESS)
5315 || (ty == FFELAB_typeFORMAT)
5316 || (ty == FFELAB_typeNOTLOOP)
5317 || (ty == FFELAB_typeENDIF)))
5318 ffestc_shriek_do_ (FALSE);
5321 /* ffestc_decl_start -- R426 or R501
5323 ffestc_decl_start(...);
5325 Verify that R426 component-def-stmt or R501 type-declaration-stmt are
5326 valid here, figure out which one, and implement. */
5329 ffestc_decl_start (ffestpType type, ffelexToken typet, ffebld kind,
5330 ffelexToken kindt, ffebld len, ffelexToken lent)
5332 switch (ffestw_state (ffestw_stack_top ()))
5334 case FFESTV_stateNIL:
5335 case FFESTV_statePROGRAM0:
5336 case FFESTV_stateSUBROUTINE0:
5337 case FFESTV_stateFUNCTION0:
5338 case FFESTV_stateMODULE0:
5339 case FFESTV_stateBLOCKDATA0:
5340 case FFESTV_statePROGRAM1:
5341 case FFESTV_stateSUBROUTINE1:
5342 case FFESTV_stateFUNCTION1:
5343 case FFESTV_stateMODULE1:
5344 case FFESTV_stateBLOCKDATA1:
5345 case FFESTV_statePROGRAM2:
5346 case FFESTV_stateSUBROUTINE2:
5347 case FFESTV_stateFUNCTION2:
5348 case FFESTV_stateMODULE2:
5349 case FFESTV_stateBLOCKDATA2:
5350 case FFESTV_statePROGRAM3:
5351 case FFESTV_stateSUBROUTINE3:
5352 case FFESTV_stateFUNCTION3:
5353 case FFESTV_stateMODULE3:
5354 case FFESTV_stateBLOCKDATA3:
5355 case FFESTV_stateUSE:
5356 ffestc_local_.decl.is_R426 = 2;
5359 case FFESTV_stateTYPE:
5360 case FFESTV_stateSTRUCTURE:
5361 case FFESTV_stateMAP:
5362 ffestc_local_.decl.is_R426 = 1;
5366 ffestc_order_bad_ ();
5367 ffestc_labeldef_useless_ ();
5368 ffestc_local_.decl.is_R426 = 0;
5372 switch (ffestc_local_.decl.is_R426)
5376 ffestc_R426_start (type, typet, kind, kindt, len, lent);
5381 ffestc_R501_start (type, typet, kind, kindt, len, lent);
5385 ffestc_labeldef_useless_ ();
5390 /* ffestc_decl_attrib -- R426 or R501 type attribute
5392 ffestc_decl_attrib(...);
5394 Verify that R426 component-def-stmt or R501 type-declaration-stmt attribute
5395 is valid here and implement. */
5398 ffestc_decl_attrib (ffestpAttrib attrib UNUSED,
5399 ffelexToken attribt UNUSED,
5400 ffestrOther intent_kw UNUSED,
5401 ffesttDimList dims UNUSED)
5404 switch (ffestc_local_.decl.is_R426)
5407 ffestc_R426_attrib (attrib, attribt, intent_kw, dims);
5411 ffestc_R501_attrib (attrib, attribt, intent_kw, dims);
5418 ffebad_start (FFEBAD_F90);
5419 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
5420 ffelex_token_where_column (ffesta_tokens[0]));
5426 /* ffestc_decl_item -- R426 or R501
5428 ffestc_decl_item(...);
5430 Establish type for a particular object. */
5433 ffestc_decl_item (ffelexToken name, ffebld kind, ffelexToken kindt,
5434 ffesttDimList dims, ffebld len, ffelexToken lent, ffebld init,
5435 ffelexToken initt, bool clist)
5437 switch (ffestc_local_.decl.is_R426)
5441 ffestc_R426_item (name, kind, kindt, dims, len, lent, init, initt,
5447 ffestc_R501_item (name, kind, kindt, dims, len, lent, init, initt,
5456 /* ffestc_decl_itemstartvals -- R426 or R501 start list of values
5458 ffestc_decl_itemstartvals();
5460 Gonna specify values for the object now. */
5463 ffestc_decl_itemstartvals ()
5465 switch (ffestc_local_.decl.is_R426)
5469 ffestc_R426_itemstartvals ();
5474 ffestc_R501_itemstartvals ();
5482 /* ffestc_decl_itemvalue -- R426 or R501 source value
5484 ffestc_decl_itemvalue(repeat,repeat_token,value,value_token);
5486 Make sure repeat and value are valid for the object being initialized. */
5489 ffestc_decl_itemvalue (ffebld repeat, ffelexToken repeat_token,
5490 ffebld value, ffelexToken value_token)
5492 switch (ffestc_local_.decl.is_R426)
5496 ffestc_R426_itemvalue (repeat, repeat_token, value, value_token);
5501 ffestc_R501_itemvalue (repeat, repeat_token, value, value_token);
5509 /* ffestc_decl_itemendvals -- R426 or R501 end list of values
5511 ffelexToken t; // the SLASH token that ends the list.
5512 ffestc_decl_itemendvals(t);
5514 No more values, might specify more objects now. */
5517 ffestc_decl_itemendvals (ffelexToken t)
5519 switch (ffestc_local_.decl.is_R426)
5523 ffestc_R426_itemendvals (t);
5528 ffestc_R501_itemendvals (t);
5536 /* ffestc_decl_finish -- R426 or R501
5538 ffestc_decl_finish();
5540 Just wrap up any local activities. */
5543 ffestc_decl_finish ()
5545 switch (ffestc_local_.decl.is_R426)
5549 ffestc_R426_finish ();
5554 ffestc_R501_finish ();
5562 /* ffestc_elsewhere -- Generic ELSE WHERE statement
5566 Decide whether ELSEWHERE or ELSE w/if-construct-name=="WHERE" is meant. */
5569 ffestc_elsewhere (ffelexToken where)
5571 switch (ffestw_state (ffestw_stack_top ()))
5573 case FFESTV_stateIFTHEN:
5574 ffestc_R805 (where);
5585 /* ffestc_end -- Generic END statement
5589 Make sure a generic END is valid in the current context, and implement
5597 b = ffestw_stack_top ();
5601 switch (ffestw_state (b))
5603 case FFESTV_stateBLOCKDATA0:
5604 case FFESTV_stateBLOCKDATA1:
5605 case FFESTV_stateBLOCKDATA2:
5606 case FFESTV_stateBLOCKDATA3:
5607 case FFESTV_stateBLOCKDATA4:
5608 case FFESTV_stateBLOCKDATA5:
5609 ffestc_R1112 (NULL);
5612 case FFESTV_stateFUNCTION0:
5613 case FFESTV_stateFUNCTION1:
5614 case FFESTV_stateFUNCTION2:
5615 case FFESTV_stateFUNCTION3:
5616 case FFESTV_stateFUNCTION4:
5617 case FFESTV_stateFUNCTION5:
5618 if ((ffestw_state (ffestw_previous (b)) != FFESTV_stateNIL)
5619 && (ffestw_state (ffestw_previous (b)) != FFESTV_stateINTERFACE0))
5621 ffebad_start (FFEBAD_END_WO);
5622 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
5623 ffelex_token_where_column (ffesta_tokens[0]));
5624 ffebad_here (1, ffestw_line (ffestw_previous (b)), ffestw_col (ffestw_previous (b)));
5625 ffebad_string ("FUNCTION");
5628 ffestc_R1221 (NULL);
5631 case FFESTV_stateMODULE0:
5632 case FFESTV_stateMODULE1:
5633 case FFESTV_stateMODULE2:
5634 case FFESTV_stateMODULE3:
5635 case FFESTV_stateMODULE4:
5636 case FFESTV_stateMODULE5:
5638 ffestc_R1106 (NULL);
5642 case FFESTV_stateSUBROUTINE0:
5643 case FFESTV_stateSUBROUTINE1:
5644 case FFESTV_stateSUBROUTINE2:
5645 case FFESTV_stateSUBROUTINE3:
5646 case FFESTV_stateSUBROUTINE4:
5647 case FFESTV_stateSUBROUTINE5:
5648 if ((ffestw_state (ffestw_previous (b)) != FFESTV_stateNIL)
5649 && (ffestw_state (ffestw_previous (b)) != FFESTV_stateINTERFACE0))
5651 ffebad_start (FFEBAD_END_WO);
5652 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
5653 ffelex_token_where_column (ffesta_tokens[0]));
5654 ffebad_here (1, ffestw_line (ffestw_previous (b)), ffestw_col (ffestw_previous (b)));
5655 ffebad_string ("SUBROUTINE");
5658 ffestc_R1225 (NULL);
5661 case FFESTV_stateUSE:
5662 b = ffestw_previous (ffestw_stack_top ());
5663 goto recurse; /* :::::::::::::::::::: */
5666 ffestc_R1103 (NULL);
5671 /* ffestc_eof -- Generic EOF
5675 Make sure we're at state NIL, or issue an error message and use each
5676 block's shriek function to clean up to state NIL. */
5681 if (ffestw_state (ffestw_stack_top ()) != FFESTV_stateNIL)
5683 ffebad_start (FFEBAD_EOF_BEFORE_BLOCK_END);
5684 ffebad_here (0, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
5687 (*ffestw_shriek (ffestw_stack_top ()))(FALSE);
5688 while (ffestw_state (ffestw_stack_top ()) != FFESTV_stateNIL);
5692 /* ffestc_exec_transition -- Check if ok and move stmt state to executable
5694 if (ffestc_exec_transition())
5695 // Transition successful (kind of like a CONTINUE stmt was seen).
5697 If the current statement state is a non-nested specification state in
5698 which, say, a CONTINUE statement would be valid, then enter the state
5699 we'd be in after seeing CONTINUE (without, of course, generating any
5700 CONTINUE code), call ffestd_exec_begin, and return TRUE. Otherwise
5703 This function cannot be invoked once the first executable statement
5704 is seen. This function may choose to always return TRUE by shrieking
5705 away any interceding state stack entries to reach the base level of
5706 specification state, but right now it doesn't, and it is (or should
5707 be) purely an issue of how one wishes errors to be handled (for example,
5708 an unrecognized statement in the middle of a STRUCTURE construct: after
5709 the error message, should subsequent statements still be interpreted as
5710 being within the construct, or should the construct be terminated upon
5711 seeing the unrecognized statement? we do the former at the moment). */
5714 ffestc_exec_transition ()
5720 switch (ffestw_state (ffestw_stack_top ()))
5722 case FFESTV_stateNIL:
5723 ffestc_shriek_begin_program_ ();
5724 goto recurse; /* :::::::::::::::::::: */
5726 case FFESTV_statePROGRAM0:
5727 case FFESTV_stateSUBROUTINE0:
5728 case FFESTV_stateFUNCTION0:
5729 case FFESTV_stateBLOCKDATA0:
5730 ffestw_state (ffestw_stack_top ()) += 4; /* To state UNIT4. */
5734 case FFESTV_statePROGRAM1:
5735 case FFESTV_stateSUBROUTINE1:
5736 case FFESTV_stateFUNCTION1:
5737 case FFESTV_stateBLOCKDATA1:
5738 ffestw_state (ffestw_stack_top ()) += 3; /* To state UNIT4. */
5742 case FFESTV_statePROGRAM2:
5743 case FFESTV_stateSUBROUTINE2:
5744 case FFESTV_stateFUNCTION2:
5745 case FFESTV_stateBLOCKDATA2:
5746 ffestw_state (ffestw_stack_top ()) += 2; /* To state UNIT4. */
5750 case FFESTV_statePROGRAM3:
5751 case FFESTV_stateSUBROUTINE3:
5752 case FFESTV_stateFUNCTION3:
5753 case FFESTV_stateBLOCKDATA3:
5754 ffestw_state (ffestw_stack_top ()) += 1; /* To state UNIT4. */
5758 case FFESTV_stateUSE:
5760 ffestc_shriek_end_uses_ (TRUE);
5762 goto recurse; /* :::::::::::::::::::: */
5769 ffestw_update (NULL); /* Update state line/col info. */
5771 ffesta_seen_first_exec = TRUE;
5772 ffestd_exec_begin ();
5777 /* ffestc_ffebad_here_doiter -- Calls ffebad_here with ptr to DO iter var
5780 // call ffebad_start first, of course.
5781 ffestc_ffebad_here_doiter(0,s);
5782 // call ffebad_finish afterwards, naturally.
5784 Searches the stack of blocks backwards for a DO loop that has s
5785 as its iteration variable, then calls ffebad_here with pointers to
5786 that particular reference to the variable. Crashes if the DO loop
5790 ffestc_ffebad_here_doiter (ffebadIndex i, ffesymbol s)
5794 for (block = ffestw_top_do (ffestw_stack_top ());
5795 (block != NULL) && (ffestw_blocknum (block) != 0);
5796 block = ffestw_top_do (ffestw_previous (block)))
5798 if (ffestw_do_iter_var (block) == s)
5800 ffebad_here (i, ffelex_token_where_line (ffestw_do_iter_var_t (block)),
5801 ffelex_token_where_column (ffestw_do_iter_var_t (block)));
5805 assert ("no do block found" == NULL);
5808 /* ffestc_is_decl_not_R1219 -- Context information for FFESTB
5810 if (ffestc_is_decl_not_R1219()) ...
5812 When a statement with the form "type[RECURSIVE]FUNCTIONname(name-list)"
5813 is seen, call this function. It returns TRUE if the statement's context
5814 is such that it is a declaration of an object named
5815 "[RECURSIVE]FUNCTIONname" with an array-decl spec of "name-list", FALSE
5816 if the statement's context is such that it begins the definition of a
5817 function named "name" havin the dummy argument list "name-list" (this
5818 is the R1219 function-stmt case). */
5821 ffestc_is_decl_not_R1219 ()
5823 switch (ffestw_state (ffestw_stack_top ()))
5825 case FFESTV_stateNIL:
5826 case FFESTV_statePROGRAM5:
5827 case FFESTV_stateSUBROUTINE5:
5828 case FFESTV_stateFUNCTION5:
5829 case FFESTV_stateMODULE5:
5830 case FFESTV_stateINTERFACE0:
5838 /* ffestc_is_entry_in_subr -- Context information for FFESTB
5840 if (ffestc_is_entry_in_subr()) ...
5842 When a statement with the form "ENTRY name(name-list)"
5843 is seen, call this function. It returns TRUE if the statement's context
5844 is such that it may have "*", meaning alternate return, in place of
5845 names in the name list (i.e. if the ENTRY is in a subroutine context).
5846 It also returns TRUE if the ENTRY is not in a function context (invalid
5847 but prevents extra complaints about "*", if present). It returns FALSE
5848 if the ENTRY is in a function context. */
5851 ffestc_is_entry_in_subr ()
5855 s = ffestw_state (ffestw_stack_top ());
5861 case FFESTV_stateFUNCTION0:
5862 case FFESTV_stateFUNCTION1:
5863 case FFESTV_stateFUNCTION2:
5864 case FFESTV_stateFUNCTION3:
5865 case FFESTV_stateFUNCTION4:
5868 case FFESTV_stateUSE:
5869 s = ffestw_state (ffestw_previous (ffestw_stack_top ()));
5870 goto recurse; /* :::::::::::::::::::: */
5877 /* ffestc_is_let_not_V027 -- Context information for FFESTB
5879 if (ffestc_is_let_not_V027()) ...
5881 When a statement with the form "PARAMETERname=expr"
5882 is seen, call this function. It returns TRUE if the statement's context
5883 is such that it is an assignment to an object named "PARAMETERname", FALSE
5884 if the statement's context is such that it is a V-extension PARAMETER
5885 statement that is like a PARAMETER(name=expr) statement except that the
5886 type of name is determined by the type of expr, not the implicit or
5887 explicit typing of name. */
5890 ffestc_is_let_not_V027 ()
5892 switch (ffestw_state (ffestw_stack_top ()))
5894 case FFESTV_statePROGRAM4:
5895 case FFESTV_stateSUBROUTINE4:
5896 case FFESTV_stateFUNCTION4:
5897 case FFESTV_stateWHERETHEN:
5898 case FFESTV_stateIFTHEN:
5899 case FFESTV_stateDO:
5900 case FFESTV_stateSELECT0:
5901 case FFESTV_stateSELECT1:
5902 case FFESTV_stateWHERE:
5903 case FFESTV_stateIF:
5911 /* ffestc_module -- MODULE or MODULE PROCEDURE statement
5913 ffestc_module(module_name_token,procedure_name_token);
5915 Decide which is intended, and implement it by calling _R1105_ or
5920 ffestc_module (ffelexToken module, ffelexToken procedure)
5922 switch (ffestw_state (ffestw_stack_top ()))
5924 case FFESTV_stateINTERFACE0:
5925 case FFESTV_stateINTERFACE1:
5926 ffestc_R1205_start ();
5927 ffestc_R1205_item (procedure);
5928 ffestc_R1205_finish ();
5932 ffestc_R1105 (module);
5938 /* ffestc_private -- Generic PRIVATE statement
5942 This is either a PRIVATE within R422 derived-type statement or an
5943 R521 PRIVATE statement. Figure it out based on context and implement
5944 it, or produce an error. */
5950 switch (ffestw_state (ffestw_stack_top ()))
5952 case FFESTV_stateTYPE:
5963 /* ffestc_terminate_4 -- Terminate ffestc after scoping unit
5965 ffestc_terminate_4();
5967 For SUBROUTINEs/FUNCTIONs within INTERFACE/END INTERFACE, derived-TYPE-
5968 defs, and statement function defs. */
5971 ffestc_terminate_4 ()
5973 ffestc_entry_num_ = ffestc_saved_entry_num_;
5976 /* ffestc_R423A -- PRIVATE statement (in R422 derived-type statement)
5984 ffestc_check_simple_ ();
5985 if (ffestc_order_type_ () != FFESTC_orderOK_)
5987 ffestc_labeldef_useless_ ();
5989 if (ffestw_substate (ffestw_stack_top ()) != 0)
5991 ffebad_start (FFEBAD_DERIVTYP_ACCESS_FIRST);
5992 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
5993 ffelex_token_where_column (ffesta_tokens[0]));
5994 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
5999 if (ffestw_state (ffestw_previous (ffestw_stack_top ())) != FFESTV_stateMODULE3)
6001 ffebad_start (FFEBAD_DERIVTYP_ACCESS);
6002 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
6003 ffelex_token_where_column (ffesta_tokens[0]));
6008 ffestw_set_substate (ffestw_stack_top (), 1); /* Seen
6009 private-sequence-stmt. */
6014 /* ffestc_R423B -- SEQUENCE statement (in R422 derived-type-stmt)
6021 ffestc_check_simple_ ();
6022 if (ffestc_order_type_ () != FFESTC_orderOK_)
6024 ffestc_labeldef_useless_ ();
6026 if (ffestw_substate (ffestw_stack_top ()) != 0)
6028 ffebad_start (FFEBAD_DERIVTYP_ACCESS_FIRST);
6029 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
6030 ffelex_token_where_column (ffesta_tokens[0]));
6031 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
6036 ffestw_set_substate (ffestw_stack_top (), 1); /* Seen
6037 private-sequence-stmt. */
6042 /* ffestc_R424 -- derived-TYPE-def statement
6044 ffestc_R424(access_token,access_kw,name_token);
6046 Handle a derived-type definition. */
6049 ffestc_R424 (ffelexToken access, ffestrOther access_kw, ffelexToken name)
6053 assert (name != NULL);
6055 ffestc_check_simple_ ();
6056 if (ffestc_order_derivedtype_ () != FFESTC_orderOK_)
6058 ffestc_labeldef_useless_ ();
6060 if ((access != NULL)
6061 && (ffestw_state (ffestw_stack_top ()) != FFESTV_stateMODULE3))
6063 ffebad_start (FFEBAD_DERIVTYP_ACCESS);
6064 ffebad_here (0, ffelex_token_where_line (access),
6065 ffelex_token_where_column (access));
6070 b = ffestw_update (ffestw_push (NULL));
6071 ffestw_set_top_do (b, NULL);
6072 ffestw_set_state (b, FFESTV_stateTYPE);
6073 ffestw_set_blocknum (b, 0);
6074 ffestw_set_shriek (b, ffestc_shriek_type_);
6075 ffestw_set_name (b, ffelex_token_use (name));
6076 ffestw_set_substate (b, 0); /* Awaiting private-sequence-stmt and one
6077 component-def-stmt. */
6079 ffestd_R424 (access, access_kw, name);
6084 /* ffestc_R425 -- END TYPE statement
6086 ffestc_R425(name_token);
6088 Make sure ffestc_kind_ identifies a TYPE definition. If not
6089 NULL, make sure name_token gives the correct name. Implement the end
6090 of the type definition. */
6093 ffestc_R425 (ffelexToken name)
6095 ffestc_check_simple_ ();
6096 if (ffestc_order_type_ () != FFESTC_orderOK_)
6098 ffestc_labeldef_useless_ ();
6100 if (ffestw_substate (ffestw_stack_top ()) != 2)
6102 ffebad_start (FFEBAD_DERIVTYP_NO_COMPONENTS);
6103 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
6104 ffelex_token_where_column (ffesta_tokens[0]));
6105 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
6110 && (ffelex_token_strcmp (name, ffestw_name (ffestw_stack_top ())) != 0))
6112 ffebad_start (FFEBAD_TYPE_WRONG_NAME);
6113 ffebad_here (0, ffelex_token_where_line (name),
6114 ffelex_token_where_column (name));
6115 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
6116 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
6120 ffestc_shriek_type_ (TRUE);
6123 /* ffestc_R426_start -- component-declaration-stmt
6125 ffestc_R426_start(...);
6127 Verify that R426 component-declaration-stmt is
6128 valid here and implement. */
6131 ffestc_R426_start (ffestpType type, ffelexToken typet, ffebld kind,
6132 ffelexToken kindt, ffebld len, ffelexToken lent)
6134 ffestc_check_start_ ();
6135 if (ffestc_order_component_ () != FFESTC_orderOK_)
6137 ffestc_local_.decl.is_R426 = 0;
6140 ffestc_labeldef_useless_ ();
6142 switch (ffestw_state (ffestw_stack_top ()))
6144 case FFESTV_stateSTRUCTURE:
6145 case FFESTV_stateMAP:
6146 ffestw_set_substate (ffestw_stack_top (), 1); /* Seen at least one
6150 case FFESTV_stateTYPE:
6151 ffestw_set_substate (ffestw_stack_top (), 2);
6155 assert ("Component parent state invalid" == NULL);
6160 /* ffestc_R426_attrib -- type attribute
6162 ffestc_R426_attrib(...);
6164 Verify that R426 component-declaration-stmt attribute
6165 is valid here and implement. */
6168 ffestc_R426_attrib (ffestpAttrib attrib, ffelexToken attribt,
6169 ffestrOther intent_kw, ffesttDimList dims)
6171 ffestc_check_attrib_ ();
6174 /* ffestc_R426_item -- declared object
6176 ffestc_R426_item(...);
6178 Establish type for a particular object. */
6181 ffestc_R426_item (ffelexToken name, ffebld kind, ffelexToken kindt,
6182 ffesttDimList dims, ffebld len, ffelexToken lent, ffebld init,
6183 ffelexToken initt, bool clist)
6185 ffestc_check_item_ ();
6186 assert (name != NULL);
6187 assert (ffelex_token_type (name) == FFELEX_typeNAME); /* Not NAMES. */
6188 assert (kind == NULL); /* No way an expression should get here. */
6190 if ((dims != NULL) || (init != NULL) || clist)
6191 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
6194 /* ffestc_R426_itemstartvals -- Start list of values
6196 ffestc_R426_itemstartvals();
6198 Gonna specify values for the object now. */
6201 ffestc_R426_itemstartvals ()
6203 ffestc_check_item_startvals_ ();
6206 /* ffestc_R426_itemvalue -- Source value
6208 ffestc_R426_itemvalue(repeat,repeat_token,value,value_token);
6210 Make sure repeat and value are valid for the object being initialized. */
6213 ffestc_R426_itemvalue (ffebld repeat, ffelexToken repeat_token,
6214 ffebld value, ffelexToken value_token)
6216 ffestc_check_item_value_ ();
6219 /* ffestc_R426_itemendvals -- End list of values
6221 ffelexToken t; // the SLASH token that ends the list.
6222 ffestc_R426_itemendvals(t);
6224 No more values, might specify more objects now. */
6227 ffestc_R426_itemendvals (ffelexToken t)
6229 ffestc_check_item_endvals_ ();
6232 /* ffestc_R426_finish -- Done
6234 ffestc_R426_finish();
6236 Just wrap up any local activities. */
6239 ffestc_R426_finish ()
6241 ffestc_check_finish_ ();
6245 /* ffestc_R501_start -- type-declaration-stmt
6247 ffestc_R501_start(...);
6249 Verify that R501 type-declaration-stmt is
6250 valid here and implement. */
6253 ffestc_R501_start (ffestpType type, ffelexToken typet, ffebld kind,
6254 ffelexToken kindt, ffebld len, ffelexToken lent)
6256 ffestc_check_start_ ();
6257 if (ffestc_order_typedecl_ () != FFESTC_orderOK_)
6259 ffestc_local_.decl.is_R426 = 0;
6262 ffestc_labeldef_useless_ ();
6264 ffestc_establish_declstmt_ (type, typet, kind, kindt, len, lent);
6267 /* ffestc_R501_attrib -- type attribute
6269 ffestc_R501_attrib(...);
6271 Verify that R501 type-declaration-stmt attribute
6272 is valid here and implement. */
6275 ffestc_R501_attrib (ffestpAttrib attrib, ffelexToken attribt,
6276 ffestrOther intent_kw UNUSED,
6277 ffesttDimList dims UNUSED)
6279 ffestc_check_attrib_ ();
6284 case FFESTP_attribALLOCATABLE:
6288 case FFESTP_attribDIMENSION:
6289 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
6292 case FFESTP_attribEXTERNAL:
6296 case FFESTP_attribINTENT:
6300 case FFESTP_attribINTRINSIC:
6304 case FFESTP_attribOPTIONAL:
6308 case FFESTP_attribPARAMETER:
6312 case FFESTP_attribPOINTER:
6317 case FFESTP_attribPRIVATE:
6320 case FFESTP_attribPUBLIC:
6324 case FFESTP_attribSAVE:
6325 switch (ffestv_save_state_)
6327 case FFESTV_savestateNONE:
6328 ffestv_save_state_ = FFESTV_savestateSPECIFIC;
6330 = ffewhere_line_use (ffelex_token_where_line (attribt));
6332 = ffewhere_column_use (ffelex_token_where_column (attribt));
6335 case FFESTV_savestateSPECIFIC:
6336 case FFESTV_savestateANY:
6339 case FFESTV_savestateALL:
6340 if (ffe_is_pedantic ())
6342 ffebad_start (FFEBAD_CONFLICTING_SAVES);
6343 ffebad_here (0, ffestv_save_line_, ffestv_save_col_);
6344 ffebad_here (1, ffelex_token_where_line (attribt),
6345 ffelex_token_where_column (attribt));
6348 ffestv_save_state_ = FFESTV_savestateANY;
6352 assert ("unexpected save state" == NULL);
6358 case FFESTP_attribTARGET:
6363 assert ("unexpected attribute" == NULL);
6368 /* ffestc_R501_item -- declared object
6370 ffestc_R501_item(...);
6372 Establish type for a particular object. */
6375 ffestc_R501_item (ffelexToken name, ffebld kind, ffelexToken kindt,
6376 ffesttDimList dims, ffebld len, ffelexToken lent,
6377 ffebld init, ffelexToken initt, bool clist)
6380 ffesymbol sfn; /* FUNCTION symbol. */
6386 bool is_init = (init != NULL) || clist;
6388 bool is_ugly_assumed;
6391 ffestc_check_item_ ();
6392 assert (name != NULL);
6393 assert (ffelex_token_type (name) == FFELEX_typeNAME); /* Not NAMES. */
6394 assert (kind == NULL); /* No way an expression should get here. */
6396 ffestc_establish_declinfo_ (kind, kindt, len, lent);
6398 is_assumed = (ffestc_local_.decl.basic_type == FFEINFO_basictypeCHARACTER)
6399 && (ffestc_local_.decl.size == FFETARGET_charactersizeNONE);
6401 if ((dims != NULL) || is_init)
6402 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
6404 s = ffesymbol_declare_local (name, TRUE);
6405 sa = ffesymbol_attrs (s);
6407 /* First figure out what kind of object this is based solely on the current
6408 object situation (type params, dimension list, and initialization). */
6410 na = FFESYMBOL_attrsTYPE;
6413 na |= FFESYMBOL_attrsANYLEN;
6415 is_ugly_assumed = (ffe_is_ugly_assumed ()
6416 && ((sa & FFESYMBOL_attrsDUMMY)
6417 || (ffesymbol_where (s) == FFEINFO_whereDUMMY)));
6419 nd = ffestt_dimlist_type (dims, is_ugly_assumed);
6422 case FFESTP_dimtypeNONE:
6425 case FFESTP_dimtypeKNOWN:
6426 na |= FFESYMBOL_attrsARRAY;
6429 case FFESTP_dimtypeADJUSTABLE:
6430 na |= FFESYMBOL_attrsARRAY | FFESYMBOL_attrsADJUSTABLE;
6433 case FFESTP_dimtypeASSUMED:
6434 na |= FFESYMBOL_attrsARRAY | FFESYMBOL_attrsANYSIZE;
6437 case FFESTP_dimtypeADJUSTABLEASSUMED:
6438 na |= FFESYMBOL_attrsARRAY | FFESYMBOL_attrsADJUSTABLE
6439 | FFESYMBOL_attrsANYSIZE;
6443 assert ("unexpected dimtype" == NULL);
6444 na = FFESYMBOL_attrsetNONE;
6448 if (!ffesta_is_entry_valid
6449 && (((na & (FFESYMBOL_attrsANYLEN | FFESYMBOL_attrsARRAY))
6450 == (FFESYMBOL_attrsANYLEN | FFESYMBOL_attrsARRAY))))
6451 na = FFESYMBOL_attrsetNONE;
6455 if (na == FFESYMBOL_attrsetNONE)
6457 else if (na & (FFESYMBOL_attrsANYLEN
6458 | FFESYMBOL_attrsADJUSTABLE
6459 | FFESYMBOL_attrsANYSIZE))
6460 na = FFESYMBOL_attrsetNONE;
6462 na |= FFESYMBOL_attrsINIT;
6465 /* Now figure out what kind of object we've got based on previous
6466 declarations of or references to the object. */
6468 if (na == FFESYMBOL_attrsetNONE)
6470 else if (!ffesymbol_is_specable (s)
6471 && (((ffesymbol_where (s) != FFEINFO_whereCONSTANT)
6472 && (ffesymbol_where (s) != FFEINFO_whereINTRINSIC))
6473 || (na & (FFESYMBOL_attrsARRAY | FFESYMBOL_attrsINIT))))
6474 na = FFESYMBOL_attrsetNONE; /* Can't dcl sym ref'd in sfuncdef, and can't
6475 dimension/init UNDERSTOODs. */
6476 else if (sa & FFESYMBOL_attrsANY)
6479 || ((sa & (FFESYMBOL_attrsSFARG
6480 | FFESYMBOL_attrsADJUSTS))
6481 && (na & (FFESYMBOL_attrsARRAY
6482 | FFESYMBOL_attrsANYLEN)))
6483 || ((sa & FFESYMBOL_attrsRESULT)
6484 && (na & (FFESYMBOL_attrsARRAY
6485 | FFESYMBOL_attrsINIT)))
6486 || ((sa & (FFESYMBOL_attrsSFUNC
6487 | FFESYMBOL_attrsEXTERNAL
6488 | FFESYMBOL_attrsINTRINSIC
6489 | FFESYMBOL_attrsINIT))
6490 && (na & (FFESYMBOL_attrsARRAY
6491 | FFESYMBOL_attrsANYLEN
6492 | FFESYMBOL_attrsINIT)))
6493 || ((sa & FFESYMBOL_attrsARRAY)
6494 && !ffesta_is_entry_valid
6495 && (na & FFESYMBOL_attrsANYLEN))
6496 || ((sa & (FFESYMBOL_attrsADJUSTABLE
6497 | FFESYMBOL_attrsANYLEN
6498 | FFESYMBOL_attrsANYSIZE
6499 | FFESYMBOL_attrsDUMMY))
6500 && (na & FFESYMBOL_attrsINIT))
6501 || ((sa & (FFESYMBOL_attrsSAVE
6502 | FFESYMBOL_attrsNAMELIST
6503 | FFESYMBOL_attrsCOMMON
6504 | FFESYMBOL_attrsEQUIV))
6505 && (na & (FFESYMBOL_attrsADJUSTABLE
6506 | FFESYMBOL_attrsANYLEN
6507 | FFESYMBOL_attrsANYSIZE))))
6508 na = FFESYMBOL_attrsetNONE;
6509 else if ((ffesymbol_kind (s) == FFEINFO_kindENTITY)
6510 && (ffesymbol_where (s) == FFEINFO_whereCONSTANT)
6511 && (na & FFESYMBOL_attrsANYLEN))
6512 { /* If CHARACTER*(*) FOO after PARAMETER FOO. */
6513 na |= FFESYMBOL_attrsTYPE;
6514 ffestc_local_.decl.size = ffebld_size (ffesymbol_init (s));
6519 /* Now see what we've got for a new object: NONE means a new error cropped
6520 up; ANY means an old error to be ignored; otherwise, everything's ok,
6521 update the object (symbol) and continue on. */
6523 if (na == FFESYMBOL_attrsetNONE)
6525 ffesymbol_error (s, name);
6526 ffestc_parent_ok_ = FALSE;
6528 else if (na & FFESYMBOL_attrsANY)
6529 ffestc_parent_ok_ = FALSE;
6532 ffesymbol_set_attrs (s, na);
6533 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
6534 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
6535 rank = ffesymbol_rank (s);
6538 ffesymbol_set_dims (s, ffestt_dimlist_as_expr (dims, &rank,
6542 ffesymbol_set_arraysize (s, array_size);
6543 ffesymbol_set_extents (s, extents);
6544 if (!(0 && ffe_is_90 ())
6545 && (ffebld_op (array_size) == FFEBLD_opCONTER)
6546 && (ffebld_constant_integerdefault (ffebld_conter (array_size))
6549 ffebad_start (FFEBAD_ZERO_ARRAY);
6550 ffebad_here (0, ffelex_token_where_line (name),
6551 ffelex_token_where_column (name));
6557 ffesymbol_set_init (s,
6558 ffeexpr_convert (init, initt, name,
6559 ffestc_local_.decl.basic_type,
6560 ffestc_local_.decl.kind_type,
6562 ffestc_local_.decl.size,
6563 FFEEXPR_contextDATA));
6564 ffecom_notify_init_symbol (s);
6565 ffesymbol_update_init (s);
6566 #if FFEGLOBAL_ENABLED
6567 if (ffesymbol_common (s) != NULL)
6568 ffeglobal_init_common (ffesymbol_common (s), initt);
6575 symter = ffebld_new_symter (s, FFEINTRIN_genNONE,
6579 ffebld_set_info (symter,
6580 ffeinfo_new (ffestc_local_.decl.basic_type,
6581 ffestc_local_.decl.kind_type,
6585 ffestc_local_.decl.size));
6586 ffestc_local_.decl.initlist = ffebld_new_item (symter, NULL);
6588 if (ffesymbol_basictype (s) == FFEINFO_basictypeNONE)
6590 ffesymbol_set_info (s,
6591 ffeinfo_new (ffestc_local_.decl.basic_type,
6592 ffestc_local_.decl.kind_type,
6595 ffesymbol_where (s),
6596 ffestc_local_.decl.size));
6597 if ((na & FFESYMBOL_attrsRESULT)
6598 && ((sfn = ffesymbol_funcresult (s)) != NULL))
6600 ffesymbol_set_info (sfn,
6601 ffeinfo_new (ffestc_local_.decl.basic_type,
6602 ffestc_local_.decl.kind_type,
6604 ffesymbol_kind (sfn),
6605 ffesymbol_where (sfn),
6606 ffestc_local_.decl.size));
6607 ffesymbol_signal_unreported (sfn);
6610 else if ((ffestc_local_.decl.basic_type != ffesymbol_basictype (s))
6611 || (ffestc_local_.decl.kind_type != ffesymbol_kindtype (s))
6612 || ((ffestc_local_.decl.basic_type
6613 == FFEINFO_basictypeCHARACTER)
6614 && (ffestc_local_.decl.size != ffesymbol_size (s))))
6615 { /* Explicit type disagrees with established
6617 ffesymbol_error (s, name);
6620 if ((na & FFESYMBOL_attrsADJUSTS)
6621 && ((ffestc_local_.decl.basic_type != FFEINFO_basictypeINTEGER)
6622 || (ffestc_local_.decl.kind_type != FFEINFO_kindtypeINTEGER1)))
6623 ffesymbol_error (s, name);
6625 ffesymbol_signal_unreported (s);
6626 ffestc_parent_ok_ = TRUE;
6630 /* ffestc_R501_itemstartvals -- Start list of values
6632 ffestc_R501_itemstartvals();
6634 Gonna specify values for the object now. */
6637 ffestc_R501_itemstartvals ()
6639 ffestc_check_item_startvals_ ();
6641 if (ffestc_parent_ok_)
6642 ffedata_begin (ffestc_local_.decl.initlist);
6645 /* ffestc_R501_itemvalue -- Source value
6647 ffestc_R501_itemvalue(repeat,repeat_token,value,value_token);
6649 Make sure repeat and value are valid for the object being initialized. */
6652 ffestc_R501_itemvalue (ffebld repeat, ffelexToken repeat_token,
6653 ffebld value, ffelexToken value_token)
6655 ffetargetIntegerDefault rpt;
6657 ffestc_check_item_value_ ();
6659 if (!ffestc_parent_ok_)
6664 else if (ffebld_op (repeat) == FFEBLD_opCONTER)
6665 rpt = ffebld_constant_integerdefault (ffebld_conter (repeat));
6668 ffestc_parent_ok_ = FALSE;
6669 ffedata_end (TRUE, NULL);
6673 if (!(ffestc_parent_ok_ = ffedata_value (rpt, value,
6674 (repeat_token == NULL) ? value_token : repeat_token)))
6675 ffedata_end (TRUE, NULL);
6678 /* ffestc_R501_itemendvals -- End list of values
6680 ffelexToken t; // the SLASH token that ends the list.
6681 ffestc_R501_itemendvals(t);
6683 No more values, might specify more objects now. */
6686 ffestc_R501_itemendvals (ffelexToken t)
6688 ffestc_check_item_endvals_ ();
6690 if (ffestc_parent_ok_)
6691 ffestc_parent_ok_ = ffedata_end (FALSE, t);
6693 if (ffestc_parent_ok_)
6694 ffesymbol_signal_unreported (ffebld_symter (ffebld_head
6695 (ffestc_local_.decl.initlist)));
6698 /* ffestc_R501_finish -- Done
6700 ffestc_R501_finish();
6702 Just wrap up any local activities. */
6705 ffestc_R501_finish ()
6707 ffestc_check_finish_ ();
6710 /* ffestc_R519_start -- INTENT statement list begin
6712 ffestc_R519_start();
6714 Verify that INTENT is valid here, and begin accepting items in the list. */
6718 ffestc_R519_start (ffelexToken intent, ffestrOther intent_kw)
6720 ffestc_check_start_ ();
6721 if (ffestc_order_spec_ () != FFESTC_orderOK_)
6726 ffestc_labeldef_useless_ ();
6728 ffestd_R519_start (intent_kw);
6733 /* ffestc_R519_item -- INTENT statement for name
6735 ffestc_R519_item(name_token);
6737 Make sure name_token identifies a valid object to be INTENTed. */
6740 ffestc_R519_item (ffelexToken name)
6742 ffestc_check_item_ ();
6743 assert (name != NULL);
6747 ffestd_R519_item (name);
6750 /* ffestc_R519_finish -- INTENT statement list complete
6752 ffestc_R519_finish();
6754 Just wrap up any local activities. */
6757 ffestc_R519_finish ()
6759 ffestc_check_finish_ ();
6763 ffestd_R519_finish ();
6766 /* ffestc_R520_start -- OPTIONAL statement list begin
6768 ffestc_R520_start();
6770 Verify that OPTIONAL is valid here, and begin accepting items in the list. */
6773 ffestc_R520_start ()
6775 ffestc_check_start_ ();
6776 if (ffestc_order_spec_ () != FFESTC_orderOK_)
6781 ffestc_labeldef_useless_ ();
6783 ffestd_R520_start ();
6788 /* ffestc_R520_item -- OPTIONAL statement for name
6790 ffestc_R520_item(name_token);
6792 Make sure name_token identifies a valid object to be OPTIONALed. */
6795 ffestc_R520_item (ffelexToken name)
6797 ffestc_check_item_ ();
6798 assert (name != NULL);
6802 ffestd_R520_item (name);
6805 /* ffestc_R520_finish -- OPTIONAL statement list complete
6807 ffestc_R520_finish();
6809 Just wrap up any local activities. */
6812 ffestc_R520_finish ()
6814 ffestc_check_finish_ ();
6818 ffestd_R520_finish ();
6821 /* ffestc_R521A -- PUBLIC statement
6825 Verify that PUBLIC is valid here. */
6830 ffestc_check_simple_ ();
6831 if (ffestc_order_access_ () != FFESTC_orderOK_)
6833 ffestc_labeldef_useless_ ();
6835 switch (ffestv_access_state_)
6837 case FFESTV_accessstateNONE:
6838 ffestv_access_state_ = FFESTV_accessstatePUBLIC;
6840 = ffewhere_line_use (ffelex_token_where_line (ffesta_tokens[0]));
6842 = ffewhere_column_use (ffelex_token_where_column (ffesta_tokens[0]));
6845 case FFESTV_accessstateANY:
6848 case FFESTV_accessstatePUBLIC:
6849 case FFESTV_accessstatePRIVATE:
6850 ffebad_start (FFEBAD_CONFLICTING_ACCESSES);
6851 ffebad_here (0, ffestv_access_line_, ffestv_access_col_);
6852 ffebad_here (1, ffelex_token_where_line (ffesta_tokens[0]),
6853 ffelex_token_where_column (ffesta_tokens[0]));
6855 ffestv_access_state_ = FFESTV_accessstateANY;
6859 assert ("unexpected access state" == NULL);
6866 /* ffestc_R521Astart -- PUBLIC statement list begin
6868 ffestc_R521Astart();
6870 Verify that PUBLIC is valid here, and begin accepting items in the list. */
6873 ffestc_R521Astart ()
6875 ffestc_check_start_ ();
6876 if (ffestc_order_access_ () != FFESTC_orderOK_)
6881 ffestc_labeldef_useless_ ();
6883 ffestd_R521Astart ();
6888 /* ffestc_R521Aitem -- PUBLIC statement for name
6890 ffestc_R521Aitem(name_token);
6892 Make sure name_token identifies a valid object to be PUBLICed. */
6895 ffestc_R521Aitem (ffelexToken name)
6897 ffestc_check_item_ ();
6898 assert (name != NULL);
6902 ffestd_R521Aitem (name);
6905 /* ffestc_R521Afinish -- PUBLIC statement list complete
6907 ffestc_R521Afinish();
6909 Just wrap up any local activities. */
6912 ffestc_R521Afinish ()
6914 ffestc_check_finish_ ();
6918 ffestd_R521Afinish ();
6921 /* ffestc_R521B -- PRIVATE statement
6925 Verify that PRIVATE is valid here (outside a derived-type statement). */
6930 ffestc_check_simple_ ();
6931 if (ffestc_order_access_ () != FFESTC_orderOK_)
6933 ffestc_labeldef_useless_ ();
6935 switch (ffestv_access_state_)
6937 case FFESTV_accessstateNONE:
6938 ffestv_access_state_ = FFESTV_accessstatePRIVATE;
6940 = ffewhere_line_use (ffelex_token_where_line (ffesta_tokens[0]));
6942 = ffewhere_column_use (ffelex_token_where_column (ffesta_tokens[0]));
6945 case FFESTV_accessstateANY:
6948 case FFESTV_accessstatePUBLIC:
6949 case FFESTV_accessstatePRIVATE:
6950 ffebad_start (FFEBAD_CONFLICTING_ACCESSES);
6951 ffebad_here (0, ffestv_access_line_, ffestv_access_col_);
6952 ffebad_here (1, ffelex_token_where_line (ffesta_tokens[0]),
6953 ffelex_token_where_column (ffesta_tokens[0]));
6955 ffestv_access_state_ = FFESTV_accessstateANY;
6959 assert ("unexpected access state" == NULL);
6966 /* ffestc_R521Bstart -- PRIVATE statement list begin
6968 ffestc_R521Bstart();
6970 Verify that PRIVATE is valid here, and begin accepting items in the list. */
6973 ffestc_R521Bstart ()
6975 ffestc_check_start_ ();
6976 if (ffestc_order_access_ () != FFESTC_orderOK_)
6981 ffestc_labeldef_useless_ ();
6983 ffestd_R521Bstart ();
6988 /* ffestc_R521Bitem -- PRIVATE statement for name
6990 ffestc_R521Bitem(name_token);
6992 Make sure name_token identifies a valid object to be PRIVATEed. */
6995 ffestc_R521Bitem (ffelexToken name)
6997 ffestc_check_item_ ();
6998 assert (name != NULL);
7002 ffestd_R521Bitem (name);
7005 /* ffestc_R521Bfinish -- PRIVATE statement list complete
7007 ffestc_R521Bfinish();
7009 Just wrap up any local activities. */
7012 ffestc_R521Bfinish ()
7014 ffestc_check_finish_ ();
7018 ffestd_R521Bfinish ();
7022 /* ffestc_R522 -- SAVE statement with no list
7026 Verify that SAVE is valid here, and flag everything as SAVEd. */
7031 ffestc_check_simple_ ();
7032 if (ffestc_order_blockspec_ () != FFESTC_orderOK_)
7034 ffestc_labeldef_useless_ ();
7036 switch (ffestv_save_state_)
7038 case FFESTV_savestateNONE:
7039 ffestv_save_state_ = FFESTV_savestateALL;
7041 = ffewhere_line_use (ffelex_token_where_line (ffesta_tokens[0]));
7043 = ffewhere_column_use (ffelex_token_where_column (ffesta_tokens[0]));
7046 case FFESTV_savestateANY:
7049 case FFESTV_savestateSPECIFIC:
7050 case FFESTV_savestateALL:
7051 if (ffe_is_pedantic ())
7053 ffebad_start (FFEBAD_CONFLICTING_SAVES);
7054 ffebad_here (0, ffestv_save_line_, ffestv_save_col_);
7055 ffebad_here (1, ffelex_token_where_line (ffesta_tokens[0]),
7056 ffelex_token_where_column (ffesta_tokens[0]));
7059 ffestv_save_state_ = FFESTV_savestateALL;
7063 assert ("unexpected save state" == NULL);
7067 ffe_set_is_saveall (TRUE);
7072 /* ffestc_R522start -- SAVE statement list begin
7076 Verify that SAVE is valid here, and begin accepting items in the list. */
7081 ffestc_check_start_ ();
7082 if (ffestc_order_blockspec_ () != FFESTC_orderOK_)
7087 ffestc_labeldef_useless_ ();
7089 switch (ffestv_save_state_)
7091 case FFESTV_savestateNONE:
7092 ffestv_save_state_ = FFESTV_savestateSPECIFIC;
7094 = ffewhere_line_use (ffelex_token_where_line (ffesta_tokens[0]));
7096 = ffewhere_column_use (ffelex_token_where_column (ffesta_tokens[0]));
7099 case FFESTV_savestateSPECIFIC:
7100 case FFESTV_savestateANY:
7103 case FFESTV_savestateALL:
7104 if (ffe_is_pedantic ())
7106 ffebad_start (FFEBAD_CONFLICTING_SAVES);
7107 ffebad_here (0, ffestv_save_line_, ffestv_save_col_);
7108 ffebad_here (1, ffelex_token_where_line (ffesta_tokens[0]),
7109 ffelex_token_where_column (ffesta_tokens[0]));
7112 ffestv_save_state_ = FFESTV_savestateANY;
7116 assert ("unexpected save state" == NULL);
7120 ffestd_R522start ();
7125 /* ffestc_R522item_object -- SAVE statement for object-name
7127 ffestc_R522item_object(name_token);
7129 Make sure name_token identifies a valid object to be SAVEd. */
7132 ffestc_R522item_object (ffelexToken name)
7138 ffestc_check_item_ ();
7139 assert (name != NULL);
7143 s = ffesymbol_declare_local (name, FALSE);
7144 sa = ffesymbol_attrs (s);
7146 /* Figure out what kind of object we've got based on previous declarations
7147 of or references to the object. */
7149 if (!ffesymbol_is_specable (s)
7150 && ((ffesymbol_kind (s) != FFEINFO_kindENTITY)
7151 || (ffesymbol_where (s) != FFEINFO_whereLOCAL)))
7152 na = FFESYMBOL_attrsetNONE; /* Can't dcl sym ref'd in sfuncdef. */
7153 else if (sa & FFESYMBOL_attrsANY)
7155 else if (!(sa & ~(FFESYMBOL_attrsARRAY
7156 | FFESYMBOL_attrsEQUIV
7157 | FFESYMBOL_attrsINIT
7158 | FFESYMBOL_attrsNAMELIST
7159 | FFESYMBOL_attrsSFARG
7160 | FFESYMBOL_attrsTYPE)))
7161 na = sa | FFESYMBOL_attrsSAVE;
7163 na = FFESYMBOL_attrsetNONE;
7165 /* Now see what we've got for a new object: NONE means a new error cropped
7166 up; ANY means an old error to be ignored; otherwise, everything's ok,
7167 update the object (symbol) and continue on. */
7169 if (na == FFESYMBOL_attrsetNONE)
7170 ffesymbol_error (s, name);
7171 else if (!(na & FFESYMBOL_attrsANY))
7173 ffesymbol_set_attrs (s, na);
7174 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
7175 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
7176 ffesymbol_update_save (s);
7177 ffesymbol_signal_unreported (s);
7180 ffestd_R522item_object (name);
7183 /* ffestc_R522item_cblock -- SAVE statement for common-block-name
7185 ffestc_R522item_cblock(name_token);
7187 Make sure name_token identifies a valid common block to be SAVEd. */
7190 ffestc_R522item_cblock (ffelexToken name)
7196 ffestc_check_item_ ();
7197 assert (name != NULL);
7201 s = ffesymbol_declare_cblock (name, ffelex_token_where_line (ffesta_tokens[0]),
7202 ffelex_token_where_column (ffesta_tokens[0]));
7203 sa = ffesymbol_attrs (s);
7205 /* Figure out what kind of object we've got based on previous declarations
7206 of or references to the object. */
7208 if (!ffesymbol_is_specable (s))
7209 na = FFESYMBOL_attrsetNONE;
7210 else if (sa & FFESYMBOL_attrsANY)
7211 na = sa; /* Already have an error here, say nothing. */
7212 else if (!(sa & ~(FFESYMBOL_attrsCBLOCK)))
7213 na = sa | FFESYMBOL_attrsSAVECBLOCK;
7215 na = FFESYMBOL_attrsetNONE;
7217 /* Now see what we've got for a new object: NONE means a new error cropped
7218 up; ANY means an old error to be ignored; otherwise, everything's ok,
7219 update the object (symbol) and continue on. */
7221 if (na == FFESYMBOL_attrsetNONE)
7222 ffesymbol_error (s, (name == NULL) ? ffesta_tokens[0] : name);
7223 else if (!(na & FFESYMBOL_attrsANY))
7225 ffesymbol_set_attrs (s, na);
7226 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
7227 ffesymbol_update_save (s);
7228 ffesymbol_signal_unreported (s);
7231 ffestd_R522item_cblock (name);
7234 /* ffestc_R522finish -- SAVE statement list complete
7236 ffestc_R522finish();
7238 Just wrap up any local activities. */
7241 ffestc_R522finish ()
7243 ffestc_check_finish_ ();
7247 ffestd_R522finish ();
7250 /* ffestc_R524_start -- DIMENSION statement list begin
7252 ffestc_R524_start(bool virtual);
7254 Verify that DIMENSION is valid here, and begin accepting items in the
7258 ffestc_R524_start (bool virtual)
7260 ffestc_check_start_ ();
7261 if (ffestc_order_blockspec_ () != FFESTC_orderOK_)
7266 ffestc_labeldef_useless_ ();
7268 ffestd_R524_start (virtual);
7273 /* ffestc_R524_item -- DIMENSION statement for object-name
7275 ffestc_R524_item(name_token,dim_list);
7277 Make sure name_token identifies a valid object to be DIMENSIONd. */
7280 ffestc_R524_item (ffelexToken name, ffesttDimList dims)
7289 bool is_ugly_assumed;
7291 ffestc_check_item_ ();
7292 assert (name != NULL);
7293 assert (dims != NULL);
7297 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
7299 s = ffesymbol_declare_local (name, FALSE);
7300 sa = ffesymbol_attrs (s);
7302 /* First figure out what kind of object this is based solely on the current
7303 object situation (dimension list). */
7305 is_ugly_assumed = (ffe_is_ugly_assumed ()
7306 && ((sa & FFESYMBOL_attrsDUMMY)
7307 || (ffesymbol_where (s) == FFEINFO_whereDUMMY)));
7309 nd = ffestt_dimlist_type (dims, is_ugly_assumed);
7312 case FFESTP_dimtypeKNOWN:
7313 na = FFESYMBOL_attrsARRAY;
7316 case FFESTP_dimtypeADJUSTABLE:
7317 na = FFESYMBOL_attrsARRAY | FFESYMBOL_attrsADJUSTABLE;
7320 case FFESTP_dimtypeASSUMED:
7321 na = FFESYMBOL_attrsARRAY | FFESYMBOL_attrsANYSIZE;
7324 case FFESTP_dimtypeADJUSTABLEASSUMED:
7325 na = FFESYMBOL_attrsARRAY | FFESYMBOL_attrsADJUSTABLE
7326 | FFESYMBOL_attrsANYSIZE;
7330 assert ("Unexpected dims type" == NULL);
7331 na = FFESYMBOL_attrsetNONE;
7335 /* Now figure out what kind of object we've got based on previous
7336 declarations of or references to the object. */
7338 if (!ffesymbol_is_specable (s))
7339 na = FFESYMBOL_attrsetNONE; /* Can't dcl sym ref'd in sfuncdef. */
7340 else if (sa & FFESYMBOL_attrsANY)
7341 na = FFESYMBOL_attrsANY;
7342 else if (!ffesta_is_entry_valid
7343 && (sa & FFESYMBOL_attrsANYLEN))
7344 na = FFESYMBOL_attrsetNONE;
7345 else if ((sa & FFESYMBOL_attrsARRAY)
7346 || ((sa & (FFESYMBOL_attrsCOMMON
7347 | FFESYMBOL_attrsEQUIV
7348 | FFESYMBOL_attrsNAMELIST
7349 | FFESYMBOL_attrsSAVE))
7350 && (na & (FFESYMBOL_attrsADJUSTABLE
7351 | FFESYMBOL_attrsANYSIZE))))
7352 na = FFESYMBOL_attrsetNONE;
7353 else if (!(sa & ~(FFESYMBOL_attrsADJUSTABLE
7354 | FFESYMBOL_attrsANYLEN
7355 | FFESYMBOL_attrsANYSIZE
7356 | FFESYMBOL_attrsCOMMON
7357 | FFESYMBOL_attrsDUMMY
7358 | FFESYMBOL_attrsEQUIV
7359 | FFESYMBOL_attrsNAMELIST
7360 | FFESYMBOL_attrsSAVE
7361 | FFESYMBOL_attrsTYPE)))
7364 na = FFESYMBOL_attrsetNONE;
7366 /* Now see what we've got for a new object: NONE means a new error cropped
7367 up; ANY means an old error to be ignored; otherwise, everything's ok,
7368 update the object (symbol) and continue on. */
7370 if (na == FFESYMBOL_attrsetNONE)
7371 ffesymbol_error (s, name);
7372 else if (!(na & FFESYMBOL_attrsANY))
7374 ffesymbol_set_attrs (s, na);
7375 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
7376 ffesymbol_set_dims (s, ffestt_dimlist_as_expr (dims, &rank,
7380 ffesymbol_set_arraysize (s, array_size);
7381 ffesymbol_set_extents (s, extents);
7382 if (!(0 && ffe_is_90 ())
7383 && (ffebld_op (array_size) == FFEBLD_opCONTER)
7384 && (ffebld_constant_integerdefault (ffebld_conter (array_size))
7387 ffebad_start (FFEBAD_ZERO_ARRAY);
7388 ffebad_here (0, ffelex_token_where_line (name),
7389 ffelex_token_where_column (name));
7392 ffesymbol_set_info (s,
7393 ffeinfo_new (ffesymbol_basictype (s),
7394 ffesymbol_kindtype (s),
7397 ffesymbol_where (s),
7398 ffesymbol_size (s)));
7401 ffesymbol_signal_unreported (s);
7403 ffestd_R524_item (name, dims);
7406 /* ffestc_R524_finish -- DIMENSION statement list complete
7408 ffestc_R524_finish();
7410 Just wrap up any local activities. */
7413 ffestc_R524_finish ()
7415 ffestc_check_finish_ ();
7419 ffestd_R524_finish ();
7422 /* ffestc_R525_start -- ALLOCATABLE statement list begin
7424 ffestc_R525_start();
7426 Verify that ALLOCATABLE is valid here, and begin accepting items in the
7431 ffestc_R525_start ()
7433 ffestc_check_start_ ();
7434 if (ffestc_order_progspec_ () != FFESTC_orderOK_)
7439 ffestc_labeldef_useless_ ();
7441 ffestd_R525_start ();
7446 /* ffestc_R525_item -- ALLOCATABLE statement for object-name
7448 ffestc_R525_item(name_token,dim_list);
7450 Make sure name_token identifies a valid object to be ALLOCATABLEd. */
7453 ffestc_R525_item (ffelexToken name, ffesttDimList dims)
7455 ffestc_check_item_ ();
7456 assert (name != NULL);
7460 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
7462 ffestd_R525_item (name, dims);
7465 /* ffestc_R525_finish -- ALLOCATABLE statement list complete
7467 ffestc_R525_finish();
7469 Just wrap up any local activities. */
7472 ffestc_R525_finish ()
7474 ffestc_check_finish_ ();
7478 ffestd_R525_finish ();
7481 /* ffestc_R526_start -- POINTER statement list begin
7483 ffestc_R526_start();
7485 Verify that POINTER is valid here, and begin accepting items in the
7489 ffestc_R526_start ()
7491 ffestc_check_start_ ();
7492 if (ffestc_order_progspec_ () != FFESTC_orderOK_)
7497 ffestc_labeldef_useless_ ();
7499 ffestd_R526_start ();
7504 /* ffestc_R526_item -- POINTER statement for object-name
7506 ffestc_R526_item(name_token,dim_list);
7508 Make sure name_token identifies a valid object to be POINTERd. */
7511 ffestc_R526_item (ffelexToken name, ffesttDimList dims)
7513 ffestc_check_item_ ();
7514 assert (name != NULL);
7518 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
7520 ffestd_R526_item (name, dims);
7523 /* ffestc_R526_finish -- POINTER statement list complete
7525 ffestc_R526_finish();
7527 Just wrap up any local activities. */
7530 ffestc_R526_finish ()
7532 ffestc_check_finish_ ();
7536 ffestd_R526_finish ();
7539 /* ffestc_R527_start -- TARGET statement list begin
7541 ffestc_R527_start();
7543 Verify that TARGET is valid here, and begin accepting items in the
7547 ffestc_R527_start ()
7549 ffestc_check_start_ ();
7550 if (ffestc_order_progspec_ () != FFESTC_orderOK_)
7555 ffestc_labeldef_useless_ ();
7557 ffestd_R527_start ();
7562 /* ffestc_R527_item -- TARGET statement for object-name
7564 ffestc_R527_item(name_token,dim_list);
7566 Make sure name_token identifies a valid object to be TARGETd. */
7569 ffestc_R527_item (ffelexToken name, ffesttDimList dims)
7571 ffestc_check_item_ ();
7572 assert (name != NULL);
7576 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
7578 ffestd_R527_item (name, dims);
7581 /* ffestc_R527_finish -- TARGET statement list complete
7583 ffestc_R527_finish();
7585 Just wrap up any local activities. */
7588 ffestc_R527_finish ()
7590 ffestc_check_finish_ ();
7594 ffestd_R527_finish ();
7598 /* ffestc_R528_start -- DATA statement list begin
7600 ffestc_R528_start();
7602 Verify that DATA is valid here, and begin accepting items in the list. */
7605 ffestc_R528_start ()
7609 ffestc_check_start_ ();
7610 if (ffe_is_pedantic_not_90 ())
7611 order = ffestc_order_data77_ ();
7613 order = ffestc_order_data_ ();
7614 if (order != FFESTC_orderOK_)
7619 ffestc_labeldef_useless_ ();
7621 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
7624 ffestc_local_.data.objlist = NULL;
7626 ffestd_R528_start_ ();
7632 /* ffestc_R528_item_object -- DATA statement target object
7634 ffestc_R528_item_object(object,object_token);
7636 Make sure object is valid to be DATAd. */
7639 ffestc_R528_item_object (ffebld expr, ffelexToken expr_token UNUSED)
7641 ffestc_check_item_ ();
7646 if (ffestc_local_.data.objlist == NULL)
7647 ffebld_init_list (&ffestc_local_.data.objlist,
7648 &ffestc_local_.data.list_bottom);
7650 ffebld_append_item (&ffestc_local_.data.list_bottom, expr);
7652 ffestd_R528_item_object_ (expr, expr_token);
7656 /* ffestc_R528_item_startvals -- DATA statement start list of values
7658 ffestc_R528_item_startvals();
7660 No more objects, gonna specify values for the list of objects now. */
7663 ffestc_R528_item_startvals ()
7665 ffestc_check_item_startvals_ ();
7670 assert (ffestc_local_.data.objlist != NULL);
7671 ffebld_end_list (&ffestc_local_.data.list_bottom);
7672 ffedata_begin (ffestc_local_.data.objlist);
7674 ffestd_R528_item_startvals_ ();
7678 /* ffestc_R528_item_value -- DATA statement source value
7680 ffestc_R528_item_value(repeat,repeat_token,value,value_token);
7682 Make sure repeat and value are valid for the objects being initialized. */
7685 ffestc_R528_item_value (ffebld repeat, ffelexToken repeat_token,
7686 ffebld value, ffelexToken value_token)
7688 ffetargetIntegerDefault rpt;
7690 ffestc_check_item_value_ ();
7697 else if (ffebld_op (repeat) == FFEBLD_opCONTER)
7698 rpt = ffebld_constant_integerdefault (ffebld_conter (repeat));
7702 ffedata_end (TRUE, NULL);
7706 if (!(ffestc_ok_ = ffedata_value (rpt, value,
7707 (repeat_token == NULL)
7710 ffedata_end (TRUE, NULL);
7713 ffestd_R528_item_value_ (repeat, value);
7717 /* ffestc_R528_item_endvals -- DATA statement start list of values
7719 ffelexToken t; // the SLASH token that ends the list.
7720 ffestc_R528_item_endvals(t);
7722 No more values, might specify more objects now. */
7725 ffestc_R528_item_endvals (ffelexToken t)
7727 ffestc_check_item_endvals_ ();
7732 ffedata_end (!ffestc_ok_, t);
7733 ffestc_local_.data.objlist = NULL;
7735 ffestd_R528_item_endvals_ (t);
7739 /* ffestc_R528_finish -- DATA statement list complete
7741 ffestc_R528_finish();
7743 Just wrap up any local activities. */
7746 ffestc_R528_finish ()
7748 ffestc_check_finish_ ();
7752 ffestd_R528_finish_ ();
7756 /* ffestc_R537_start -- PARAMETER statement list begin
7758 ffestc_R537_start();
7760 Verify that PARAMETER is valid here, and begin accepting items in the
7764 ffestc_R537_start ()
7766 ffestc_check_start_ ();
7767 if (ffestc_order_parameter_ () != FFESTC_orderOK_)
7772 ffestc_labeldef_useless_ ();
7774 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
7776 ffestd_R537_start ();
7781 /* ffestc_R537_item -- PARAMETER statement assignment
7783 ffestc_R537_item(dest,dest_token,source,source_token);
7785 Make sure the source is a valid source for the destination; make the
7789 ffestc_R537_item (ffebld dest, ffelexToken dest_token, ffebld source,
7790 ffelexToken source_token)
7794 ffestc_check_item_ ();
7798 if ((ffebld_op (dest) == FFEBLD_opANY)
7799 || (ffebld_op (source) == FFEBLD_opANY))
7801 if (ffebld_op (dest) == FFEBLD_opSYMTER)
7803 s = ffebld_symter (dest);
7804 ffesymbol_set_init (s, ffebld_new_any ());
7805 ffebld_set_info (ffesymbol_init (s), ffeinfo_new_any ());
7806 ffesymbol_signal_unreported (s);
7808 ffestd_R537_item (dest, source);
7812 assert (ffebld_op (dest) == FFEBLD_opSYMTER);
7813 assert (ffebld_op (source) == FFEBLD_opCONTER);
7815 s = ffebld_symter (dest);
7816 if ((ffesymbol_basictype (s) == FFEINFO_basictypeCHARACTER)
7817 && (ffesymbol_size (s) == FFETARGET_charactersizeNONE))
7818 { /* Destination has explicit/implicit
7819 CHARACTER*(*) type; set length. */
7820 ffesymbol_set_info (s,
7821 ffeinfo_new (ffesymbol_basictype (s),
7822 ffesymbol_kindtype (s),
7825 ffesymbol_where (s),
7826 ffebld_size (source)));
7827 ffebld_set_info (dest, ffeinfo_use (ffesymbol_info (s)));
7830 source = ffeexpr_convert_expr (source, source_token, dest, dest_token,
7831 FFEEXPR_contextDATA);
7833 ffesymbol_set_init (s, source);
7835 ffesymbol_signal_unreported (s);
7837 ffestd_R537_item (dest, source);
7840 /* ffestc_R537_finish -- PARAMETER statement list complete
7842 ffestc_R537_finish();
7844 Just wrap up any local activities. */
7847 ffestc_R537_finish ()
7849 ffestc_check_finish_ ();
7853 ffestd_R537_finish ();
7856 /* ffestc_R539 -- IMPLICIT NONE statement
7860 Verify that the IMPLICIT NONE statement is ok here and implement. */
7865 ffestc_check_simple_ ();
7866 if (ffestc_order_implicitnone_ () != FFESTC_orderOK_)
7868 ffestc_labeldef_useless_ ();
7875 /* ffestc_R539start -- IMPLICIT statement
7879 Verify that the IMPLICIT statement is ok here and implement. */
7884 ffestc_check_start_ ();
7885 if (ffestc_order_implicit_ () != FFESTC_orderOK_)
7890 ffestc_labeldef_useless_ ();
7892 ffestd_R539start ();
7897 /* ffestc_R539item -- IMPLICIT statement specification (R540)
7899 ffestc_R539item(...);
7901 Verify that the type and letter list are all ok and implement. */
7904 ffestc_R539item (ffestpType type, ffebld kind, ffelexToken kindt,
7905 ffebld len, ffelexToken lent, ffesttImpList letters)
7907 ffestc_check_item_ ();
7911 if ((type == FFESTP_typeCHARACTER) && (len != NULL)
7912 && (ffebld_op (len) == FFEBLD_opSTAR))
7913 { /* Complain and pretend they're CHARACTER
7915 ffebad_start (FFEBAD_IMPLICIT_ADJLEN);
7916 ffebad_here (0, ffelex_token_where_line (lent),
7917 ffelex_token_where_column (lent));
7922 ffestc_establish_declstmt_ (type, ffesta_tokens[0], kind, kindt, len, lent);
7923 ffestc_establish_declinfo_ (NULL, NULL, NULL, NULL);
7925 ffestt_implist_drive (letters, ffestc_establish_impletter_);
7927 ffestd_R539item (type, kind, kindt, len, lent, letters);
7930 /* ffestc_R539finish -- IMPLICIT statement
7932 ffestc_R539finish();
7934 Finish up any local activities. */
7937 ffestc_R539finish ()
7939 ffestc_check_finish_ ();
7943 ffestd_R539finish ();
7946 /* ffestc_R542_start -- NAMELIST statement list begin
7948 ffestc_R542_start();
7950 Verify that NAMELIST is valid here, and begin accepting items in the
7954 ffestc_R542_start ()
7956 ffestc_check_start_ ();
7957 if (ffestc_order_progspec_ () != FFESTC_orderOK_)
7962 ffestc_labeldef_useless_ ();
7964 if (ffe_is_f2c_library ()
7965 && (ffe_case_source () == FFE_caseNONE))
7967 ffebad_start (FFEBAD_NAMELIST_CASE);
7968 ffesta_ffebad_here_current_stmt (0);
7972 ffestd_R542_start ();
7974 ffestc_local_.namelist.symbol = NULL;
7979 /* ffestc_R542_item_nlist -- NAMELIST statement for group-name
7981 ffestc_R542_item_nlist(groupname_token);
7983 Make sure name_token identifies a valid object to be NAMELISTd. */
7986 ffestc_R542_item_nlist (ffelexToken name)
7990 ffestc_check_item_ ();
7991 assert (name != NULL);
7995 if (ffestc_local_.namelist.symbol != NULL)
7996 ffesymbol_signal_unreported (ffestc_local_.namelist.symbol);
7998 s = ffesymbol_declare_local (name, FALSE);
8000 if ((ffesymbol_state (s) == FFESYMBOL_stateNONE)
8001 || ((ffesymbol_state (s) == FFESYMBOL_stateUNDERSTOOD)
8002 && (ffesymbol_kind (s) == FFEINFO_kindNAMELIST)))
8004 ffestc_parent_ok_ = TRUE;
8005 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
8007 ffebld_init_list (ffesymbol_ptr_to_namelist (s),
8008 ffesymbol_ptr_to_listbottom (s));
8009 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
8010 ffesymbol_set_info (s,
8011 ffeinfo_new (FFEINFO_basictypeNONE,
8012 FFEINFO_kindtypeNONE,
8014 FFEINFO_kindNAMELIST,
8016 FFETARGET_charactersizeNONE));
8021 if (ffesymbol_kind (s) != FFEINFO_kindANY)
8022 ffesymbol_error (s, name);
8023 ffestc_parent_ok_ = FALSE;
8026 ffestc_local_.namelist.symbol = s;
8028 ffestd_R542_item_nlist (name);
8031 /* ffestc_R542_item_nitem -- NAMELIST statement for variable-name
8033 ffestc_R542_item_nitem(name_token);
8035 Make sure name_token identifies a valid object to be NAMELISTd. */
8038 ffestc_R542_item_nitem (ffelexToken name)
8045 ffestc_check_item_ ();
8046 assert (name != NULL);
8050 s = ffesymbol_declare_local (name, FALSE);
8051 sa = ffesymbol_attrs (s);
8053 /* Figure out what kind of object we've got based on previous declarations
8054 of or references to the object. */
8056 if (!ffesymbol_is_specable (s)
8057 && ((ffesymbol_kind (s) != FFEINFO_kindENTITY)
8058 || ((ffesymbol_where (s) != FFEINFO_whereLOCAL)
8059 && (ffesymbol_where (s) != FFEINFO_whereCOMMON))))
8060 na = FFESYMBOL_attrsetNONE;
8061 else if (sa & FFESYMBOL_attrsANY)
8062 na = FFESYMBOL_attrsANY;
8063 else if (!(sa & ~(FFESYMBOL_attrsADJUSTS
8064 | FFESYMBOL_attrsARRAY
8065 | FFESYMBOL_attrsCOMMON
8066 | FFESYMBOL_attrsEQUIV
8067 | FFESYMBOL_attrsINIT
8068 | FFESYMBOL_attrsNAMELIST
8069 | FFESYMBOL_attrsSAVE
8070 | FFESYMBOL_attrsSFARG
8071 | FFESYMBOL_attrsTYPE)))
8072 na = sa | FFESYMBOL_attrsNAMELIST;
8074 na = FFESYMBOL_attrsetNONE;
8076 /* Now see what we've got for a new object: NONE means a new error cropped
8077 up; ANY means an old error to be ignored; otherwise, everything's ok,
8078 update the object (symbol) and continue on. */
8080 if (na == FFESYMBOL_attrsetNONE)
8081 ffesymbol_error (s, name);
8082 else if (!(na & FFESYMBOL_attrsANY))
8084 ffesymbol_set_attrs (s, na);
8085 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
8086 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
8087 ffesymbol_set_namelisted (s, TRUE);
8088 ffesymbol_signal_unreported (s);
8089 #if 0 /* No need to establish type yet! */
8090 if (!ffeimplic_establish_symbol (s))
8091 ffesymbol_error (s, name);
8095 if (ffestc_parent_ok_)
8097 e = ffebld_new_symter (s, FFEINTRIN_genNONE, FFEINTRIN_specNONE,
8100 ffeinfo_new (FFEINFO_basictypeNONE,
8101 FFEINFO_kindtypeNONE, 0,
8104 FFETARGET_charactersizeNONE));
8106 (ffesymbol_ptr_to_listbottom (ffestc_local_.namelist.symbol), e);
8109 ffestd_R542_item_nitem (name);
8112 /* ffestc_R542_finish -- NAMELIST statement list complete
8114 ffestc_R542_finish();
8116 Just wrap up any local activities. */
8119 ffestc_R542_finish ()
8121 ffestc_check_finish_ ();
8125 ffesymbol_signal_unreported (ffestc_local_.namelist.symbol);
8127 ffestd_R542_finish ();
8130 /* ffestc_R544_start -- EQUIVALENCE statement list begin
8132 ffestc_R544_start();
8134 Verify that EQUIVALENCE is valid here, and begin accepting items in the
8138 ffestc_R544_start ()
8140 ffestc_check_start_ ();
8141 if (ffestc_order_blockspec_ () != FFESTC_orderOK_)
8146 ffestc_labeldef_useless_ ();
8148 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
8153 /* ffestc_R544_item -- EQUIVALENCE statement assignment
8155 ffestc_R544_item(exprlist);
8157 Make sure the equivalence is valid, then implement it. */
8160 ffestc_R544_item (ffesttExprList exprlist)
8162 ffestc_check_item_ ();
8166 /* First we go through the list and come up with one ffeequiv object that
8167 will describe all items in the list. When an ffeequiv object is first
8168 found, it is used (else we create one as a "local equiv" for the time
8169 being). If subsequent ffeequiv objects are found, they are merged with
8170 the first so we end up with one. However, if more than one COMMON
8171 variable is involved, then an error condition occurs. */
8173 ffestc_local_.equiv.ok = TRUE;
8174 ffestc_local_.equiv.t = NULL; /* No token yet. */
8175 ffestc_local_.equiv.eq = NULL;/* No equiv yet. */
8176 ffestc_local_.equiv.save = FALSE; /* No SAVEd variables yet. */
8178 ffebld_init_list (&ffestc_local_.equiv.list, &ffestc_local_.equiv.bottom);
8179 ffestt_exprlist_drive (exprlist, ffestc_R544_equiv_); /* Get one equiv. */
8180 ffebld_end_list (&ffestc_local_.equiv.bottom);
8182 if (!ffestc_local_.equiv.ok)
8183 return; /* Something went wrong, stop bothering with
8186 if (ffestc_local_.equiv.eq == NULL)
8187 ffestc_local_.equiv.eq = ffeequiv_new (); /* Make local equivalence. */
8189 /* Append this list of equivalences to list of such lists for this
8192 ffeequiv_add (ffestc_local_.equiv.eq, ffestc_local_.equiv.list,
8193 ffestc_local_.equiv.t);
8194 if (ffestc_local_.equiv.save)
8195 ffeequiv_update_save (ffestc_local_.equiv.eq);
8198 /* ffestc_R544_equiv_ -- EQUIVALENCE statement handler for item in list
8202 ffestc_R544_equiv_(expr,t);
8204 Record information, if any, on symbol in expr; if symbol has equivalence
8205 object already, merge with outstanding object if present or make it
8206 the outstanding object. */
8209 ffestc_R544_equiv_ (ffebld expr, ffelexToken t)
8213 if (!ffestc_local_.equiv.ok)
8216 if (ffestc_local_.equiv.t == NULL)
8217 ffestc_local_.equiv.t = t;
8219 switch (ffebld_op (expr))
8222 return; /* Don't put this on the list. */
8224 case FFEBLD_opSYMTER:
8225 case FFEBLD_opARRAYREF:
8226 case FFEBLD_opSUBSTR:
8227 break; /* All of these are ok. */
8230 assert ("ffestc_R544_equiv_ bad op" == NULL);
8234 ffebld_append_item (&ffestc_local_.equiv.bottom, expr);
8236 s = ffeequiv_symbol (expr);
8238 /* See if symbol has an equivalence object already. */
8240 if (ffesymbol_equiv (s) != NULL)
8241 if (ffestc_local_.equiv.eq == NULL)
8242 ffestc_local_.equiv.eq = ffesymbol_equiv (s); /* New equiv obj. */
8243 else if (ffestc_local_.equiv.eq != ffesymbol_equiv (s))
8245 ffestc_local_.equiv.eq = ffeequiv_merge (ffesymbol_equiv (s),
8246 ffestc_local_.equiv.eq,
8248 if (ffestc_local_.equiv.eq == NULL)
8249 ffestc_local_.equiv.ok = FALSE; /* Couldn't merge. */
8252 if (ffesymbol_is_save (s))
8253 ffestc_local_.equiv.save = TRUE;
8256 /* ffestc_R544_finish -- EQUIVALENCE statement list complete
8258 ffestc_R544_finish();
8260 Just wrap up any local activities. */
8263 ffestc_R544_finish ()
8265 ffestc_check_finish_ ();
8268 /* ffestc_R547_start -- COMMON statement list begin
8270 ffestc_R547_start();
8272 Verify that COMMON is valid here, and begin accepting items in the list. */
8275 ffestc_R547_start ()
8277 ffestc_check_start_ ();
8278 if (ffestc_order_blockspec_ () != FFESTC_orderOK_)
8283 ffestc_labeldef_useless_ ();
8285 ffestc_local_.common.symbol = NULL; /* Blank common is the default. */
8286 ffestc_parent_ok_ = TRUE;
8288 ffestd_R547_start ();
8293 /* ffestc_R547_item_object -- COMMON statement for object-name
8295 ffestc_R547_item_object(name_token,dim_list);
8297 Make sure name_token identifies a valid object to be COMMONd. */
8300 ffestc_R547_item_object (ffelexToken name, ffesttDimList dims)
8310 bool is_ugly_assumed;
8312 if (ffestc_parent_ok_ && (ffestc_local_.common.symbol == NULL))
8313 ffestc_R547_item_cblock (NULL); /* As if "COMMON [//] ...". */
8315 ffestc_check_item_ ();
8316 assert (name != NULL);
8321 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
8323 s = ffesymbol_declare_local (name, FALSE);
8324 sa = ffesymbol_attrs (s);
8326 /* First figure out what kind of object this is based solely on the current
8327 object situation (dimension list). */
8329 is_ugly_assumed = (ffe_is_ugly_assumed ()
8330 && ((sa & FFESYMBOL_attrsDUMMY)
8331 || (ffesymbol_where (s) == FFEINFO_whereDUMMY)));
8333 nd = ffestt_dimlist_type (dims, is_ugly_assumed);
8336 case FFESTP_dimtypeNONE:
8337 na = FFESYMBOL_attrsCOMMON;
8340 case FFESTP_dimtypeKNOWN:
8341 na = FFESYMBOL_attrsCOMMON | FFESYMBOL_attrsARRAY;
8345 na = FFESYMBOL_attrsetNONE;
8349 /* Figure out what kind of object we've got based on previous declarations
8350 of or references to the object. */
8352 if (na == FFESYMBOL_attrsetNONE)
8354 else if (!ffesymbol_is_specable (s))
8355 na = FFESYMBOL_attrsetNONE; /* Can't dcl sym ref'd in sfuncdef. */
8356 else if (sa & FFESYMBOL_attrsANY)
8357 na = FFESYMBOL_attrsANY;
8358 else if ((sa & (FFESYMBOL_attrsADJUSTS
8359 | FFESYMBOL_attrsARRAY
8360 | FFESYMBOL_attrsINIT
8361 | FFESYMBOL_attrsSFARG))
8362 && (na & FFESYMBOL_attrsARRAY))
8363 na = FFESYMBOL_attrsetNONE;
8364 else if (!(sa & ~(FFESYMBOL_attrsADJUSTS
8365 | FFESYMBOL_attrsARRAY
8366 | FFESYMBOL_attrsEQUIV
8367 | FFESYMBOL_attrsINIT
8368 | FFESYMBOL_attrsNAMELIST
8369 | FFESYMBOL_attrsSFARG
8370 | FFESYMBOL_attrsTYPE)))
8373 na = FFESYMBOL_attrsetNONE;
8375 /* Now see what we've got for a new object: NONE means a new error cropped
8376 up; ANY means an old error to be ignored; otherwise, everything's ok,
8377 update the object (symbol) and continue on. */
8379 if (na == FFESYMBOL_attrsetNONE)
8380 ffesymbol_error (s, name);
8381 else if ((ffesymbol_equiv (s) != NULL)
8382 && (ffeequiv_common (ffesymbol_equiv (s)) != NULL)
8383 && (ffeequiv_common (ffesymbol_equiv (s))
8384 != ffestc_local_.common.symbol))
8386 /* Oops, just COMMONed a symbol to a different area (via equiv). */
8387 ffebad_start (FFEBAD_EQUIV_COMMON);
8388 ffebad_here (0, ffelex_token_where_line (name),
8389 ffelex_token_where_column (name));
8390 ffebad_string (ffesymbol_text (ffestc_local_.common.symbol));
8391 ffebad_string (ffesymbol_text (ffeequiv_common (ffesymbol_equiv (s))));
8393 ffesymbol_set_attr (s, na | FFESYMBOL_attrANY);
8394 ffesymbol_set_info (s, ffeinfo_new_any ());
8395 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
8396 ffesymbol_signal_unreported (s);
8398 else if (!(na & FFESYMBOL_attrsANY))
8400 ffesymbol_set_attrs (s, na);
8401 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
8402 ffesymbol_set_common (s, ffestc_local_.common.symbol);
8403 #if FFEGLOBAL_ENABLED
8404 if (ffesymbol_is_init (s))
8405 ffeglobal_init_common (ffestc_local_.common.symbol, name);
8407 if (ffesymbol_is_save (ffestc_local_.common.symbol))
8408 ffesymbol_update_save (s);
8409 if (ffesymbol_equiv (s) != NULL)
8410 { /* Is this newly COMMONed symbol involved in
8412 if (ffeequiv_common (ffesymbol_equiv (s)) == NULL)
8413 ffeequiv_set_common (ffesymbol_equiv (s), /* Yes, tell equiv obj. */
8414 ffestc_local_.common.symbol);
8415 #if FFEGLOBAL_ENABLED
8416 if (ffeequiv_is_init (ffesymbol_equiv (s)))
8417 ffeglobal_init_common (ffestc_local_.common.symbol, name);
8419 if (ffesymbol_is_save (ffestc_local_.common.symbol))
8420 ffeequiv_update_save (ffesymbol_equiv (s));
8424 ffesymbol_set_dims (s, ffestt_dimlist_as_expr (dims, &rank,
8428 ffesymbol_set_arraysize (s, array_size);
8429 ffesymbol_set_extents (s, extents);
8430 if (!(0 && ffe_is_90 ())
8431 && (ffebld_op (array_size) == FFEBLD_opCONTER)
8432 && (ffebld_constant_integerdefault (ffebld_conter (array_size))
8435 ffebad_start (FFEBAD_ZERO_ARRAY);
8436 ffebad_here (0, ffelex_token_where_line (name),
8437 ffelex_token_where_column (name));
8440 ffesymbol_set_info (s,
8441 ffeinfo_new (ffesymbol_basictype (s),
8442 ffesymbol_kindtype (s),
8445 ffesymbol_where (s),
8446 ffesymbol_size (s)));
8448 ffesymbol_signal_unreported (s);
8451 if (ffestc_parent_ok_)
8453 e = ffebld_new_symter (s, FFEINTRIN_genNONE, FFEINTRIN_specNONE,
8456 ffeinfo_new (FFEINFO_basictypeNONE,
8457 FFEINFO_kindtypeNONE,
8461 FFETARGET_charactersizeNONE));
8463 (ffesymbol_ptr_to_listbottom (ffestc_local_.common.symbol), e);
8466 ffestd_R547_item_object (name, dims);
8469 /* ffestc_R547_item_cblock -- COMMON statement for common-block-name
8471 ffestc_R547_item_cblock(name_token);
8473 Make sure name_token identifies a valid common block to be COMMONd. */
8476 ffestc_R547_item_cblock (ffelexToken name)
8482 ffestc_check_item_ ();
8486 if (ffestc_local_.common.symbol != NULL)
8487 ffesymbol_signal_unreported (ffestc_local_.common.symbol);
8489 s = ffesymbol_declare_cblock (name,
8490 ffelex_token_where_line (ffesta_tokens[0]),
8491 ffelex_token_where_column (ffesta_tokens[0]));
8492 sa = ffesymbol_attrs (s);
8494 /* Figure out what kind of object we've got based on previous declarations
8495 of or references to the object. */
8497 if (!ffesymbol_is_specable (s))
8498 na = FFESYMBOL_attrsetNONE;
8499 else if (sa & FFESYMBOL_attrsANY)
8500 na = FFESYMBOL_attrsANY; /* Already have an error here, say nothing. */
8501 else if (!(sa & ~(FFESYMBOL_attrsCBLOCK
8502 | FFESYMBOL_attrsSAVECBLOCK)))
8504 if (!(sa & FFESYMBOL_attrsCBLOCK))
8505 ffebld_init_list (ffesymbol_ptr_to_commonlist (s),
8506 ffesymbol_ptr_to_listbottom (s));
8507 na = sa | FFESYMBOL_attrsCBLOCK;
8510 na = FFESYMBOL_attrsetNONE;
8512 /* Now see what we've got for a new object: NONE means a new error cropped
8513 up; ANY means an old error to be ignored; otherwise, everything's ok,
8514 update the object (symbol) and continue on. */
8516 if (na == FFESYMBOL_attrsetNONE)
8518 ffesymbol_error (s, name == NULL ? ffesta_tokens[0] : name);
8519 ffestc_parent_ok_ = FALSE;
8521 else if (na & FFESYMBOL_attrsANY)
8522 ffestc_parent_ok_ = FALSE;
8525 ffesymbol_set_attrs (s, na);
8526 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
8528 ffesymbol_update_save (s);
8529 ffestc_parent_ok_ = TRUE;
8532 ffestc_local_.common.symbol = s;
8534 ffestd_R547_item_cblock (name);
8537 /* ffestc_R547_finish -- COMMON statement list complete
8539 ffestc_R547_finish();
8541 Just wrap up any local activities. */
8544 ffestc_R547_finish ()
8546 ffestc_check_finish_ ();
8550 if (ffestc_local_.common.symbol != NULL)
8551 ffesymbol_signal_unreported (ffestc_local_.common.symbol);
8553 ffestd_R547_finish ();
8556 /* ffestc_R620 -- ALLOCATE statement
8558 ffestc_R620(exprlist,stat,stat_token);
8560 Make sure the expression list is valid, then implement it. */
8564 ffestc_R620 (ffesttExprList exprlist, ffebld stat, ffelexToken stat_token)
8566 ffestc_check_simple_ ();
8567 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
8569 ffestc_labeldef_branch_begin_ ();
8571 ffestd_R620 (exprlist, stat);
8573 if (ffestc_shriek_after1_ != NULL)
8574 (*ffestc_shriek_after1_) (TRUE);
8575 ffestc_labeldef_branch_end_ ();
8578 /* ffestc_R624 -- NULLIFY statement
8580 ffestc_R624(pointer_name_list);
8582 Make sure pointer_name_list identifies valid pointers for a NULLIFY. */
8585 ffestc_R624 (ffesttExprList pointers)
8587 ffestc_check_simple_ ();
8588 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
8590 ffestc_labeldef_branch_begin_ ();
8592 ffestd_R624 (pointers);
8594 if (ffestc_shriek_after1_ != NULL)
8595 (*ffestc_shriek_after1_) (TRUE);
8596 ffestc_labeldef_branch_end_ ();
8599 /* ffestc_R625 -- DEALLOCATE statement
8601 ffestc_R625(exprlist,stat,stat_token);
8603 Make sure the equivalence is valid, then implement it. */
8606 ffestc_R625 (ffesttExprList exprlist, ffebld stat, ffelexToken stat_token)
8608 ffestc_check_simple_ ();
8609 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
8611 ffestc_labeldef_branch_begin_ ();
8613 ffestd_R625 (exprlist, stat);
8615 if (ffestc_shriek_after1_ != NULL)
8616 (*ffestc_shriek_after1_) (TRUE);
8617 ffestc_labeldef_branch_end_ ();
8621 /* ffestc_let -- R1213 or R737
8625 Verify that R1213 defined-assignment or R737 assignment-stmt are
8626 valid here, figure out which one, and implement. */
8630 ffestc_let (ffebld dest, ffebld source, ffelexToken source_token)
8632 ffestc_R737 (dest, source, source_token);
8636 /* ffestc_R737 -- Assignment statement
8638 ffestc_R737(dest_expr,source_expr,source_token);
8640 Make sure the assignment is valid. */
8643 ffestc_R737 (ffebld dest, ffebld source, ffelexToken source_token)
8645 ffestc_check_simple_ ();
8647 switch (ffestw_state (ffestw_stack_top ()))
8650 case FFESTV_stateWHERE:
8651 case FFESTV_stateWHERETHEN:
8652 if (ffestc_order_actionwhere_ () != FFESTC_orderOK_)
8654 ffestc_labeldef_useless_ ();
8656 ffestd_R737B (dest, source);
8658 if (ffestc_shriek_after1_ != NULL)
8659 (*ffestc_shriek_after1_) (TRUE);
8667 if (ffestc_order_actionwhere_ () != FFESTC_orderOK_)
8669 ffestc_labeldef_branch_begin_ ();
8671 source = ffeexpr_convert_expr (source, source_token, dest, ffesta_tokens[0],
8672 FFEEXPR_contextLET);
8674 ffestd_R737A (dest, source);
8676 if (ffestc_shriek_after1_ != NULL)
8677 (*ffestc_shriek_after1_) (TRUE);
8678 ffestc_labeldef_branch_end_ ();
8681 /* ffestc_R738 -- Pointer assignment statement
8683 ffestc_R738(dest_expr,source_expr,source_token);
8685 Make sure the assignment is valid. */
8689 ffestc_R738 (ffebld dest, ffebld source, ffelexToken source_token)
8691 ffestc_check_simple_ ();
8692 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
8694 ffestc_labeldef_branch_begin_ ();
8696 ffestd_R738 (dest, source);
8698 if (ffestc_shriek_after1_ != NULL)
8699 (*ffestc_shriek_after1_) (TRUE);
8700 ffestc_labeldef_branch_end_ ();
8703 /* ffestc_R740 -- WHERE statement
8705 ffestc_R740(expr,expr_token);
8707 Make sure statement is valid here; implement. */
8710 ffestc_R740 (ffebld expr, ffelexToken expr_token)
8714 ffestc_check_simple_ ();
8715 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
8717 ffestc_labeldef_branch_begin_ ();
8719 b = ffestw_update (ffestw_push (NULL));
8720 ffestw_set_top_do (b, ffestw_top_do (ffestw_previous (b)));
8721 ffestw_set_state (b, FFESTV_stateWHERE);
8722 ffestw_set_blocknum (b, ffestc_blocknum_++);
8723 ffestw_set_shriek (b, ffestc_shriek_where_lost_);
8727 /* Leave label finishing to next statement. */
8731 /* ffestc_R742 -- WHERE-construct statement
8733 ffestc_R742(expr,expr_token);
8735 Make sure statement is valid here; implement. */
8738 ffestc_R742 (ffebld expr, ffelexToken expr_token)
8742 ffestc_check_simple_ ();
8743 if (ffestc_order_exec_ () != FFESTC_orderOK_)
8745 ffestc_labeldef_notloop_probably_this_wont_work_ ();
8747 b = ffestw_update (ffestw_push (NULL));
8748 ffestw_set_top_do (b, ffestw_top_do (ffestw_previous (b)));
8749 ffestw_set_state (b, FFESTV_stateWHERETHEN);
8750 ffestw_set_blocknum (b, ffestc_blocknum_++);
8751 ffestw_set_shriek (b, ffestc_shriek_wherethen_);
8752 ffestw_set_substate (b, 0); /* Haven't seen ELSEWHERE yet. */
8757 /* ffestc_R744 -- ELSE WHERE statement
8761 Make sure ffestc_kind_ identifies a WHERE block.
8762 Implement the ELSE of the current WHERE block. */
8767 ffestc_check_simple_ ();
8768 if (ffestc_order_where_ () != FFESTC_orderOK_)
8770 ffestc_labeldef_useless_ ();
8772 if (ffestw_substate (ffestw_stack_top ()) != 0)
8774 ffebad_start (FFEBAD_SECOND_ELSE_WHERE);
8775 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
8776 ffelex_token_where_column (ffesta_tokens[0]));
8777 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
8781 ffestw_set_substate (ffestw_stack_top (), 1); /* Saw ELSEWHERE. */
8786 /* ffestc_R745 -- END WHERE statement
8790 Make sure ffestc_kind_ identifies a WHERE block.
8791 Implement the end of the current WHERE block. */
8796 ffestc_check_simple_ ();
8797 if (ffestc_order_where_ () != FFESTC_orderOK_)
8799 ffestc_labeldef_useless_ ();
8801 ffestc_shriek_wherethen_ (TRUE);
8805 /* ffestc_R803 -- Block IF (IF-THEN) statement
8807 ffestc_R803(construct_name,expr,expr_token);
8809 Make sure statement is valid here; implement. */
8812 ffestc_R803 (ffelexToken construct_name, ffebld expr,
8813 ffelexToken expr_token UNUSED)
8818 ffestc_check_simple_ ();
8819 if (ffestc_order_exec_ () != FFESTC_orderOK_)
8821 ffestc_labeldef_notloop_ ();
8823 b = ffestw_update (ffestw_push (NULL));
8824 ffestw_set_top_do (b, ffestw_top_do (ffestw_previous (b)));
8825 ffestw_set_state (b, FFESTV_stateIFTHEN);
8826 ffestw_set_blocknum (b, ffestc_blocknum_++);
8827 ffestw_set_shriek (b, ffestc_shriek_ifthen_);
8828 ffestw_set_substate (b, 0); /* Haven't seen ELSE yet. */
8830 if (construct_name == NULL)
8831 ffestw_set_name (b, NULL);
8834 ffestw_set_name (b, ffelex_token_use (construct_name));
8836 s = ffesymbol_declare_local (construct_name, FALSE);
8838 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
8840 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
8841 ffesymbol_set_info (s,
8842 ffeinfo_new (FFEINFO_basictypeNONE,
8843 FFEINFO_kindtypeNONE,
8845 FFEINFO_kindCONSTRUCT,
8847 FFETARGET_charactersizeNONE));
8848 s = ffecom_sym_learned (s);
8849 ffesymbol_signal_unreported (s);
8852 ffesymbol_error (s, construct_name);
8855 ffestd_R803 (construct_name, expr);
8858 /* ffestc_R804 -- ELSE IF statement
8860 ffestc_R804(expr,expr_token,name_token);
8862 Make sure ffestc_kind_ identifies an IF block. If not
8863 NULL, make sure name_token gives the correct name. Implement the else
8867 ffestc_R804 (ffebld expr, ffelexToken expr_token UNUSED,
8870 ffestc_check_simple_ ();
8871 if (ffestc_order_ifthen_ () != FFESTC_orderOK_)
8873 ffestc_labeldef_useless_ ();
8877 if (ffestw_name (ffestw_stack_top ()) == NULL)
8879 ffebad_start (FFEBAD_CONSTRUCT_NOT_NAMED);
8880 ffebad_here (0, ffelex_token_where_line (name),
8881 ffelex_token_where_column (name));
8882 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
8885 else if (ffelex_token_strcmp (name,
8886 ffestw_name (ffestw_stack_top ()))
8889 ffebad_start (FFEBAD_CONSTRUCT_WRONG_NAME);
8890 ffebad_here (0, ffelex_token_where_line (name),
8891 ffelex_token_where_column (name));
8892 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
8893 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
8898 if (ffestw_substate (ffestw_stack_top ()) != 0)
8900 ffebad_start (FFEBAD_AFTER_ELSE);
8901 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
8902 ffelex_token_where_column (ffesta_tokens[0]));
8903 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
8905 return; /* Don't upset back end with ELSEIF
8909 ffestd_R804 (expr, name);
8912 /* ffestc_R805 -- ELSE statement
8914 ffestc_R805(name_token);
8916 Make sure ffestc_kind_ identifies an IF block. If not
8917 NULL, make sure name_token gives the correct name. Implement the ELSE
8921 ffestc_R805 (ffelexToken name)
8923 ffestc_check_simple_ ();
8924 if (ffestc_order_ifthen_ () != FFESTC_orderOK_)
8926 ffestc_labeldef_useless_ ();
8930 if (ffestw_name (ffestw_stack_top ()) == NULL)
8932 ffebad_start (FFEBAD_CONSTRUCT_NOT_NAMED);
8933 ffebad_here (0, ffelex_token_where_line (name),
8934 ffelex_token_where_column (name));
8935 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
8938 else if (ffelex_token_strcmp (name, ffestw_name (ffestw_stack_top ())) != 0)
8940 ffebad_start (FFEBAD_CONSTRUCT_WRONG_NAME);
8941 ffebad_here (0, ffelex_token_where_line (name),
8942 ffelex_token_where_column (name));
8943 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
8944 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
8949 if (ffestw_substate (ffestw_stack_top ()) != 0)
8951 ffebad_start (FFEBAD_AFTER_ELSE);
8952 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
8953 ffelex_token_where_column (ffesta_tokens[0]));
8954 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
8956 return; /* Tell back end about only one ELSE. */
8959 ffestw_set_substate (ffestw_stack_top (), 1); /* Saw ELSE. */
8964 /* ffestc_R806 -- END IF statement
8966 ffestc_R806(name_token);
8968 Make sure ffestc_kind_ identifies an IF block. If not
8969 NULL, make sure name_token gives the correct name. Implement the end
8973 ffestc_R806 (ffelexToken name)
8975 ffestc_check_simple_ ();
8976 if (ffestc_order_ifthen_ () != FFESTC_orderOK_)
8978 ffestc_labeldef_endif_ ();
8982 if (ffestw_name (ffestw_stack_top ()) != NULL)
8984 ffebad_start (FFEBAD_CONSTRUCT_NAMED);
8985 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
8986 ffelex_token_where_column (ffesta_tokens[0]));
8987 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
8993 if (ffestw_name (ffestw_stack_top ()) == NULL)
8995 ffebad_start (FFEBAD_CONSTRUCT_NOT_NAMED);
8996 ffebad_here (0, ffelex_token_where_line (name),
8997 ffelex_token_where_column (name));
8998 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
9001 else if (ffelex_token_strcmp (name, ffestw_name (ffestw_stack_top ())) != 0)
9003 ffebad_start (FFEBAD_CONSTRUCT_WRONG_NAME);
9004 ffebad_here (0, ffelex_token_where_line (name),
9005 ffelex_token_where_column (name));
9006 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
9007 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
9012 ffestc_shriek_ifthen_ (TRUE);
9015 /* ffestc_R807 -- Logical IF statement
9017 ffestc_R807(expr,expr_token);
9019 Make sure statement is valid here; implement. */
9022 ffestc_R807 (ffebld expr, ffelexToken expr_token UNUSED)
9026 ffestc_check_simple_ ();
9027 if (ffestc_order_action_ () != FFESTC_orderOK_)
9029 ffestc_labeldef_branch_begin_ ();
9031 b = ffestw_update (ffestw_push (NULL));
9032 ffestw_set_top_do (b, ffestw_top_do (ffestw_previous (b)));
9033 ffestw_set_state (b, FFESTV_stateIF);
9034 ffestw_set_blocknum (b, ffestc_blocknum_++);
9035 ffestw_set_shriek (b, ffestc_shriek_if_lost_);
9039 /* Do the label finishing in the next statement. */
9043 /* ffestc_R809 -- SELECT CASE statement
9045 ffestc_R809(construct_name,expr,expr_token);
9047 Make sure statement is valid here; implement. */
9050 ffestc_R809 (ffelexToken construct_name, ffebld expr, ffelexToken expr_token)
9057 ffestc_check_simple_ ();
9058 if (ffestc_order_exec_ () != FFESTC_orderOK_)
9060 ffestc_labeldef_notloop_ ();
9062 b = ffestw_update (ffestw_push (NULL));
9063 ffestw_set_top_do (b, ffestw_top_do (ffestw_previous (b)));
9064 ffestw_set_state (b, FFESTV_stateSELECT0);
9065 ffestw_set_blocknum (b, ffestc_blocknum_++);
9066 ffestw_set_shriek (b, ffestc_shriek_select_);
9067 ffestw_set_substate (b, 0); /* Haven't seen CASE DEFAULT yet. */
9069 /* Init block to manage CASE list. */
9071 pool = malloc_pool_new ("Select", ffe_pool_any_unit (), 1024);
9072 s = (ffestwSelect) malloc_new_kp (pool, "Select", sizeof (*s));
9073 s->first_rel = (ffestwCase) &s->first_rel;
9074 s->last_rel = (ffestwCase) &s->first_rel;
9075 s->first_stmt = (ffestwCase) &s->first_rel;
9076 s->last_stmt = (ffestwCase) &s->first_rel;
9079 s->t = ffelex_token_use (expr_token);
9080 s->type = ffeinfo_basictype (ffebld_info (expr));
9081 s->kindtype = ffeinfo_kindtype (ffebld_info (expr));
9082 ffestw_set_select (b, s);
9084 if (construct_name == NULL)
9085 ffestw_set_name (b, NULL);
9088 ffestw_set_name (b, ffelex_token_use (construct_name));
9090 sym = ffesymbol_declare_local (construct_name, FALSE);
9092 if (ffesymbol_state (sym) == FFESYMBOL_stateNONE)
9094 ffesymbol_set_state (sym, FFESYMBOL_stateUNDERSTOOD);
9095 ffesymbol_set_info (sym,
9096 ffeinfo_new (FFEINFO_basictypeNONE,
9097 FFEINFO_kindtypeNONE, 0,
9098 FFEINFO_kindCONSTRUCT,
9100 FFETARGET_charactersizeNONE));
9101 sym = ffecom_sym_learned (sym);
9102 ffesymbol_signal_unreported (sym);
9105 ffesymbol_error (sym, construct_name);
9108 ffestd_R809 (construct_name, expr);
9111 /* ffestc_R810 -- CASE statement
9113 ffestc_R810(case_value_range_list,name);
9115 If case_value_range_list is NULL, it's CASE DEFAULT. name is the case-
9116 construct-name. Make sure no more than one CASE DEFAULT is present for
9117 a given case-construct and that there aren't any overlapping ranges or
9118 duplicate case values. */
9121 ffestc_R810 (ffesttCaseList cases, ffelexToken name)
9123 ffesttCaseList caseobj;
9126 ffebldConstant expr1c, expr2c;
9128 ffestc_check_simple_ ();
9129 if (ffestc_order_selectcase_ () != FFESTC_orderOK_)
9131 ffestc_labeldef_useless_ ();
9133 s = ffestw_select (ffestw_stack_top ());
9135 if (ffestw_state (ffestw_stack_top ()) == FFESTV_stateSELECT0)
9137 #if 0 /* Not sure we want to have msgs point here
9138 instead of SELECT CASE. */
9139 ffestw_update (NULL); /* Update state line/col info. */
9141 ffestw_set_state (ffestw_stack_top (), FFESTV_stateSELECT1);
9146 if (ffestw_name (ffestw_stack_top ()) == NULL)
9148 ffebad_start (FFEBAD_CONSTRUCT_NOT_NAMED);
9149 ffebad_here (0, ffelex_token_where_line (name),
9150 ffelex_token_where_column (name));
9151 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
9154 else if (ffelex_token_strcmp (name,
9155 ffestw_name (ffestw_stack_top ()))
9158 ffebad_start (FFEBAD_CONSTRUCT_WRONG_NAME);
9159 ffebad_here (0, ffelex_token_where_line (name),
9160 ffelex_token_where_column (name));
9161 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
9162 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
9169 if (ffestw_substate (ffestw_stack_top ()) != 0)
9171 ffebad_start (FFEBAD_CASE_SECOND_DEFAULT);
9172 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
9173 ffelex_token_where_column (ffesta_tokens[0]));
9174 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
9178 ffestw_set_substate (ffestw_stack_top (), 1); /* Saw ELSE. */
9181 { /* For each case, try to fit into sorted list
9183 for (caseobj = cases->next; caseobj != cases; caseobj = caseobj->next)
9185 if ((caseobj->expr1 == NULL)
9187 || (caseobj->expr2 == NULL)))
9189 ffebad_start (FFEBAD_CASE_BAD_RANGE);
9190 ffebad_here (0, ffelex_token_where_line (caseobj->t),
9191 ffelex_token_where_column (caseobj->t));
9196 if (((caseobj->expr1 != NULL)
9197 && ((ffeinfo_basictype (ffebld_info (caseobj->expr1))
9199 || (ffeinfo_kindtype (ffebld_info (caseobj->expr1))
9201 || ((caseobj->range)
9202 && (caseobj->expr2 != NULL)
9203 && ((ffeinfo_basictype (ffebld_info (caseobj->expr2))
9205 || (ffeinfo_kindtype (ffebld_info (caseobj->expr2))
9208 ffebad_start (FFEBAD_CASE_TYPE_DISAGREE);
9209 ffebad_here (0, ffelex_token_where_line (caseobj->t),
9210 ffelex_token_where_column (caseobj->t));
9211 ffebad_here (1, ffelex_token_where_line (s->t),
9212 ffelex_token_where_column (s->t));
9217 if ((s->type == FFEINFO_basictypeLOGICAL) && (caseobj->range))
9219 ffebad_start (FFEBAD_CASE_LOGICAL_RANGE);
9220 ffebad_here (0, ffelex_token_where_line (caseobj->t),
9221 ffelex_token_where_column (caseobj->t));
9226 if (caseobj->expr1 == NULL)
9228 else if (ffebld_op (caseobj->expr1) != FFEBLD_opCONTER)
9229 continue; /* opANY. */
9231 expr1c = ffebld_conter (caseobj->expr1);
9233 if (!caseobj->range)
9234 expr2c = expr1c; /* expr1c and expr2c are NOT NULL in this
9236 else if (caseobj->expr2 == NULL)
9238 else if (ffebld_op (caseobj->expr2) != FFEBLD_opCONTER)
9239 continue; /* opANY. */
9241 expr2c = ffebld_conter (caseobj->expr2);
9244 { /* "CASE (:high)", must be first in list. */
9246 if ((c != (ffestwCase) &s->first_rel)
9247 && ((c->low == NULL)
9248 || (ffebld_constant_cmp (expr2c, c->low) >= 0)))
9249 { /* Other "CASE (:high)" or lowest "CASE
9250 (low[:high])" low. */
9251 ffebad_start (FFEBAD_CASE_DUPLICATE);
9252 ffebad_here (0, ffelex_token_where_line (caseobj->t),
9253 ffelex_token_where_column (caseobj->t));
9254 ffebad_here (1, ffelex_token_where_line (c->t),
9255 ffelex_token_where_column (c->t));
9260 else if (expr2c == NULL)
9261 { /* "CASE (low:)", must be last in list. */
9263 if ((c != (ffestwCase) &s->first_rel)
9264 && ((c->high == NULL)
9265 || (ffebld_constant_cmp (expr1c, c->high) <= 0)))
9266 { /* Other "CASE (low:)" or lowest "CASE
9267 ([low:]high)" high. */
9268 ffebad_start (FFEBAD_CASE_DUPLICATE);
9269 ffebad_here (0, ffelex_token_where_line (caseobj->t),
9270 ffelex_token_where_column (caseobj->t));
9271 ffebad_here (1, ffelex_token_where_line (c->t),
9272 ffelex_token_where_column (c->t));
9276 c = c->next_rel; /* Same as c = (ffestwCase) &s->first;. */
9279 { /* (expr1c != NULL) && (expr2c != NULL). */
9280 if (ffebld_constant_cmp (expr1c, expr2c) > 0)
9281 { /* Such as "CASE (3:1)" or "CASE ('B':'A')". */
9282 ffebad_start (FFEBAD_CASE_RANGE_USELESS); /* Warn/inform only. */
9283 ffebad_here (0, ffelex_token_where_line (caseobj->t),
9284 ffelex_token_where_column (caseobj->t));
9288 for (c = s->first_rel;
9289 (c != (ffestwCase) &s->first_rel)
9290 && ((c->low == NULL)
9291 || (ffebld_constant_cmp (expr1c, c->low) > 0));
9294 nc = c; /* Which one to report? */
9295 if (((c != (ffestwCase) &s->first_rel)
9296 && (ffebld_constant_cmp (expr2c, c->low) >= 0))
9297 || (((nc = c->previous_rel) != (ffestwCase) &s->first_rel)
9298 && (ffebld_constant_cmp (expr1c, nc->high) <= 0)))
9299 { /* Interference with range in case nc. */
9300 ffebad_start (FFEBAD_CASE_DUPLICATE);
9301 ffebad_here (0, ffelex_token_where_line (caseobj->t),
9302 ffelex_token_where_column (caseobj->t));
9303 ffebad_here (1, ffelex_token_where_line (nc->t),
9304 ffelex_token_where_column (nc->t));
9310 /* If we reach here for this case range/value, it's ok (sorts into
9311 the list of ranges/values) so we give it its own case object
9312 sorted into the list of case statements. */
9314 nc = malloc_new_kp (s->pool, "Case range", sizeof (*nc));
9316 nc->previous_rel = c->previous_rel;
9317 nc->next_stmt = (ffestwCase) &s->first_rel;
9318 nc->previous_stmt = s->last_stmt;
9321 nc->casenum = s->cases;
9322 nc->t = ffelex_token_use (caseobj->t);
9323 nc->next_rel->previous_rel = nc;
9324 nc->previous_rel->next_rel = nc;
9325 nc->next_stmt->previous_stmt = nc;
9326 nc->previous_stmt->next_stmt = nc;
9330 ffestd_R810 ((cases == NULL) ? 0 : s->cases);
9332 s->cases++; /* Increment # of cases. */
9335 /* ffestc_R811 -- END SELECT statement
9337 ffestc_R811(name_token);
9339 Make sure ffestc_kind_ identifies a SELECT block. If not
9340 NULL, make sure name_token gives the correct name. Implement the end
9341 of the SELECT block. */
9344 ffestc_R811 (ffelexToken name)
9346 ffestc_check_simple_ ();
9347 if (ffestc_order_selectcase_ () != FFESTC_orderOK_)
9349 ffestc_labeldef_notloop_ ();
9353 if (ffestw_name (ffestw_stack_top ()) != NULL)
9355 ffebad_start (FFEBAD_CONSTRUCT_NAMED);
9356 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
9357 ffelex_token_where_column (ffesta_tokens[0]));
9358 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
9364 if (ffestw_name (ffestw_stack_top ()) == NULL)
9366 ffebad_start (FFEBAD_CONSTRUCT_NOT_NAMED);
9367 ffebad_here (0, ffelex_token_where_line (name),
9368 ffelex_token_where_column (name));
9369 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
9372 else if (ffelex_token_strcmp (name,
9373 ffestw_name (ffestw_stack_top ()))
9376 ffebad_start (FFEBAD_CONSTRUCT_WRONG_NAME);
9377 ffebad_here (0, ffelex_token_where_line (name),
9378 ffelex_token_where_column (name));
9379 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
9380 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
9385 ffestc_shriek_select_ (TRUE);
9388 /* ffestc_R819A -- Iterative labeled DO statement
9390 ffestc_R819A(construct_name,label_token,expr,expr_token);
9392 Make sure statement is valid here; implement. */
9395 ffestc_R819A (ffelexToken construct_name, ffelexToken label_token, ffebld var,
9396 ffelexToken var_token, ffebld start, ffelexToken start_token, ffebld end,
9397 ffelexToken end_token, ffebld incr, ffelexToken incr_token)
9404 ffestc_check_simple_ ();
9405 if (ffestc_order_exec_ () != FFESTC_orderOK_)
9407 ffestc_labeldef_notloop_ ();
9409 if (!ffestc_labelref_is_loopend_ (label_token, &label))
9412 b = ffestw_update (ffestw_push (NULL));
9413 ffestw_set_top_do (b, b);
9414 ffestw_set_state (b, FFESTV_stateDO);
9415 ffestw_set_blocknum (b, ffestc_blocknum_++);
9416 ffestw_set_shriek (b, ffestc_shriek_do_);
9417 ffestw_set_label (b, label);
9418 switch (ffebld_op (var))
9420 case FFEBLD_opSYMTER:
9421 if ((ffeinfo_basictype (ffebld_info (var)) == FFEINFO_basictypeREAL)
9422 && ffe_is_warn_surprising ())
9424 ffebad_start (FFEBAD_DO_REAL); /* See error message!!! */
9425 ffebad_here (0, ffelex_token_where_line (var_token),
9426 ffelex_token_where_column (var_token));
9427 ffebad_string (ffesymbol_text (ffebld_symter (var)));
9430 if (!ffesymbol_is_doiter (varsym = ffebld_symter (var)))
9431 { /* Presumably already complained about by
9433 ffesymbol_set_is_doiter (varsym, TRUE);
9434 ffestw_set_do_iter_var (b, varsym);
9435 ffestw_set_do_iter_var_t (b, ffelex_token_use (var_token));
9440 ffestw_set_do_iter_var (b, NULL);
9441 ffestw_set_do_iter_var_t (b, NULL);
9445 assert ("bad iter var" == NULL);
9449 if (construct_name == NULL)
9450 ffestw_set_name (b, NULL);
9453 ffestw_set_name (b, ffelex_token_use (construct_name));
9455 s = ffesymbol_declare_local (construct_name, FALSE);
9457 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
9459 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
9460 ffesymbol_set_info (s,
9461 ffeinfo_new (FFEINFO_basictypeNONE,
9462 FFEINFO_kindtypeNONE,
9464 FFEINFO_kindCONSTRUCT,
9466 FFETARGET_charactersizeNONE));
9467 s = ffecom_sym_learned (s);
9468 ffesymbol_signal_unreported (s);
9471 ffesymbol_error (s, construct_name);
9476 incr = ffebld_new_conter (ffebld_constant_new_integerdefault_val (1));
9477 ffebld_set_info (incr, ffeinfo_new
9478 (FFEINFO_basictypeINTEGER,
9479 FFEINFO_kindtypeINTEGERDEFAULT,
9482 FFEINFO_whereCONSTANT,
9483 FFETARGET_charactersizeNONE));
9486 start = ffeexpr_convert_expr (start, start_token, var, var_token,
9487 FFEEXPR_contextLET);
9488 end = ffeexpr_convert_expr (end, end_token, var, var_token,
9489 FFEEXPR_contextLET);
9490 incr = ffeexpr_convert_expr (incr, incr_token, var, var_token,
9491 FFEEXPR_contextLET);
9493 ffestd_R819A (construct_name, label, var,
9499 /* ffestc_R819B -- Labeled DO WHILE statement
9501 ffestc_R819B(construct_name,label_token,expr,expr_token);
9503 Make sure statement is valid here; implement. */
9506 ffestc_R819B (ffelexToken construct_name, ffelexToken label_token,
9507 ffebld expr, ffelexToken expr_token UNUSED)
9513 ffestc_check_simple_ ();
9514 if (ffestc_order_exec_ () != FFESTC_orderOK_)
9516 ffestc_labeldef_notloop_ ();
9518 if (!ffestc_labelref_is_loopend_ (label_token, &label))
9521 b = ffestw_update (ffestw_push (NULL));
9522 ffestw_set_top_do (b, b);
9523 ffestw_set_state (b, FFESTV_stateDO);
9524 ffestw_set_blocknum (b, ffestc_blocknum_++);
9525 ffestw_set_shriek (b, ffestc_shriek_do_);
9526 ffestw_set_label (b, label);
9527 ffestw_set_do_iter_var (b, NULL);
9528 ffestw_set_do_iter_var_t (b, NULL);
9530 if (construct_name == NULL)
9531 ffestw_set_name (b, NULL);
9534 ffestw_set_name (b, ffelex_token_use (construct_name));
9536 s = ffesymbol_declare_local (construct_name, FALSE);
9538 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
9540 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
9541 ffesymbol_set_info (s,
9542 ffeinfo_new (FFEINFO_basictypeNONE,
9543 FFEINFO_kindtypeNONE,
9545 FFEINFO_kindCONSTRUCT,
9547 FFETARGET_charactersizeNONE));
9548 s = ffecom_sym_learned (s);
9549 ffesymbol_signal_unreported (s);
9552 ffesymbol_error (s, construct_name);
9555 ffestd_R819B (construct_name, label, expr);
9558 /* ffestc_R820A -- Iterative nonlabeled DO statement
9560 ffestc_R820A(construct_name,expr,expr_token);
9562 Make sure statement is valid here; implement. */
9565 ffestc_R820A (ffelexToken construct_name, ffebld var, ffelexToken var_token,
9566 ffebld start, ffelexToken start_token, ffebld end, ffelexToken end_token,
9567 ffebld incr, ffelexToken incr_token)
9573 ffestc_check_simple_ ();
9574 if (ffestc_order_exec_ () != FFESTC_orderOK_)
9576 ffestc_labeldef_notloop_ ();
9578 b = ffestw_update (ffestw_push (NULL));
9579 ffestw_set_top_do (b, b);
9580 ffestw_set_state (b, FFESTV_stateDO);
9581 ffestw_set_blocknum (b, ffestc_blocknum_++);
9582 ffestw_set_shriek (b, ffestc_shriek_do_);
9583 ffestw_set_label (b, NULL);
9584 switch (ffebld_op (var))
9586 case FFEBLD_opSYMTER:
9587 if ((ffeinfo_basictype (ffebld_info (var)) == FFEINFO_basictypeREAL)
9588 && ffe_is_warn_surprising ())
9590 ffebad_start (FFEBAD_DO_REAL); /* See error message!!! */
9591 ffebad_here (0, ffelex_token_where_line (var_token),
9592 ffelex_token_where_column (var_token));
9593 ffebad_string (ffesymbol_text (ffebld_symter (var)));
9596 if (!ffesymbol_is_doiter (varsym = ffebld_symter (var)))
9597 { /* Presumably already complained about by
9599 ffesymbol_set_is_doiter (varsym, TRUE);
9600 ffestw_set_do_iter_var (b, varsym);
9601 ffestw_set_do_iter_var_t (b, ffelex_token_use (var_token));
9606 ffestw_set_do_iter_var (b, NULL);
9607 ffestw_set_do_iter_var_t (b, NULL);
9611 assert ("bad iter var" == NULL);
9615 if (construct_name == NULL)
9616 ffestw_set_name (b, NULL);
9619 ffestw_set_name (b, ffelex_token_use (construct_name));
9621 s = ffesymbol_declare_local (construct_name, FALSE);
9623 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
9625 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
9626 ffesymbol_set_info (s,
9627 ffeinfo_new (FFEINFO_basictypeNONE,
9628 FFEINFO_kindtypeNONE,
9630 FFEINFO_kindCONSTRUCT,
9632 FFETARGET_charactersizeNONE));
9633 s = ffecom_sym_learned (s);
9634 ffesymbol_signal_unreported (s);
9637 ffesymbol_error (s, construct_name);
9642 incr = ffebld_new_conter (ffebld_constant_new_integerdefault_val (1));
9643 ffebld_set_info (incr, ffeinfo_new
9644 (FFEINFO_basictypeINTEGER,
9645 FFEINFO_kindtypeINTEGERDEFAULT,
9648 FFEINFO_whereCONSTANT,
9649 FFETARGET_charactersizeNONE));
9652 start = ffeexpr_convert_expr (start, start_token, var, var_token,
9653 FFEEXPR_contextLET);
9654 end = ffeexpr_convert_expr (end, end_token, var, var_token,
9655 FFEEXPR_contextLET);
9656 incr = ffeexpr_convert_expr (incr, incr_token, var, var_token,
9657 FFEEXPR_contextLET);
9660 if ((ffebld_op (incr) == FFEBLD_opCONTER)
9661 && (ffebld_constant_is_zero (ffebld_conter (incr))))
9663 ffebad_start (FFEBAD_DO_STEP_ZERO);
9664 ffebad_here (0, ffelex_token_where_line (incr_token),
9665 ffelex_token_where_column (incr_token));
9666 ffebad_string ("Iterative DO loop");
9671 ffestd_R819A (construct_name, NULL, var,
9677 /* ffestc_R820B -- Nonlabeled DO WHILE statement
9679 ffestc_R820B(construct_name,expr,expr_token);
9681 Make sure statement is valid here; implement. */
9684 ffestc_R820B (ffelexToken construct_name, ffebld expr,
9685 ffelexToken expr_token UNUSED)
9690 ffestc_check_simple_ ();
9691 if (ffestc_order_exec_ () != FFESTC_orderOK_)
9693 ffestc_labeldef_notloop_ ();
9695 b = ffestw_update (ffestw_push (NULL));
9696 ffestw_set_top_do (b, b);
9697 ffestw_set_state (b, FFESTV_stateDO);
9698 ffestw_set_blocknum (b, ffestc_blocknum_++);
9699 ffestw_set_shriek (b, ffestc_shriek_do_);
9700 ffestw_set_label (b, NULL);
9701 ffestw_set_do_iter_var (b, NULL);
9702 ffestw_set_do_iter_var_t (b, NULL);
9704 if (construct_name == NULL)
9705 ffestw_set_name (b, NULL);
9708 ffestw_set_name (b, ffelex_token_use (construct_name));
9710 s = ffesymbol_declare_local (construct_name, FALSE);
9712 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
9714 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
9715 ffesymbol_set_info (s,
9716 ffeinfo_new (FFEINFO_basictypeNONE,
9717 FFEINFO_kindtypeNONE,
9719 FFEINFO_kindCONSTRUCT,
9721 FFETARGET_charactersizeNONE));
9722 s = ffecom_sym_learned (s);
9723 ffesymbol_signal_unreported (s);
9726 ffesymbol_error (s, construct_name);
9729 ffestd_R819B (construct_name, NULL, expr);
9732 /* ffestc_R825 -- END DO statement
9734 ffestc_R825(name_token);
9736 Make sure ffestc_kind_ identifies a DO block. If not
9737 NULL, make sure name_token gives the correct name. Implement the end
9741 ffestc_R825 (ffelexToken name)
9743 ffestc_check_simple_ ();
9744 if (ffestc_order_do_ () != FFESTC_orderOK_)
9746 ffestc_labeldef_branch_begin_ ();
9750 if (ffestw_name (ffestw_stack_top ()) != NULL)
9752 ffebad_start (FFEBAD_CONSTRUCT_NAMED);
9753 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
9754 ffelex_token_where_column (ffesta_tokens[0]));
9755 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
9761 if (ffestw_name (ffestw_stack_top ()) == NULL)
9763 ffebad_start (FFEBAD_CONSTRUCT_NOT_NAMED);
9764 ffebad_here (0, ffelex_token_where_line (name),
9765 ffelex_token_where_column (name));
9766 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
9769 else if (ffelex_token_strcmp (name,
9770 ffestw_name (ffestw_stack_top ()))
9773 ffebad_start (FFEBAD_CONSTRUCT_WRONG_NAME);
9774 ffebad_here (0, ffelex_token_where_line (name),
9775 ffelex_token_where_column (name));
9776 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
9777 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
9782 if (ffesta_label_token == NULL)
9783 { /* If top of stack has label, its an error! */
9784 if (ffestw_label (ffestw_stack_top ()) != NULL)
9786 ffebad_start (FFEBAD_DO_HAD_LABEL);
9787 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
9788 ffelex_token_where_column (ffesta_tokens[0]));
9789 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
9793 ffestc_shriek_do_ (TRUE);
9795 ffestc_try_shriek_do_ ();
9802 ffestc_labeldef_branch_end_ ();
9805 /* ffestc_R834 -- CYCLE statement
9807 ffestc_R834(name_token);
9809 Handle a CYCLE within a loop. */
9812 ffestc_R834 (ffelexToken name)
9816 ffestc_check_simple_ ();
9817 if (ffestc_order_actiondo_ () != FFESTC_orderOK_)
9819 ffestc_labeldef_notloop_begin_ ();
9822 block = ffestw_top_do (ffestw_stack_top ());
9824 { /* Search for name. */
9825 for (block = ffestw_top_do (ffestw_stack_top ());
9826 (block != NULL) && (ffestw_blocknum (block) != 0);
9827 block = ffestw_top_do (ffestw_previous (block)))
9829 if ((ffestw_name (block) != NULL)
9830 && (ffelex_token_strcmp (name, ffestw_name (block)) == 0))
9833 if ((block == NULL) || (ffestw_blocknum (block) == 0))
9835 block = ffestw_top_do (ffestw_stack_top ());
9836 ffebad_start (FFEBAD_CONSTRUCT_NO_DO_NAME);
9837 ffebad_here (0, ffelex_token_where_line (name),
9838 ffelex_token_where_column (name));
9843 ffestd_R834 (block);
9845 if (ffestc_shriek_after1_ != NULL)
9846 (*ffestc_shriek_after1_) (TRUE);
9848 /* notloop's that are actionif's can be the target of a loop-end
9849 statement if they're in the "then" part of a logical IF, as
9850 in "DO 10", "10 IF (...) CYCLE". */
9852 ffestc_labeldef_branch_end_ ();
9855 /* ffestc_R835 -- EXIT statement
9857 ffestc_R835(name_token);
9859 Handle a EXIT within a loop. */
9862 ffestc_R835 (ffelexToken name)
9866 ffestc_check_simple_ ();
9867 if (ffestc_order_actiondo_ () != FFESTC_orderOK_)
9869 ffestc_labeldef_notloop_begin_ ();
9872 block = ffestw_top_do (ffestw_stack_top ());
9874 { /* Search for name. */
9875 for (block = ffestw_top_do (ffestw_stack_top ());
9876 (block != NULL) && (ffestw_blocknum (block) != 0);
9877 block = ffestw_top_do (ffestw_previous (block)))
9879 if ((ffestw_name (block) != NULL)
9880 && (ffelex_token_strcmp (name, ffestw_name (block)) == 0))
9883 if ((block == NULL) || (ffestw_blocknum (block) == 0))
9885 block = ffestw_top_do (ffestw_stack_top ());
9886 ffebad_start (FFEBAD_CONSTRUCT_NO_DO_NAME);
9887 ffebad_here (0, ffelex_token_where_line (name),
9888 ffelex_token_where_column (name));
9893 ffestd_R835 (block);
9895 if (ffestc_shriek_after1_ != NULL)
9896 (*ffestc_shriek_after1_) (TRUE);
9898 /* notloop's that are actionif's can be the target of a loop-end
9899 statement if they're in the "then" part of a logical IF, as
9900 in "DO 10", "10 IF (...) EXIT". */
9902 ffestc_labeldef_branch_end_ ();
9905 /* ffestc_R836 -- GOTO statement
9907 ffestc_R836(label_token);
9909 Make sure label_token identifies a valid label for a GOTO. Update
9910 that label's info to indicate it is the target of a GOTO. */
9913 ffestc_R836 (ffelexToken label_token)
9917 ffestc_check_simple_ ();
9918 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
9920 ffestc_labeldef_notloop_begin_ ();
9922 if (ffestc_labelref_is_branch_ (label_token, &label))
9923 ffestd_R836 (label);
9925 if (ffestc_shriek_after1_ != NULL)
9926 (*ffestc_shriek_after1_) (TRUE);
9928 /* notloop's that are actionif's can be the target of a loop-end
9929 statement if they're in the "then" part of a logical IF, as
9930 in "DO 10", "10 IF (...) GOTO 100". */
9932 ffestc_labeldef_branch_end_ ();
9935 /* ffestc_R837 -- Computed GOTO statement
9937 ffestc_R837(label_list,expr,expr_token);
9939 Make sure label_list identifies valid labels for a GOTO. Update
9940 each label's info to indicate it is the target of a GOTO. */
9943 ffestc_R837 (ffesttTokenList label_toks, ffebld expr,
9944 ffelexToken expr_token UNUSED)
9951 assert (label_toks != NULL);
9953 ffestc_check_simple_ ();
9954 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
9956 ffestc_labeldef_branch_begin_ ();
9958 labels = malloc_new_kp (ffesta_output_pool, "FFESTC labels",
9960 * ffestt_tokenlist_count (label_toks));
9962 for (ti = label_toks->first, i = 0;
9963 ti != (ffesttTokenItem) &label_toks->first;
9966 if (!ffestc_labelref_is_branch_ (ti->t, &labels[i]))
9974 ffestd_R837 (labels, ffestt_tokenlist_count (label_toks), expr);
9976 if (ffestc_shriek_after1_ != NULL)
9977 (*ffestc_shriek_after1_) (TRUE);
9978 ffestc_labeldef_branch_end_ ();
9981 /* ffestc_R838 -- ASSIGN statement
9983 ffestc_R838(label_token,target_variable,target_token);
9985 Make sure label_token identifies a valid label for an assignment. Update
9986 that label's info to indicate it is the source of an assignment. Update
9987 target_variable's info to indicate it is the target the assignment of that
9991 ffestc_R838 (ffelexToken label_token, ffebld target,
9992 ffelexToken target_token UNUSED)
9996 ffestc_check_simple_ ();
9997 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
9999 ffestc_labeldef_branch_begin_ ();
10001 if (ffestc_labelref_is_assignable_ (label_token, &label))
10002 ffestd_R838 (label, target);
10004 if (ffestc_shriek_after1_ != NULL)
10005 (*ffestc_shriek_after1_) (TRUE);
10006 ffestc_labeldef_branch_end_ ();
10009 /* ffestc_R839 -- Assigned GOTO statement
10011 ffestc_R839(target,target_token,label_list);
10013 Make sure label_list identifies valid labels for a GOTO. Update
10014 each label's info to indicate it is the target of a GOTO. */
10017 ffestc_R839 (ffebld target, ffelexToken target_token UNUSED,
10018 ffesttTokenList label_toks)
10020 ffesttTokenItem ti;
10025 ffestc_check_simple_ ();
10026 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
10028 ffestc_labeldef_notloop_begin_ ();
10030 if (label_toks == NULL)
10037 labels = malloc_new_kp (ffesta_output_pool, "FFESTC labels",
10038 sizeof (*labels) * ffestt_tokenlist_count (label_toks));
10040 for (ti = label_toks->first, i = 0;
10041 ti != (ffesttTokenItem) &label_toks->first;
10042 ti = ti->next, ++i)
10044 if (!ffestc_labelref_is_branch_ (ti->t, &labels[i]))
10053 ffestd_R839 (target, labels, i);
10055 if (ffestc_shriek_after1_ != NULL)
10056 (*ffestc_shriek_after1_) (TRUE);
10058 /* notloop's that are actionif's can be the target of a loop-end
10059 statement if they're in the "then" part of a logical IF, as
10060 in "DO 10", "10 IF (...) GOTO I". */
10062 ffestc_labeldef_branch_end_ ();
10065 /* ffestc_R840 -- Arithmetic IF statement
10067 ffestc_R840(expr,expr_token,neg,zero,pos);
10069 Make sure the labels are valid; implement. */
10072 ffestc_R840 (ffebld expr, ffelexToken expr_token UNUSED,
10073 ffelexToken neg_token, ffelexToken zero_token,
10074 ffelexToken pos_token)
10080 ffestc_check_simple_ ();
10081 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
10083 ffestc_labeldef_notloop_begin_ ();
10085 if (ffestc_labelref_is_branch_ (neg_token, &neg)
10086 && ffestc_labelref_is_branch_ (zero_token, &zero)
10087 && ffestc_labelref_is_branch_ (pos_token, &pos))
10088 ffestd_R840 (expr, neg, zero, pos);
10090 if (ffestc_shriek_after1_ != NULL)
10091 (*ffestc_shriek_after1_) (TRUE);
10093 /* notloop's that are actionif's can be the target of a loop-end
10094 statement if they're in the "then" part of a logical IF, as
10095 in "DO 10", "10 IF (...) GOTO (100,200,300), I". */
10097 ffestc_labeldef_branch_end_ ();
10100 /* ffestc_R841 -- CONTINUE statement
10107 ffestc_check_simple_ ();
10109 if (ffestc_order_actionwhere_ () != FFESTC_orderOK_)
10112 switch (ffestw_state (ffestw_stack_top ()))
10115 case FFESTV_stateWHERE:
10116 case FFESTV_stateWHERETHEN:
10117 ffestc_labeldef_useless_ ();
10119 ffestd_R841 (TRUE);
10121 /* It's okay that we call ffestc_labeldef_branch_end_ () below,
10122 since that will be a no-op after calling _useless_ () above. */
10127 ffestc_labeldef_branch_begin_ ();
10129 ffestd_R841 (FALSE);
10134 if (ffestc_shriek_after1_ != NULL)
10135 (*ffestc_shriek_after1_) (TRUE);
10136 ffestc_labeldef_branch_end_ ();
10139 /* ffestc_R842 -- STOP statement
10141 ffestc_R842(expr,expr_token);
10143 Make sure statement is valid here; implement. expr and expr_token are
10144 both NULL if there was no expression. */
10147 ffestc_R842 (ffebld expr, ffelexToken expr_token UNUSED)
10149 ffestc_check_simple_ ();
10150 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
10152 ffestc_labeldef_notloop_begin_ ();
10154 ffestd_R842 (expr);
10156 if (ffestc_shriek_after1_ != NULL)
10157 (*ffestc_shriek_after1_) (TRUE);
10159 /* notloop's that are actionif's can be the target of a loop-end
10160 statement if they're in the "then" part of a logical IF, as
10161 in "DO 10", "10 IF (...) STOP". */
10163 ffestc_labeldef_branch_end_ ();
10166 /* ffestc_R843 -- PAUSE statement
10168 ffestc_R843(expr,expr_token);
10170 Make sure statement is valid here; implement. expr and expr_token are
10171 both NULL if there was no expression. */
10174 ffestc_R843 (ffebld expr, ffelexToken expr_token UNUSED)
10176 ffestc_check_simple_ ();
10177 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
10179 ffestc_labeldef_branch_begin_ ();
10181 ffestd_R843 (expr);
10183 if (ffestc_shriek_after1_ != NULL)
10184 (*ffestc_shriek_after1_) (TRUE);
10185 ffestc_labeldef_branch_end_ ();
10188 /* ffestc_R904 -- OPEN statement
10192 Make sure an OPEN is valid in the current context, and implement it. */
10199 char *status_strs[]
10208 char *access_strs[]
10222 char *carriagecontrol_strs[]
10229 char *dispose_strs[]
10246 char *organization_strs[]
10253 char *position_strs[]
10260 char *action_strs[]
10274 char *recordtype_strs[]
10291 ffestc_check_simple_ ();
10292 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
10294 ffestc_labeldef_branch_begin_ ();
10296 if (ffestc_subr_is_branch_
10297 (&ffestp_file.open.open_spec[FFESTP_openixERR])
10298 && ffestc_subr_is_present_ ("UNIT",
10299 &ffestp_file.open.open_spec[FFESTP_openixUNIT]))
10301 i = ffestc_subr_binsrch_ (status_strs,
10302 ARRAY_SIZE (status_strs),
10303 &ffestp_file.open.open_spec[FFESTP_openixSTATUS],
10304 "NEW, OLD, REPLACE, SCRATCH, or UNKNOWN");
10307 case 0: /* Unknown. */
10308 case 5: /* UNKNOWN. */
10309 expect_file = 2; /* Unknown, don't care about FILE=. */
10314 if (ffe_is_pedantic ())
10315 expect_file = 1; /* Yes, need FILE=. */
10317 expect_file = 2; /* f2clib doesn't care about FILE=. */
10320 case 3: /* REPLACE. */
10321 expect_file = 1; /* Yes, need FILE=. */
10324 case 4: /* SCRATCH. */
10325 expect_file = 0; /* No, disallow FILE=. */
10329 assert ("invalid _binsrch_ result" == NULL);
10333 if ((expect_file == 0)
10334 && ffestp_file.open.open_spec[FFESTP_openixFILE].kw_or_val_present)
10336 ffebad_start (FFEBAD_CONFLICTING_SPECS);
10337 assert (ffestp_file.open.open_spec[FFESTP_openixFILE].kw_or_val_present);
10338 if (ffestp_file.open.open_spec[FFESTP_openixFILE].kw_present)
10340 ffebad_here (0, ffelex_token_where_line
10341 (ffestp_file.open.open_spec[FFESTP_openixFILE].kw),
10342 ffelex_token_where_column
10343 (ffestp_file.open.open_spec[FFESTP_openixFILE].kw));
10347 ffebad_here (0, ffelex_token_where_line
10348 (ffestp_file.open.open_spec[FFESTP_openixFILE].value),
10349 ffelex_token_where_column
10350 (ffestp_file.open.open_spec[FFESTP_openixFILE].value));
10352 assert (ffestp_file.open.open_spec[FFESTP_openixSTATUS].kw_or_val_present);
10353 if (ffestp_file.open.open_spec[FFESTP_openixSTATUS].kw_present)
10355 ffebad_here (1, ffelex_token_where_line
10356 (ffestp_file.open.open_spec[FFESTP_openixSTATUS].kw),
10357 ffelex_token_where_column
10358 (ffestp_file.open.open_spec[FFESTP_openixSTATUS].kw));
10362 ffebad_here (1, ffelex_token_where_line
10363 (ffestp_file.open.open_spec[FFESTP_openixSTATUS].value),
10364 ffelex_token_where_column
10365 (ffestp_file.open.open_spec[FFESTP_openixSTATUS].value));
10369 else if ((expect_file == 1)
10370 && !ffestp_file.open.open_spec[FFESTP_openixFILE].kw_or_val_present)
10372 ffebad_start (FFEBAD_MISSING_SPECIFIER);
10373 assert (ffestp_file.open.open_spec[FFESTP_openixSTATUS].kw_or_val_present);
10374 if (ffestp_file.open.open_spec[FFESTP_openixSTATUS].kw_present)
10376 ffebad_here (0, ffelex_token_where_line
10377 (ffestp_file.open.open_spec[FFESTP_openixSTATUS].kw),
10378 ffelex_token_where_column
10379 (ffestp_file.open.open_spec[FFESTP_openixSTATUS].kw));
10383 ffebad_here (0, ffelex_token_where_line
10384 (ffestp_file.open.open_spec[FFESTP_openixSTATUS].value),
10385 ffelex_token_where_column
10386 (ffestp_file.open.open_spec[FFESTP_openixSTATUS].value));
10388 ffebad_string ("FILE=");
10392 ffestc_subr_binsrch_ (access_strs, ARRAY_SIZE (access_strs),
10393 &ffestp_file.open.open_spec[FFESTP_openixACCESS],
10394 "APPEND, DIRECT, KEYED, or SEQUENTIAL");
10396 ffestc_subr_binsrch_ (blank_strs, ARRAY_SIZE (blank_strs),
10397 &ffestp_file.open.open_spec[FFESTP_openixBLANK],
10400 ffestc_subr_binsrch_ (carriagecontrol_strs,
10401 ARRAY_SIZE (carriagecontrol_strs),
10402 &ffestp_file.open.open_spec[FFESTP_openixCARRIAGECONTROL],
10403 "FORTRAN, LIST, or NONE");
10405 ffestc_subr_binsrch_ (dispose_strs, ARRAY_SIZE (dispose_strs),
10406 &ffestp_file.open.open_spec[FFESTP_openixDISPOSE],
10407 "DELETE, KEEP, PRINT, PRINT/DELETE, SAVE, SUBMIT, or SUBMIT/DELETE");
10409 ffestc_subr_binsrch_ (form_strs, ARRAY_SIZE (form_strs),
10410 &ffestp_file.open.open_spec[FFESTP_openixFORM],
10411 "FORMATTED or UNFORMATTED");
10413 ffestc_subr_binsrch_ (organization_strs, ARRAY_SIZE (organization_strs),
10414 &ffestp_file.open.open_spec[FFESTP_openixORGANIZATION],
10415 "INDEXED, RELATIVE, or SEQUENTIAL");
10417 ffestc_subr_binsrch_ (position_strs, ARRAY_SIZE (position_strs),
10418 &ffestp_file.open.open_spec[FFESTP_openixPOSITION],
10419 "APPEND, ASIS, or REWIND");
10421 ffestc_subr_binsrch_ (action_strs, ARRAY_SIZE (action_strs),
10422 &ffestp_file.open.open_spec[FFESTP_openixACTION],
10423 "READ, READWRITE, or WRITE");
10425 ffestc_subr_binsrch_ (delim_strs, ARRAY_SIZE (delim_strs),
10426 &ffestp_file.open.open_spec[FFESTP_openixDELIM],
10427 "APOSTROPHE, NONE, or QUOTE");
10429 ffestc_subr_binsrch_ (recordtype_strs, ARRAY_SIZE (recordtype_strs),
10430 &ffestp_file.open.open_spec[FFESTP_openixRECORDTYPE],
10431 "FIXED, SEGMENTED, STREAM, STREAM_CR, STREAM_LF, or VARIABLE");
10433 ffestc_subr_binsrch_ (pad_strs, ARRAY_SIZE (pad_strs),
10434 &ffestp_file.open.open_spec[FFESTP_openixPAD],
10440 if (ffestc_shriek_after1_ != NULL)
10441 (*ffestc_shriek_after1_) (TRUE);
10442 ffestc_labeldef_branch_end_ ();
10445 /* ffestc_R907 -- CLOSE statement
10449 Make sure a CLOSE is valid in the current context, and implement it. */
10454 char *status_strs[]
10466 ffestc_check_simple_ ();
10467 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
10469 ffestc_labeldef_branch_begin_ ();
10471 if (ffestc_subr_is_branch_
10472 (&ffestp_file.close.close_spec[FFESTP_closeixERR])
10473 && ffestc_subr_is_present_ ("UNIT",
10474 &ffestp_file.close.close_spec[FFESTP_closeixUNIT]))
10476 ffestc_subr_binsrch_ (status_strs, ARRAY_SIZE (status_strs),
10477 &ffestp_file.close.close_spec[FFESTP_closeixSTATUS],
10478 "DELETE, KEEP, PRINT, PRINT/DELETE, SAVE, SUBMIT, or SUBMIT/DELETE");
10483 if (ffestc_shriek_after1_ != NULL)
10484 (*ffestc_shriek_after1_) (TRUE);
10485 ffestc_labeldef_branch_end_ ();
10488 /* ffestc_R909_start -- READ(...) statement list begin
10490 ffestc_R909_start(FALSE);
10492 Verify that READ is valid here, and begin accepting items in the
10496 ffestc_R909_start (bool only_format)
10499 ffestvFormat format;
10503 ffestpReadIx spec1;
10504 ffestpReadIx spec2;
10506 ffestc_check_start_ ();
10507 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
10509 ffestc_ok_ = FALSE;
10512 ffestc_labeldef_branch_begin_ ();
10514 if (!ffestc_subr_is_format_
10515 (&ffestp_file.read.read_spec[FFESTP_readixFORMAT]))
10517 ffestc_ok_ = FALSE;
10521 format = ffestc_subr_format_
10522 (&ffestp_file.read.read_spec[FFESTP_readixFORMAT]);
10523 ffestc_namelist_ = (format == FFESTV_formatNAMELIST);
10527 ffestd_R909_start (TRUE, FFESTV_unitNONE, format, FALSE, FALSE);
10533 if (!ffestc_subr_is_branch_
10534 (&ffestp_file.read.read_spec[FFESTP_readixEOR])
10535 || !ffestc_subr_is_branch_
10536 (&ffestp_file.read.read_spec[FFESTP_readixERR])
10537 || !ffestc_subr_is_branch_
10538 (&ffestp_file.read.read_spec[FFESTP_readixEND]))
10540 ffestc_ok_ = FALSE;
10544 unit = ffestc_subr_unit_
10545 (&ffestp_file.read.read_spec[FFESTP_readixUNIT]);
10546 if (unit == FFESTV_unitNONE)
10548 ffebad_start (FFEBAD_NO_UNIT_SPEC);
10549 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
10550 ffelex_token_where_column (ffesta_tokens[0]));
10552 ffestc_ok_ = FALSE;
10556 rec = ffestp_file.read.read_spec[FFESTP_readixREC].kw_or_val_present;
10558 if (ffestp_file.read.read_spec[FFESTP_readixKEYEQ].kw_or_val_present)
10561 keyn = spec1 = FFESTP_readixKEYEQ;
10566 keyn = spec1 = FFESTP_readix;
10569 if (ffestp_file.read.read_spec[FFESTP_readixKEYGT].kw_or_val_present)
10573 spec2 = FFESTP_readixKEYGT;
10574 whine: /* :::::::::::::::::::: */
10575 ffebad_start (FFEBAD_CONFLICTING_SPECS);
10576 assert (ffestp_file.read.read_spec[spec1].kw_or_val_present);
10577 if (ffestp_file.read.read_spec[spec1].kw_present)
10579 ffebad_here (0, ffelex_token_where_line
10580 (ffestp_file.read.read_spec[spec1].kw),
10581 ffelex_token_where_column
10582 (ffestp_file.read.read_spec[spec1].kw));
10586 ffebad_here (0, ffelex_token_where_line
10587 (ffestp_file.read.read_spec[spec1].value),
10588 ffelex_token_where_column
10589 (ffestp_file.read.read_spec[spec1].value));
10591 assert (ffestp_file.read.read_spec[spec2].kw_or_val_present);
10592 if (ffestp_file.read.read_spec[spec2].kw_present)
10594 ffebad_here (1, ffelex_token_where_line
10595 (ffestp_file.read.read_spec[spec2].kw),
10596 ffelex_token_where_column
10597 (ffestp_file.read.read_spec[spec2].kw));
10601 ffebad_here (1, ffelex_token_where_line
10602 (ffestp_file.read.read_spec[spec2].value),
10603 ffelex_token_where_column
10604 (ffestp_file.read.read_spec[spec2].value));
10607 ffestc_ok_ = FALSE;
10611 keyn = spec1 = FFESTP_readixKEYGT;
10614 if (ffestp_file.read.read_spec[FFESTP_readixKEYGE].kw_or_val_present)
10618 spec2 = FFESTP_readixKEYGT;
10619 goto whine; /* :::::::::::::::::::: */
10622 keyn = FFESTP_readixKEYGT;
10627 spec1 = FFESTP_readixREC;
10631 goto whine; /* :::::::::::::::::::: */
10633 if (unit == FFESTV_unitCHAREXPR)
10635 spec2 = FFESTP_readixUNIT;
10636 goto whine; /* :::::::::::::::::::: */
10638 if ((format == FFESTV_formatASTERISK)
10639 || (format == FFESTV_formatNAMELIST))
10641 spec2 = FFESTP_readixFORMAT;
10642 goto whine; /* :::::::::::::::::::: */
10644 if (ffestp_file.read.read_spec[FFESTP_readixADVANCE].kw_or_val_present)
10646 spec2 = FFESTP_readixADVANCE;
10647 goto whine; /* :::::::::::::::::::: */
10649 if (ffestp_file.read.read_spec[FFESTP_readixEND].kw_or_val_present)
10651 spec2 = FFESTP_readixEND;
10652 goto whine; /* :::::::::::::::::::: */
10654 if (ffestp_file.read.read_spec[FFESTP_readixNULLS].kw_or_val_present)
10656 spec2 = FFESTP_readixNULLS;
10657 goto whine; /* :::::::::::::::::::: */
10663 if (unit == FFESTV_unitCHAREXPR)
10665 spec2 = FFESTP_readixUNIT;
10666 goto whine; /* :::::::::::::::::::: */
10668 if ((format == FFESTV_formatASTERISK)
10669 || (format == FFESTV_formatNAMELIST))
10671 spec2 = FFESTP_readixFORMAT;
10672 goto whine; /* :::::::::::::::::::: */
10674 if (ffestp_file.read.read_spec[FFESTP_readixADVANCE].kw_or_val_present)
10676 spec2 = FFESTP_readixADVANCE;
10677 goto whine; /* :::::::::::::::::::: */
10679 if (ffestp_file.read.read_spec[FFESTP_readixEND].kw_or_val_present)
10681 spec2 = FFESTP_readixEND;
10682 goto whine; /* :::::::::::::::::::: */
10684 if (ffestp_file.read.read_spec[FFESTP_readixEOR].kw_or_val_present)
10686 spec2 = FFESTP_readixEOR;
10687 goto whine; /* :::::::::::::::::::: */
10689 if (ffestp_file.read.read_spec[FFESTP_readixNULLS].kw_or_val_present)
10691 spec2 = FFESTP_readixNULLS;
10692 goto whine; /* :::::::::::::::::::: */
10694 if (ffestp_file.read.read_spec[FFESTP_readixREC].kw_or_val_present)
10696 spec2 = FFESTP_readixREC;
10697 goto whine; /* :::::::::::::::::::: */
10699 if (ffestp_file.read.read_spec[FFESTP_readixSIZE].kw_or_val_present)
10701 spec2 = FFESTP_readixSIZE;
10702 goto whine; /* :::::::::::::::::::: */
10706 { /* Sequential/Internal. */
10707 if (unit == FFESTV_unitCHAREXPR)
10708 { /* Internal file. */
10709 spec1 = FFESTP_readixUNIT;
10710 if (format == FFESTV_formatNAMELIST)
10712 spec2 = FFESTP_readixFORMAT;
10713 goto whine; /* :::::::::::::::::::: */
10715 if (ffestp_file.read.read_spec[FFESTP_readixADVANCE].kw_or_val_present)
10717 spec2 = FFESTP_readixADVANCE;
10718 goto whine; /* :::::::::::::::::::: */
10721 if (ffestp_file.read.read_spec[FFESTP_readixADVANCE].kw_or_val_present)
10722 { /* ADVANCE= specified. */
10723 spec1 = FFESTP_readixADVANCE;
10724 if (format == FFESTV_formatNONE)
10726 ffebad_start (FFEBAD_MISSING_FORMAT_SPEC);
10727 ffebad_here (0, ffelex_token_where_line
10728 (ffestp_file.read.read_spec[spec1].kw),
10729 ffelex_token_where_column
10730 (ffestp_file.read.read_spec[spec1].kw));
10733 ffestc_ok_ = FALSE;
10736 if (format == FFESTV_formatNAMELIST)
10738 spec2 = FFESTP_readixFORMAT;
10739 goto whine; /* :::::::::::::::::::: */
10742 if (ffestp_file.read.read_spec[FFESTP_readixEOR].kw_or_val_present)
10743 { /* EOR= specified. */
10744 spec1 = FFESTP_readixEOR;
10745 if (ffestc_subr_speccmp_ ("No",
10746 &ffestp_file.read.read_spec[FFESTP_readixADVANCE],
10749 goto whine_advance; /* :::::::::::::::::::: */
10752 if (ffestp_file.read.read_spec[FFESTP_readixNULLS].kw_or_val_present)
10753 { /* NULLS= specified. */
10754 spec1 = FFESTP_readixNULLS;
10755 if (format != FFESTV_formatASTERISK)
10757 spec2 = FFESTP_readixFORMAT;
10758 goto whine; /* :::::::::::::::::::: */
10761 if (ffestp_file.read.read_spec[FFESTP_readixSIZE].kw_or_val_present)
10762 { /* SIZE= specified. */
10763 spec1 = FFESTP_readixSIZE;
10764 if (ffestc_subr_speccmp_ ("No",
10765 &ffestp_file.read.read_spec[FFESTP_readixADVANCE],
10768 whine_advance: /* :::::::::::::::::::: */
10769 if (ffestp_file.read.read_spec[FFESTP_readixADVANCE]
10770 .kw_or_val_present)
10772 ffebad_start (FFEBAD_CONFLICTING_SPECS);
10773 ffebad_here (0, ffelex_token_where_line
10774 (ffestp_file.read.read_spec[spec1].kw),
10775 ffelex_token_where_column
10776 (ffestp_file.read.read_spec[spec1].kw));
10777 ffebad_here (1, ffelex_token_where_line
10778 (ffestp_file.read.read_spec[FFESTP_readixADVANCE].kw),
10779 ffelex_token_where_column
10780 (ffestp_file.read.read_spec[FFESTP_readixADVANCE].kw));
10785 ffebad_start (FFEBAD_MISSING_ADVANCE_SPEC);
10786 ffebad_here (0, ffelex_token_where_line
10787 (ffestp_file.read.read_spec[spec1].kw),
10788 ffelex_token_where_column
10789 (ffestp_file.read.read_spec[spec1].kw));
10793 ffestc_ok_ = FALSE;
10799 if (unit == FFESTV_unitCHAREXPR)
10800 ffestc_iolist_context_ = FFEEXPR_contextIOLISTDF;
10802 ffestc_iolist_context_ = FFEEXPR_contextIOLIST;
10804 ffestd_R909_start (FALSE, unit, format, rec, key);
10809 /* ffestc_R909_item -- READ statement i/o item
10811 ffestc_R909_item(expr,expr_token);
10813 Implement output-list expression. */
10816 ffestc_R909_item (ffebld expr, ffelexToken expr_token)
10818 ffestc_check_item_ ();
10822 if (ffestc_namelist_ != 0)
10824 if (ffestc_namelist_ == 1)
10826 ffestc_namelist_ = 2;
10827 ffebad_start (FFEBAD_NAMELIST_ITEMS);
10828 ffebad_here (0, ffelex_token_where_line (expr_token),
10829 ffelex_token_where_column (expr_token));
10835 ffestd_R909_item (expr, expr_token);
10838 /* ffestc_R909_finish -- READ statement list complete
10840 ffestc_R909_finish();
10842 Just wrap up any local activities. */
10845 ffestc_R909_finish ()
10847 ffestc_check_finish_ ();
10851 ffestd_R909_finish ();
10853 if (ffestc_shriek_after1_ != NULL)
10854 (*ffestc_shriek_after1_) (TRUE);
10855 ffestc_labeldef_branch_end_ ();
10858 /* ffestc_R910_start -- WRITE(...) statement list begin
10860 ffestc_R910_start();
10862 Verify that WRITE is valid here, and begin accepting items in the
10866 ffestc_R910_start ()
10869 ffestvFormat format;
10871 ffestpWriteIx spec1;
10872 ffestpWriteIx spec2;
10874 ffestc_check_start_ ();
10875 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
10877 ffestc_ok_ = FALSE;
10880 ffestc_labeldef_branch_begin_ ();
10882 if (!ffestc_subr_is_branch_
10883 (&ffestp_file.write.write_spec[FFESTP_writeixEOR])
10884 || !ffestc_subr_is_branch_
10885 (&ffestp_file.write.write_spec[FFESTP_writeixERR])
10886 || !ffestc_subr_is_format_
10887 (&ffestp_file.write.write_spec[FFESTP_writeixFORMAT]))
10889 ffestc_ok_ = FALSE;
10893 format = ffestc_subr_format_
10894 (&ffestp_file.write.write_spec[FFESTP_writeixFORMAT]);
10895 ffestc_namelist_ = (format == FFESTV_formatNAMELIST);
10897 unit = ffestc_subr_unit_
10898 (&ffestp_file.write.write_spec[FFESTP_writeixUNIT]);
10899 if (unit == FFESTV_unitNONE)
10901 ffebad_start (FFEBAD_NO_UNIT_SPEC);
10902 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
10903 ffelex_token_where_column (ffesta_tokens[0]));
10905 ffestc_ok_ = FALSE;
10909 rec = ffestp_file.write.write_spec[FFESTP_writeixREC].kw_or_val_present;
10913 spec1 = FFESTP_writeixREC;
10914 if (unit == FFESTV_unitCHAREXPR)
10916 spec2 = FFESTP_writeixUNIT;
10917 whine: /* :::::::::::::::::::: */
10918 ffebad_start (FFEBAD_CONFLICTING_SPECS);
10919 assert (ffestp_file.write.write_spec[spec1].kw_or_val_present);
10920 if (ffestp_file.write.write_spec[spec1].kw_present)
10922 ffebad_here (0, ffelex_token_where_line
10923 (ffestp_file.write.write_spec[spec1].kw),
10924 ffelex_token_where_column
10925 (ffestp_file.write.write_spec[spec1].kw));
10929 ffebad_here (0, ffelex_token_where_line
10930 (ffestp_file.write.write_spec[spec1].value),
10931 ffelex_token_where_column
10932 (ffestp_file.write.write_spec[spec1].value));
10934 assert (ffestp_file.write.write_spec[spec2].kw_or_val_present);
10935 if (ffestp_file.write.write_spec[spec2].kw_present)
10937 ffebad_here (1, ffelex_token_where_line
10938 (ffestp_file.write.write_spec[spec2].kw),
10939 ffelex_token_where_column
10940 (ffestp_file.write.write_spec[spec2].kw));
10944 ffebad_here (1, ffelex_token_where_line
10945 (ffestp_file.write.write_spec[spec2].value),
10946 ffelex_token_where_column
10947 (ffestp_file.write.write_spec[spec2].value));
10950 ffestc_ok_ = FALSE;
10953 if ((format == FFESTV_formatASTERISK)
10954 || (format == FFESTV_formatNAMELIST))
10956 spec2 = FFESTP_writeixFORMAT;
10957 goto whine; /* :::::::::::::::::::: */
10959 if (ffestp_file.write.write_spec[FFESTP_writeixADVANCE].kw_or_val_present)
10961 spec2 = FFESTP_writeixADVANCE;
10962 goto whine; /* :::::::::::::::::::: */
10966 { /* Sequential/Indexed/Internal. */
10967 if (unit == FFESTV_unitCHAREXPR)
10968 { /* Internal file. */
10969 spec1 = FFESTP_writeixUNIT;
10970 if (format == FFESTV_formatNAMELIST)
10972 spec2 = FFESTP_writeixFORMAT;
10973 goto whine; /* :::::::::::::::::::: */
10975 if (ffestp_file.write.write_spec[FFESTP_writeixADVANCE].kw_or_val_present)
10977 spec2 = FFESTP_writeixADVANCE;
10978 goto whine; /* :::::::::::::::::::: */
10981 if (ffestp_file.write.write_spec[FFESTP_writeixADVANCE].kw_or_val_present)
10982 { /* ADVANCE= specified. */
10983 spec1 = FFESTP_writeixADVANCE;
10984 if (format == FFESTV_formatNONE)
10986 ffebad_start (FFEBAD_MISSING_FORMAT_SPEC);
10987 ffebad_here (0, ffelex_token_where_line
10988 (ffestp_file.write.write_spec[spec1].kw),
10989 ffelex_token_where_column
10990 (ffestp_file.write.write_spec[spec1].kw));
10993 ffestc_ok_ = FALSE;
10996 if (format == FFESTV_formatNAMELIST)
10998 spec2 = FFESTP_writeixFORMAT;
10999 goto whine; /* :::::::::::::::::::: */
11002 if (ffestp_file.write.write_spec[FFESTP_writeixEOR].kw_or_val_present)
11003 { /* EOR= specified. */
11004 spec1 = FFESTP_writeixEOR;
11005 if (ffestc_subr_speccmp_ ("No",
11006 &ffestp_file.write.write_spec[FFESTP_writeixADVANCE],
11009 if (ffestp_file.write.write_spec[FFESTP_writeixADVANCE]
11010 .kw_or_val_present)
11012 ffebad_start (FFEBAD_CONFLICTING_SPECS);
11013 ffebad_here (0, ffelex_token_where_line
11014 (ffestp_file.write.write_spec[spec1].kw),
11015 ffelex_token_where_column
11016 (ffestp_file.write.write_spec[spec1].kw));
11017 ffebad_here (1, ffelex_token_where_line
11018 (ffestp_file.write.write_spec[FFESTP_writeixADVANCE].kw),
11019 ffelex_token_where_column
11020 (ffestp_file.write.write_spec[FFESTP_writeixADVANCE].kw));
11025 ffebad_start (FFEBAD_MISSING_ADVANCE_SPEC);
11026 ffebad_here (0, ffelex_token_where_line
11027 (ffestp_file.write.write_spec[spec1].kw),
11028 ffelex_token_where_column
11029 (ffestp_file.write.write_spec[spec1].kw));
11033 ffestc_ok_ = FALSE;
11039 if (unit == FFESTV_unitCHAREXPR)
11040 ffestc_iolist_context_ = FFEEXPR_contextIOLISTDF;
11042 ffestc_iolist_context_ = FFEEXPR_contextIOLIST;
11044 ffestd_R910_start (unit, format, rec);
11049 /* ffestc_R910_item -- WRITE statement i/o item
11051 ffestc_R910_item(expr,expr_token);
11053 Implement output-list expression. */
11056 ffestc_R910_item (ffebld expr, ffelexToken expr_token)
11058 ffestc_check_item_ ();
11062 if (ffestc_namelist_ != 0)
11064 if (ffestc_namelist_ == 1)
11066 ffestc_namelist_ = 2;
11067 ffebad_start (FFEBAD_NAMELIST_ITEMS);
11068 ffebad_here (0, ffelex_token_where_line (expr_token),
11069 ffelex_token_where_column (expr_token));
11075 ffestd_R910_item (expr, expr_token);
11078 /* ffestc_R910_finish -- WRITE statement list complete
11080 ffestc_R910_finish();
11082 Just wrap up any local activities. */
11085 ffestc_R910_finish ()
11087 ffestc_check_finish_ ();
11091 ffestd_R910_finish ();
11093 if (ffestc_shriek_after1_ != NULL)
11094 (*ffestc_shriek_after1_) (TRUE);
11095 ffestc_labeldef_branch_end_ ();
11098 /* ffestc_R911_start -- PRINT(...) statement list begin
11100 ffestc_R911_start();
11102 Verify that PRINT is valid here, and begin accepting items in the
11106 ffestc_R911_start ()
11108 ffestvFormat format;
11110 ffestc_check_start_ ();
11111 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
11113 ffestc_ok_ = FALSE;
11116 ffestc_labeldef_branch_begin_ ();
11118 if (!ffestc_subr_is_format_
11119 (&ffestp_file.print.print_spec[FFESTP_printixFORMAT]))
11121 ffestc_ok_ = FALSE;
11125 format = ffestc_subr_format_
11126 (&ffestp_file.print.print_spec[FFESTP_printixFORMAT]);
11127 ffestc_namelist_ = (format == FFESTV_formatNAMELIST);
11129 ffestd_R911_start (format);
11134 /* ffestc_R911_item -- PRINT statement i/o item
11136 ffestc_R911_item(expr,expr_token);
11138 Implement output-list expression. */
11141 ffestc_R911_item (ffebld expr, ffelexToken expr_token)
11143 ffestc_check_item_ ();
11147 if (ffestc_namelist_ != 0)
11149 if (ffestc_namelist_ == 1)
11151 ffestc_namelist_ = 2;
11152 ffebad_start (FFEBAD_NAMELIST_ITEMS);
11153 ffebad_here (0, ffelex_token_where_line (expr_token),
11154 ffelex_token_where_column (expr_token));
11160 ffestd_R911_item (expr, expr_token);
11163 /* ffestc_R911_finish -- PRINT statement list complete
11165 ffestc_R911_finish();
11167 Just wrap up any local activities. */
11170 ffestc_R911_finish ()
11172 ffestc_check_finish_ ();
11176 ffestd_R911_finish ();
11178 if (ffestc_shriek_after1_ != NULL)
11179 (*ffestc_shriek_after1_) (TRUE);
11180 ffestc_labeldef_branch_end_ ();
11183 /* ffestc_R919 -- BACKSPACE statement
11187 Make sure a BACKSPACE is valid in the current context, and implement it. */
11192 ffestc_check_simple_ ();
11193 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
11195 ffestc_labeldef_branch_begin_ ();
11197 if (ffestc_subr_is_branch_
11198 (&ffestp_file.beru.beru_spec[FFESTP_beruixERR])
11199 && ffestc_subr_is_present_ ("UNIT",
11200 &ffestp_file.beru.beru_spec[FFESTP_beruixUNIT]))
11203 if (ffestc_shriek_after1_ != NULL)
11204 (*ffestc_shriek_after1_) (TRUE);
11205 ffestc_labeldef_branch_end_ ();
11208 /* ffestc_R920 -- ENDFILE statement
11212 Make sure a ENDFILE is valid in the current context, and implement it. */
11217 ffestc_check_simple_ ();
11218 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
11220 ffestc_labeldef_branch_begin_ ();
11222 if (ffestc_subr_is_branch_
11223 (&ffestp_file.beru.beru_spec[FFESTP_beruixERR])
11224 && ffestc_subr_is_present_ ("UNIT",
11225 &ffestp_file.beru.beru_spec[FFESTP_beruixUNIT]))
11228 if (ffestc_shriek_after1_ != NULL)
11229 (*ffestc_shriek_after1_) (TRUE);
11230 ffestc_labeldef_branch_end_ ();
11233 /* ffestc_R921 -- REWIND statement
11237 Make sure a REWIND is valid in the current context, and implement it. */
11242 ffestc_check_simple_ ();
11243 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
11245 ffestc_labeldef_branch_begin_ ();
11247 if (ffestc_subr_is_branch_
11248 (&ffestp_file.beru.beru_spec[FFESTP_beruixERR])
11249 && ffestc_subr_is_present_ ("UNIT",
11250 &ffestp_file.beru.beru_spec[FFESTP_beruixUNIT]))
11253 if (ffestc_shriek_after1_ != NULL)
11254 (*ffestc_shriek_after1_) (TRUE);
11255 ffestc_labeldef_branch_end_ ();
11258 /* ffestc_R923A -- INQUIRE statement (non-IOLENGTH version)
11262 Make sure an INQUIRE is valid in the current context, and implement it. */
11270 ffestc_check_simple_ ();
11271 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
11273 ffestc_labeldef_branch_begin_ ();
11275 if (ffestc_subr_is_branch_
11276 (&ffestp_file.inquire.inquire_spec[FFESTP_inquireixERR]))
11278 by_file = ffestp_file.inquire.inquire_spec[FFESTP_inquireixFILE]
11279 .kw_or_val_present;
11280 by_unit = ffestp_file.inquire.inquire_spec[FFESTP_inquireixUNIT]
11281 .kw_or_val_present;
11282 if (by_file && by_unit)
11284 ffebad_start (FFEBAD_CONFLICTING_SPECS);
11285 assert (ffestp_file.inquire.inquire_spec[FFESTP_inquireixUNIT].kw_or_val_present);
11286 if (ffestp_file.inquire.inquire_spec[FFESTP_inquireixUNIT].kw_present)
11288 ffebad_here (0, ffelex_token_where_line
11289 (ffestp_file.inquire.inquire_spec[FFESTP_inquireixUNIT].kw),
11290 ffelex_token_where_column
11291 (ffestp_file.inquire.inquire_spec[FFESTP_inquireixUNIT].kw));
11295 ffebad_here (0, ffelex_token_where_line
11296 (ffestp_file.inquire.inquire_spec[FFESTP_inquireixUNIT].value),
11297 ffelex_token_where_column
11298 (ffestp_file.inquire.inquire_spec[FFESTP_inquireixUNIT].value));
11300 assert (ffestp_file.inquire.inquire_spec[FFESTP_inquireixFILE].kw_or_val_present);
11301 if (ffestp_file.inquire.inquire_spec[FFESTP_inquireixFILE].kw_present)
11303 ffebad_here (1, ffelex_token_where_line
11304 (ffestp_file.inquire.inquire_spec[FFESTP_inquireixFILE].kw),
11305 ffelex_token_where_column
11306 (ffestp_file.inquire.inquire_spec[FFESTP_inquireixFILE].kw));
11310 ffebad_here (1, ffelex_token_where_line
11311 (ffestp_file.inquire.inquire_spec[FFESTP_inquireixFILE].value),
11312 ffelex_token_where_column
11313 (ffestp_file.inquire.inquire_spec[FFESTP_inquireixFILE].value));
11317 else if (!by_file && !by_unit)
11319 ffebad_start (FFEBAD_MISSING_SPECIFIER);
11320 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
11321 ffelex_token_where_column (ffesta_tokens[0]));
11322 ffebad_string ("UNIT= or FILE=");
11326 ffestd_R923A (by_file);
11329 if (ffestc_shriek_after1_ != NULL)
11330 (*ffestc_shriek_after1_) (TRUE);
11331 ffestc_labeldef_branch_end_ ();
11334 /* ffestc_R923B_start -- INQUIRE(IOLENGTH=expr) statement list begin
11336 ffestc_R923B_start();
11338 Verify that INQUIRE is valid here, and begin accepting items in the
11342 ffestc_R923B_start ()
11344 ffestc_check_start_ ();
11345 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
11347 ffestc_ok_ = FALSE;
11350 ffestc_labeldef_branch_begin_ ();
11352 ffestd_R923B_start ();
11357 /* ffestc_R923B_item -- INQUIRE statement i/o item
11359 ffestc_R923B_item(expr,expr_token);
11361 Implement output-list expression. */
11364 ffestc_R923B_item (ffebld expr, ffelexToken expr_token UNUSED)
11366 ffestc_check_item_ ();
11370 ffestd_R923B_item (expr);
11373 /* ffestc_R923B_finish -- INQUIRE statement list complete
11375 ffestc_R923B_finish();
11377 Just wrap up any local activities. */
11380 ffestc_R923B_finish ()
11382 ffestc_check_finish_ ();
11386 ffestd_R923B_finish ();
11388 if (ffestc_shriek_after1_ != NULL)
11389 (*ffestc_shriek_after1_) (TRUE);
11390 ffestc_labeldef_branch_end_ ();
11393 /* ffestc_R1001 -- FORMAT statement
11395 ffestc_R1001(format_list);
11397 Make sure format_list is valid. Update label's info to indicate it is a
11398 FORMAT label, and (perhaps) warn if there is no label! */
11401 ffestc_R1001 (ffesttFormatList f)
11403 ffestc_check_simple_ ();
11404 if (ffestc_order_format_ () != FFESTC_orderOK_)
11406 ffestc_labeldef_format_ ();
11411 /* ffestc_R1102 -- PROGRAM statement
11413 ffestc_R1102(name_token);
11415 Make sure ffestc_kind_ identifies an empty block. Make sure name_token
11416 gives a valid name. Implement the beginning of a main program. */
11419 ffestc_R1102 (ffelexToken name)
11424 assert (name != NULL);
11426 ffestc_check_simple_ ();
11427 if (ffestc_order_unit_ () != FFESTC_orderOK_)
11429 ffestc_labeldef_useless_ ();
11431 ffestc_blocknum_ = 0;
11432 b = ffestw_update (ffestw_push (NULL));
11433 ffestw_set_top_do (b, NULL);
11434 ffestw_set_state (b, FFESTV_statePROGRAM0);
11435 ffestw_set_blocknum (b, ffestc_blocknum_++);
11436 ffestw_set_shriek (b, ffestc_shriek_end_program_);
11438 ffestw_set_name (b, ffelex_token_use (name));
11440 s = ffesymbol_declare_programunit (name,
11441 ffelex_token_where_line (ffesta_tokens[0]),
11442 ffelex_token_where_column (ffesta_tokens[0]));
11444 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
11446 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
11447 ffesymbol_set_info (s,
11448 ffeinfo_new (FFEINFO_basictypeNONE,
11449 FFEINFO_kindtypeNONE,
11451 FFEINFO_kindPROGRAM,
11452 FFEINFO_whereLOCAL,
11453 FFETARGET_charactersizeNONE));
11454 ffesymbol_signal_unreported (s);
11457 ffesymbol_error (s, name);
11459 ffestd_R1102 (s, name);
11462 /* ffestc_R1103 -- END PROGRAM statement
11464 ffestc_R1103(name_token);
11466 Make sure ffestc_kind_ identifies the current kind of program unit. If not
11467 NULL, make sure name_token gives the correct name. Implement the end
11468 of the current program unit. */
11471 ffestc_R1103 (ffelexToken name)
11473 ffestc_check_simple_ ();
11474 if (ffestc_order_program_ () != FFESTC_orderOK_)
11476 ffestc_labeldef_notloop_ ();
11480 if (ffestw_name (ffestw_stack_top ()) == NULL)
11482 ffebad_start (FFEBAD_PROGRAM_NOT_NAMED);
11483 ffebad_here (0, ffelex_token_where_line (name),
11484 ffelex_token_where_column (name));
11485 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
11488 else if (ffelex_token_strcmp (name, ffestw_name (ffestw_stack_top ())) != 0)
11490 ffebad_start (FFEBAD_UNIT_WRONG_NAME);
11491 ffebad_here (0, ffelex_token_where_line (name),
11492 ffelex_token_where_column (name));
11493 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
11494 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
11499 ffestc_shriek_end_program_ (TRUE);
11502 /* ffestc_R1105 -- MODULE statement
11504 ffestc_R1105(name_token);
11506 Make sure ffestc_kind_ identifies an empty block. Make sure name_token
11507 gives a valid name. Implement the beginning of a module. */
11511 ffestc_R1105 (ffelexToken name)
11515 assert (name != NULL);
11517 ffestc_check_simple_ ();
11518 if (ffestc_order_unit_ () != FFESTC_orderOK_)
11520 ffestc_labeldef_useless_ ();
11522 ffestc_blocknum_ = 0;
11523 b = ffestw_update (ffestw_push (NULL));
11524 ffestw_set_top_do (b, NULL);
11525 ffestw_set_state (b, FFESTV_stateMODULE0);
11526 ffestw_set_blocknum (b, ffestc_blocknum_++);
11527 ffestw_set_shriek (b, ffestc_shriek_module_);
11528 ffestw_set_name (b, ffelex_token_use (name));
11530 ffestd_R1105 (name);
11533 /* ffestc_R1106 -- END MODULE statement
11535 ffestc_R1106(name_token);
11537 Make sure ffestc_kind_ identifies the current kind of program unit. If not
11538 NULL, make sure name_token gives the correct name. Implement the end
11539 of the current program unit. */
11542 ffestc_R1106 (ffelexToken name)
11544 ffestc_check_simple_ ();
11545 if (ffestc_order_module_ () != FFESTC_orderOK_)
11547 ffestc_labeldef_useless_ ();
11550 && (ffelex_token_strcmp (name, ffestw_name (ffestw_stack_top ())) != 0))
11552 ffebad_start (FFEBAD_UNIT_WRONG_NAME);
11553 ffebad_here (0, ffelex_token_where_line (name),
11554 ffelex_token_where_column (name));
11555 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
11556 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
11560 ffestc_shriek_module_ (TRUE);
11563 /* ffestc_R1107_start -- USE statement list begin
11565 ffestc_R1107_start();
11567 Verify that USE is valid here, and begin accepting items in the list. */
11570 ffestc_R1107_start (ffelexToken name, bool only)
11572 ffestc_check_start_ ();
11573 if (ffestc_order_use_ () != FFESTC_orderOK_)
11575 ffestc_ok_ = FALSE;
11578 ffestc_labeldef_useless_ ();
11580 ffestd_R1107_start (name, only);
11585 /* ffestc_R1107_item -- USE statement for name
11587 ffestc_R1107_item(local_token,use_token);
11589 Make sure name_token identifies a valid object to be USEed. local_token
11590 may be NULL if _start_ was called with only==TRUE. */
11593 ffestc_R1107_item (ffelexToken local, ffelexToken use)
11595 ffestc_check_item_ ();
11596 assert (use != NULL);
11600 ffestd_R1107_item (local, use);
11603 /* ffestc_R1107_finish -- USE statement list complete
11605 ffestc_R1107_finish();
11607 Just wrap up any local activities. */
11610 ffestc_R1107_finish ()
11612 ffestc_check_finish_ ();
11616 ffestd_R1107_finish ();
11620 /* ffestc_R1111 -- BLOCK DATA statement
11622 ffestc_R1111(name_token);
11624 Make sure ffestc_kind_ identifies no current program unit. If not
11625 NULL, make sure name_token gives a valid name. Implement the beginning
11626 of a block data program unit. */
11629 ffestc_R1111 (ffelexToken name)
11634 ffestc_check_simple_ ();
11635 if (ffestc_order_unit_ () != FFESTC_orderOK_)
11637 ffestc_labeldef_useless_ ();
11639 ffestc_blocknum_ = 0;
11640 b = ffestw_update (ffestw_push (NULL));
11641 ffestw_set_top_do (b, NULL);
11642 ffestw_set_state (b, FFESTV_stateBLOCKDATA0);
11643 ffestw_set_blocknum (b, ffestc_blocknum_++);
11644 ffestw_set_shriek (b, ffestc_shriek_blockdata_);
11647 ffestw_set_name (b, NULL);
11649 ffestw_set_name (b, ffelex_token_use (name));
11651 s = ffesymbol_declare_blockdataunit (name,
11652 ffelex_token_where_line (ffesta_tokens[0]),
11653 ffelex_token_where_column (ffesta_tokens[0]));
11655 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
11657 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
11658 ffesymbol_set_info (s,
11659 ffeinfo_new (FFEINFO_basictypeNONE,
11660 FFEINFO_kindtypeNONE,
11662 FFEINFO_kindBLOCKDATA,
11663 FFEINFO_whereLOCAL,
11664 FFETARGET_charactersizeNONE));
11665 ffesymbol_signal_unreported (s);
11668 ffesymbol_error (s, name);
11670 ffestd_R1111 (s, name);
11673 /* ffestc_R1112 -- END BLOCK DATA statement
11675 ffestc_R1112(name_token);
11677 Make sure ffestc_kind_ identifies the current kind of program unit. If not
11678 NULL, make sure name_token gives the correct name. Implement the end
11679 of the current program unit. */
11682 ffestc_R1112 (ffelexToken name)
11684 ffestc_check_simple_ ();
11685 if (ffestc_order_blockdata_ () != FFESTC_orderOK_)
11687 ffestc_labeldef_useless_ ();
11691 if (ffestw_name (ffestw_stack_top ()) == NULL)
11693 ffebad_start (FFEBAD_BLOCKDATA_NOT_NAMED);
11694 ffebad_here (0, ffelex_token_where_line (name),
11695 ffelex_token_where_column (name));
11696 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
11699 else if (ffelex_token_strcmp (name, ffestw_name (ffestw_stack_top ())) != 0)
11701 ffebad_start (FFEBAD_UNIT_WRONG_NAME);
11702 ffebad_here (0, ffelex_token_where_line (name),
11703 ffelex_token_where_column (name));
11704 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
11705 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
11710 ffestc_shriek_blockdata_ (TRUE);
11713 /* ffestc_R1202 -- INTERFACE statement
11715 ffestc_R1202(operator,defined_name);
11717 Make sure ffestc_kind_ identifies an INTERFACE block.
11718 Implement the end of the current interface.
11721 Allow no operator or name to mean INTERFACE by itself; missed this
11722 valid form when originally doing syntactic analysis code. */
11726 ffestc_R1202 (ffestpDefinedOperator operator, ffelexToken name)
11730 ffestc_check_simple_ ();
11731 if (ffestc_order_interfacespec_ () != FFESTC_orderOK_)
11733 ffestc_labeldef_useless_ ();
11735 b = ffestw_update (ffestw_push (NULL));
11736 ffestw_set_top_do (b, NULL);
11737 ffestw_set_state (b, FFESTV_stateINTERFACE0);
11738 ffestw_set_blocknum (b, 0);
11739 ffestw_set_shriek (b, ffestc_shriek_interface_);
11741 if ((operator == FFESTP_definedoperatorNone) && (name == NULL))
11742 ffestw_set_substate (b, 0); /* No generic-spec, so disallow MODULE
11745 ffestw_set_substate (b, 1); /* MODULE PROCEDURE ok. */
11747 ffestd_R1202 (operator, name);
11752 /* ffestc_R1203 -- END INTERFACE statement
11756 Make sure ffestc_kind_ identifies an INTERFACE block.
11757 Implement the end of the current interface. */
11762 ffestc_check_simple_ ();
11763 if (ffestc_order_interface_ () != FFESTC_orderOK_)
11765 ffestc_labeldef_useless_ ();
11767 ffestc_shriek_interface_ (TRUE);
11769 ffe_terminate_4 ();
11772 /* ffestc_R1205_start -- MODULE PROCEDURE statement list begin
11774 ffestc_R1205_start();
11776 Verify that MODULE PROCEDURE is valid here, and begin accepting items in
11780 ffestc_R1205_start ()
11782 ffestc_check_start_ ();
11783 if (ffestc_order_interface_ () != FFESTC_orderOK_)
11785 ffestc_ok_ = FALSE;
11788 ffestc_labeldef_useless_ ();
11790 if (ffestw_substate (ffestw_stack_top ()) == 0)
11792 ffebad_start (FFEBAD_INVALID_MODULE_PROCEDURE);
11793 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
11794 ffelex_token_where_column (ffesta_tokens[0]));
11795 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
11797 ffestc_ok_ = FALSE;
11801 if (ffestw_state (ffestw_stack_top ()) == FFESTV_stateINTERFACE0)
11803 ffestw_update (NULL); /* Update state line/col info. */
11804 ffestw_set_state (ffestw_stack_top (), FFESTV_stateINTERFACE1);
11807 ffestd_R1205_start ();
11812 /* ffestc_R1205_item -- MODULE PROCEDURE statement for name
11814 ffestc_R1205_item(name_token);
11816 Make sure name_token identifies a valid object to be MODULE PROCEDUREed. */
11819 ffestc_R1205_item (ffelexToken name)
11821 ffestc_check_item_ ();
11822 assert (name != NULL);
11826 ffestd_R1205_item (name);
11829 /* ffestc_R1205_finish -- MODULE PROCEDURE statement list complete
11831 ffestc_R1205_finish();
11833 Just wrap up any local activities. */
11836 ffestc_R1205_finish ()
11838 ffestc_check_finish_ ();
11842 ffestd_R1205_finish ();
11846 /* ffestc_R1207_start -- EXTERNAL statement list begin
11848 ffestc_R1207_start();
11850 Verify that EXTERNAL is valid here, and begin accepting items in the list. */
11853 ffestc_R1207_start ()
11855 ffestc_check_start_ ();
11856 if (ffestc_order_progspec_ () != FFESTC_orderOK_)
11858 ffestc_ok_ = FALSE;
11861 ffestc_labeldef_useless_ ();
11863 ffestd_R1207_start ();
11868 /* ffestc_R1207_item -- EXTERNAL statement for name
11870 ffestc_R1207_item(name_token);
11872 Make sure name_token identifies a valid object to be EXTERNALd. */
11875 ffestc_R1207_item (ffelexToken name)
11881 ffestc_check_item_ ();
11882 assert (name != NULL);
11886 s = ffesymbol_declare_local (name, FALSE);
11887 sa = ffesymbol_attrs (s);
11889 /* Figure out what kind of object we've got based on previous declarations
11890 of or references to the object. */
11892 if (!ffesymbol_is_specable (s))
11893 na = FFESYMBOL_attrsetNONE; /* Can't dcl sym ref'd in sfuncdef. */
11894 else if (sa & FFESYMBOL_attrsANY)
11895 na = FFESYMBOL_attrsANY;
11896 else if (!(sa & ~(FFESYMBOL_attrsDUMMY
11897 | FFESYMBOL_attrsTYPE)))
11898 na = sa | FFESYMBOL_attrsEXTERNAL;
11900 na = FFESYMBOL_attrsetNONE;
11902 /* Now see what we've got for a new object: NONE means a new error cropped
11903 up; ANY means an old error to be ignored; otherwise, everything's ok,
11904 update the object (symbol) and continue on. */
11906 if (na == FFESYMBOL_attrsetNONE)
11907 ffesymbol_error (s, name);
11908 else if (!(na & FFESYMBOL_attrsANY))
11910 ffesymbol_set_attrs (s, na);
11911 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
11912 ffesymbol_set_explicitwhere (s, TRUE);
11913 ffesymbol_reference (s, name, FALSE);
11914 ffesymbol_signal_unreported (s);
11917 ffestd_R1207_item (name);
11920 /* ffestc_R1207_finish -- EXTERNAL statement list complete
11922 ffestc_R1207_finish();
11924 Just wrap up any local activities. */
11927 ffestc_R1207_finish ()
11929 ffestc_check_finish_ ();
11933 ffestd_R1207_finish ();
11936 /* ffestc_R1208_start -- INTRINSIC statement list begin
11938 ffestc_R1208_start();
11940 Verify that INTRINSIC is valid here, and begin accepting items in the list. */
11943 ffestc_R1208_start ()
11945 ffestc_check_start_ ();
11946 if (ffestc_order_progspec_ () != FFESTC_orderOK_)
11948 ffestc_ok_ = FALSE;
11951 ffestc_labeldef_useless_ ();
11953 ffestd_R1208_start ();
11958 /* ffestc_R1208_item -- INTRINSIC statement for name
11960 ffestc_R1208_item(name_token);
11962 Make sure name_token identifies a valid object to be INTRINSICd. */
11965 ffestc_R1208_item (ffelexToken name)
11971 ffeintrinSpec spec;
11974 ffestc_check_item_ ();
11975 assert (name != NULL);
11979 s = ffesymbol_declare_local (name, TRUE);
11980 sa = ffesymbol_attrs (s);
11982 /* Figure out what kind of object we've got based on previous declarations
11983 of or references to the object. */
11985 if (!ffesymbol_is_specable (s))
11986 na = FFESYMBOL_attrsetNONE; /* Can't dcl sym ref'd in sfuncdef. */
11987 else if (sa & FFESYMBOL_attrsANY)
11989 else if (!(sa & ~FFESYMBOL_attrsTYPE))
11991 if (ffeintrin_is_intrinsic (ffelex_token_text (name), name, TRUE,
11993 && ((imp == FFEINTRIN_impNONE)
11994 #if 0 /* Don't bother with this for now. */
11995 || ((ffeintrin_basictype (spec)
11996 == ffesymbol_basictype (s))
11997 && (ffeintrin_kindtype (spec)
11998 == ffesymbol_kindtype (s)))
12002 || !(sa & FFESYMBOL_attrsTYPE)))
12003 na = sa | FFESYMBOL_attrsINTRINSIC;
12005 na = FFESYMBOL_attrsetNONE;
12008 na = FFESYMBOL_attrsetNONE;
12010 /* Now see what we've got for a new object: NONE means a new error cropped
12011 up; ANY means an old error to be ignored; otherwise, everything's ok,
12012 update the object (symbol) and continue on. */
12014 if (na == FFESYMBOL_attrsetNONE)
12015 ffesymbol_error (s, name);
12016 else if (!(na & FFESYMBOL_attrsANY))
12018 ffesymbol_set_attrs (s, na);
12019 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
12020 ffesymbol_set_generic (s, gen);
12021 ffesymbol_set_specific (s, spec);
12022 ffesymbol_set_implementation (s, imp);
12023 ffesymbol_set_info (s,
12024 ffeinfo_new (ffesymbol_basictype (s),
12025 ffesymbol_kindtype (s),
12028 FFEINFO_whereINTRINSIC,
12029 ffesymbol_size (s)));
12030 ffesymbol_set_explicitwhere (s, TRUE);
12031 ffesymbol_reference (s, name, TRUE);
12034 ffesymbol_signal_unreported (s);
12036 ffestd_R1208_item (name);
12039 /* ffestc_R1208_finish -- INTRINSIC statement list complete
12041 ffestc_R1208_finish();
12043 Just wrap up any local activities. */
12046 ffestc_R1208_finish ()
12048 ffestc_check_finish_ ();
12052 ffestd_R1208_finish ();
12055 /* ffestc_R1212 -- CALL statement
12057 ffestc_R1212(expr,expr_token);
12059 Make sure statement is valid here; implement. */
12062 ffestc_R1212 (ffebld expr, ffelexToken expr_token UNUSED)
12064 ffebld item; /* ITEM. */
12065 ffebld labexpr; /* LABTOK=>LABTER. */
12067 bool ok; /* TRUE if all LABTOKs were ok. */
12068 bool ok1; /* TRUE if a particular LABTOK is ok. */
12070 ffestc_check_simple_ ();
12071 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
12073 ffestc_labeldef_branch_begin_ ();
12075 if (ffebld_op (expr) != FFEBLD_opSUBRREF)
12076 ffestd_R841 (FALSE); /* CONTINUE. */
12081 for (item = ffebld_right (expr);
12083 item = ffebld_trail (item))
12085 if (((labexpr = ffebld_head (item)) != NULL)
12086 && (ffebld_op (labexpr) == FFEBLD_opLABTOK))
12088 ok1 = ffestc_labelref_is_branch_ (ffebld_labtok (labexpr),
12090 ffelex_token_kill (ffebld_labtok (labexpr));
12096 ffebld_set_op (labexpr, FFEBLD_opLABTER);
12097 ffebld_set_labter (labexpr, label);
12102 ffestd_R1212 (expr);
12105 if (ffestc_shriek_after1_ != NULL)
12106 (*ffestc_shriek_after1_) (TRUE);
12107 ffestc_labeldef_branch_end_ ();
12110 /* ffestc_R1213 -- Defined assignment statement
12112 ffestc_R1213(dest_expr,source_expr,source_token);
12114 Make sure the assignment is valid. */
12118 ffestc_R1213 (ffebld dest, ffebld source, ffelexToken source_token)
12120 ffestc_check_simple_ ();
12121 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
12123 ffestc_labeldef_branch_begin_ ();
12125 ffestd_R1213 (dest, source);
12127 if (ffestc_shriek_after1_ != NULL)
12128 (*ffestc_shriek_after1_) (TRUE);
12129 ffestc_labeldef_branch_end_ ();
12133 /* ffestc_R1219 -- FUNCTION statement
12135 ffestc_R1219(funcname,arglist,ending_token,kind,kindt,len,lent,
12138 Make sure statement is valid here, register arguments for the
12139 function name, and so on.
12142 Added the kind, len, and recursive arguments. */
12145 ffestc_R1219 (ffelexToken funcname, ffesttTokenList args,
12146 ffelexToken final UNUSED, ffestpType type, ffebld kind,
12147 ffelexToken kindt, ffebld len, ffelexToken lent,
12148 ffelexToken recursive, ffelexToken result)
12152 ffesymbol fs; /* FUNCTION symbol when dealing with RESULT
12157 bool separate_result;
12159 assert ((funcname != NULL)
12160 && (ffelex_token_type (funcname) == FFELEX_typeNAME));
12162 ffestc_check_simple_ ();
12163 if (ffestc_order_iface_ () != FFESTC_orderOK_)
12165 ffestc_labeldef_useless_ ();
12167 ffestc_blocknum_ = 0;
12168 ffesta_is_entry_valid =
12169 (ffestw_state (ffestw_stack_top ()) == FFESTV_stateNIL);
12170 b = ffestw_update (ffestw_push (NULL));
12171 ffestw_set_top_do (b, NULL);
12172 ffestw_set_state (b, FFESTV_stateFUNCTION0);
12173 ffestw_set_blocknum (b, ffestc_blocknum_++);
12174 ffestw_set_shriek (b, ffestc_shriek_function_);
12175 ffestw_set_name (b, ffelex_token_use (funcname));
12177 if (type == FFESTP_typeNone)
12179 ffestc_local_.decl.basic_type = FFEINFO_basictypeNONE;
12180 ffestc_local_.decl.kind_type = FFEINFO_kindtypeNONE;
12181 ffestc_local_.decl.size = FFETARGET_charactersizeNONE;
12185 ffestc_establish_declstmt_ (type, ffesta_tokens[0],
12186 kind, kindt, len, lent);
12187 ffestc_establish_declinfo_ (NULL, NULL, NULL, NULL);
12190 separate_result = (result != NULL)
12191 && (ffelex_token_strcmp (funcname, result) != 0);
12193 if (separate_result)
12194 fs = ffesymbol_declare_funcnotresunit (funcname); /* Global/local. */
12196 fs = ffesymbol_declare_funcunit (funcname); /* Global only. */
12198 if (ffesymbol_state (fs) == FFESYMBOL_stateNONE)
12200 ffesymbol_set_state (fs, FFESYMBOL_stateUNDERSTOOD);
12201 ffesymbol_signal_unreported (fs);
12203 /* Note that .basic_type and .kind_type might be NONE here. */
12205 ffesymbol_set_info (fs,
12206 ffeinfo_new (ffestc_local_.decl.basic_type,
12207 ffestc_local_.decl.kind_type,
12209 FFEINFO_kindFUNCTION,
12210 FFEINFO_whereLOCAL,
12211 ffestc_local_.decl.size));
12213 /* Check whether the type info fits the filewide expectations;
12214 set ok flag accordingly. */
12216 ffesymbol_reference (fs, funcname, FALSE);
12217 if (ffesymbol_attrs (fs) & FFESYMBOL_attrsANY)
12218 ffestc_parent_ok_ = FALSE;
12220 ffestc_parent_ok_ = TRUE;
12224 if (ffesymbol_kind (fs) != FFEINFO_kindANY)
12225 ffesymbol_error (fs, funcname);
12226 ffestc_parent_ok_ = FALSE;
12229 if (ffestc_parent_ok_)
12231 ffebld_init_list (&fs->dummy_args, &ffestc_local_.dummy.list_bottom);
12232 ffestt_tokenlist_drive (args, ffestc_promote_dummy_);
12233 ffebld_end_list (&ffestc_local_.dummy.list_bottom);
12236 if (result == NULL)
12241 s = ffesymbol_declare_funcresult (res);
12242 sa = ffesymbol_attrs (s);
12244 /* Figure out what kind of object we've got based on previous declarations
12245 of or references to the object. */
12247 if (sa & FFESYMBOL_attrsANY)
12248 na = FFESYMBOL_attrsANY;
12249 else if (ffesymbol_state (s) != FFESYMBOL_stateNONE)
12250 na = FFESYMBOL_attrsetNONE;
12253 na = FFESYMBOL_attrsRESULT;
12254 if (ffestc_local_.decl.basic_type != FFEINFO_basictypeNONE)
12256 na |= FFESYMBOL_attrsTYPE;
12257 if ((ffestc_local_.decl.basic_type == FFEINFO_basictypeCHARACTER)
12258 && (ffestc_local_.decl.size == FFETARGET_charactersizeNONE))
12259 na |= FFESYMBOL_attrsANYLEN;
12263 /* Now see what we've got for a new object: NONE means a new error cropped
12264 up; ANY means an old error to be ignored; otherwise, everything's ok,
12265 update the object (symbol) and continue on. */
12267 if ((na & ~FFESYMBOL_attrsANY) == FFESYMBOL_attrsetNONE)
12269 if (!(na & FFESYMBOL_attrsANY))
12270 ffesymbol_error (s, res);
12271 ffesymbol_set_funcresult (fs, NULL);
12272 ffesymbol_set_funcresult (s, NULL);
12273 ffestc_parent_ok_ = FALSE;
12277 ffesymbol_set_attrs (s, na);
12278 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
12279 ffesymbol_set_funcresult (fs, s);
12280 ffesymbol_set_funcresult (s, fs);
12281 if (ffestc_local_.decl.basic_type != FFEINFO_basictypeNONE)
12283 ffesymbol_set_info (s,
12284 ffeinfo_new (ffestc_local_.decl.basic_type,
12285 ffestc_local_.decl.kind_type,
12289 ffestc_local_.decl.size));
12293 ffesymbol_signal_unreported (fs);
12295 ffestd_R1219 (fs, funcname, args, type, kind, kindt, len, lent,
12296 (recursive != NULL), result, separate_result);
12299 /* ffestc_R1221 -- END FUNCTION statement
12301 ffestc_R1221(name_token);
12303 Make sure ffestc_kind_ identifies the current kind of program unit. If
12304 not NULL, make sure name_token gives the correct name. Implement the end
12305 of the current program unit. */
12308 ffestc_R1221 (ffelexToken name)
12310 ffestc_check_simple_ ();
12311 if (ffestc_order_function_ () != FFESTC_orderOK_)
12313 ffestc_labeldef_notloop_ ();
12316 && (ffelex_token_strcmp (name, ffestw_name (ffestw_stack_top ())) != 0))
12318 ffebad_start (FFEBAD_UNIT_WRONG_NAME);
12319 ffebad_here (0, ffelex_token_where_line (name),
12320 ffelex_token_where_column (name));
12321 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
12322 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
12326 ffestc_shriek_function_ (TRUE);
12329 /* ffestc_R1223 -- SUBROUTINE statement
12331 ffestc_R1223(subrname,arglist,ending_token,recursive_token);
12333 Make sure statement is valid here, register arguments for the
12334 subroutine name, and so on.
12337 Added the recursive argument. */
12340 ffestc_R1223 (ffelexToken subrname, ffesttTokenList args,
12341 ffelexToken final, ffelexToken recursive)
12346 assert ((subrname != NULL)
12347 && (ffelex_token_type (subrname) == FFELEX_typeNAME));
12349 ffestc_check_simple_ ();
12350 if (ffestc_order_iface_ () != FFESTC_orderOK_)
12352 ffestc_labeldef_useless_ ();
12354 ffestc_blocknum_ = 0;
12355 ffesta_is_entry_valid
12356 = (ffestw_state (ffestw_stack_top ()) == FFESTV_stateNIL);
12357 b = ffestw_update (ffestw_push (NULL));
12358 ffestw_set_top_do (b, NULL);
12359 ffestw_set_state (b, FFESTV_stateSUBROUTINE0);
12360 ffestw_set_blocknum (b, ffestc_blocknum_++);
12361 ffestw_set_shriek (b, ffestc_shriek_subroutine_);
12362 ffestw_set_name (b, ffelex_token_use (subrname));
12364 s = ffesymbol_declare_subrunit (subrname);
12365 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
12367 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
12368 ffesymbol_set_info (s,
12369 ffeinfo_new (FFEINFO_basictypeNONE,
12370 FFEINFO_kindtypeNONE,
12372 FFEINFO_kindSUBROUTINE,
12373 FFEINFO_whereLOCAL,
12374 FFETARGET_charactersizeNONE));
12375 ffestc_parent_ok_ = TRUE;
12379 if (ffesymbol_kind (s) != FFEINFO_kindANY)
12380 ffesymbol_error (s, subrname);
12381 ffestc_parent_ok_ = FALSE;
12384 if (ffestc_parent_ok_)
12386 ffebld_init_list (&s->dummy_args, &ffestc_local_.dummy.list_bottom);
12387 ffestt_tokenlist_drive (args, ffestc_promote_dummy_);
12388 ffebld_end_list (&ffestc_local_.dummy.list_bottom);
12391 ffesymbol_signal_unreported (s);
12393 ffestd_R1223 (s, subrname, args, final, (recursive != NULL));
12396 /* ffestc_R1225 -- END SUBROUTINE statement
12398 ffestc_R1225(name_token);
12400 Make sure ffestc_kind_ identifies the current kind of program unit. If
12401 not NULL, make sure name_token gives the correct name. Implement the end
12402 of the current program unit. */
12405 ffestc_R1225 (ffelexToken name)
12407 ffestc_check_simple_ ();
12408 if (ffestc_order_subroutine_ () != FFESTC_orderOK_)
12410 ffestc_labeldef_notloop_ ();
12413 && (ffelex_token_strcmp (name, ffestw_name (ffestw_stack_top ())) != 0))
12415 ffebad_start (FFEBAD_UNIT_WRONG_NAME);
12416 ffebad_here (0, ffelex_token_where_line (name),
12417 ffelex_token_where_column (name));
12418 ffebad_here (1, ffelex_token_where_line (ffestw_name (ffestw_stack_top ())),
12419 ffelex_token_where_column (ffestw_name (ffestw_stack_top ())));
12423 ffestc_shriek_subroutine_ (TRUE);
12426 /* ffestc_R1226 -- ENTRY statement
12428 ffestc_R1226(entryname,arglist,ending_token);
12430 Make sure we're in a SUBROUTINE or FUNCTION, register arguments for the
12431 entry point name, and so on. */
12434 ffestc_R1226 (ffelexToken entryname, ffesttTokenList args,
12435 ffelexToken final UNUSED)
12441 bool in_spec; /* TRUE if further specification statements
12442 may follow, FALSE if executable stmts. */
12443 bool in_func; /* TRUE if ENTRY is a FUNCTION, not
12446 assert ((entryname != NULL)
12447 && (ffelex_token_type (entryname) == FFELEX_typeNAME));
12449 ffestc_check_simple_ ();
12450 if (ffestc_order_entry_ () != FFESTC_orderOK_)
12452 ffestc_labeldef_useless_ ();
12454 switch (ffestw_state (ffestw_stack_top ()))
12456 case FFESTV_stateFUNCTION1:
12457 case FFESTV_stateFUNCTION2:
12458 case FFESTV_stateFUNCTION3:
12463 case FFESTV_stateFUNCTION4:
12468 case FFESTV_stateSUBROUTINE1:
12469 case FFESTV_stateSUBROUTINE2:
12470 case FFESTV_stateSUBROUTINE3:
12475 case FFESTV_stateSUBROUTINE4:
12481 assert ("ENTRY not in FUNCTION or SUBROUTINE?" == NULL);
12488 fs = ffesymbol_declare_funcunit (entryname);
12490 fs = ffesymbol_declare_subrunit (entryname);
12492 if (ffesymbol_state (fs) == FFESYMBOL_stateNONE)
12493 ffesymbol_set_state (fs, FFESYMBOL_stateUNDERSTOOD);
12496 if (ffesymbol_kind (fs) != FFEINFO_kindANY)
12497 ffesymbol_error (fs, entryname);
12500 ++ffestc_entry_num_;
12502 ffebld_init_list (&fs->dummy_args, &ffestc_local_.dummy.list_bottom);
12504 ffestt_tokenlist_drive (args, ffestc_promote_dummy_);
12506 ffestt_tokenlist_drive (args, ffestc_promote_execdummy_);
12507 ffebld_end_list (&ffestc_local_.dummy.list_bottom);
12511 s = ffesymbol_declare_funcresult (entryname);
12512 ffesymbol_set_funcresult (fs, s);
12513 ffesymbol_set_funcresult (s, fs);
12514 sa = ffesymbol_attrs (s);
12516 /* Figure out what kind of object we've got based on previous
12517 declarations of or references to the object. */
12519 if (ffesymbol_state (s) == FFESYMBOL_stateUNDERSTOOD)
12520 na = FFESYMBOL_attrsetNONE;
12521 else if (sa & FFESYMBOL_attrsANY)
12522 na = FFESYMBOL_attrsANY;
12523 else if (!(sa & ~(FFESYMBOL_attrsANYLEN
12524 | FFESYMBOL_attrsTYPE)))
12525 na = sa | FFESYMBOL_attrsRESULT;
12527 na = FFESYMBOL_attrsetNONE;
12529 /* Now see what we've got for a new object: NONE means a new error
12530 cropped up; ANY means an old error to be ignored; otherwise,
12531 everything's ok, update the object (symbol) and continue on. */
12533 if (na == FFESYMBOL_attrsetNONE)
12535 ffesymbol_error (s, entryname);
12536 ffestc_parent_ok_ = FALSE;
12538 else if (na & FFESYMBOL_attrsANY)
12540 ffestc_parent_ok_ = FALSE;
12544 ffesymbol_set_attrs (s, na);
12545 if (ffesymbol_state (s) == FFESYMBOL_stateNONE)
12546 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
12547 else if (ffesymbol_state (s) == FFESYMBOL_stateUNCERTAIN)
12549 ffesymbol_set_state (s, FFESYMBOL_stateUNDERSTOOD);
12550 ffesymbol_set_info (s,
12551 ffeinfo_new (ffesymbol_basictype (s),
12552 ffesymbol_kindtype (s),
12554 FFEINFO_kindENTITY,
12555 FFEINFO_whereRESULT,
12556 ffesymbol_size (s)));
12557 ffesymbol_resolve_intrin (s);
12558 ffestorag_exec_layout (s);
12562 /* Since ENTRY might appear after executable stmts, do what would have
12563 been done if it hadn't -- give symbol implicit type and
12564 exec-transition it. */
12566 if (!in_spec && ffesymbol_is_specable (s))
12568 if (!ffeimplic_establish_symbol (s)) /* Do implicit typing. */
12569 ffesymbol_error (s, entryname);
12570 s = ffecom_sym_exec_transition (s);
12573 /* Use whatever type info is available for ENTRY to set up type for its
12574 global-name-space function symbol relative. */
12576 ffesymbol_set_info (fs,
12577 ffeinfo_new (ffesymbol_basictype (s),
12578 ffesymbol_kindtype (s),
12580 FFEINFO_kindFUNCTION,
12581 FFEINFO_whereLOCAL,
12582 ffesymbol_size (s)));
12585 /* Check whether the type info fits the filewide expectations;
12586 set ok flag accordingly. */
12588 ffesymbol_reference (fs, entryname, FALSE);
12591 When ENTRY FOO() RESULT(IBAR) is supported, what will the typing be
12592 if FOO and IBAR would normally end up with different types? I think
12593 the answer is that FOO is always given whatever type would be chosen
12594 for IBAR, rather than the other way around, and I think it ends up
12595 working that way for FUNCTION FOO() RESULT(IBAR), but this should be
12596 checked out in all its different combos. Related question is, is
12597 there any way that FOO in either case ends up without type info
12598 filled in? Does anyone care? */
12600 ffesymbol_signal_unreported (s);
12604 ffesymbol_set_info (fs,
12605 ffeinfo_new (FFEINFO_basictypeNONE,
12606 FFEINFO_kindtypeNONE,
12608 FFEINFO_kindSUBROUTINE,
12609 FFEINFO_whereLOCAL,
12610 FFETARGET_charactersizeNONE));
12614 fs = ffecom_sym_exec_transition (fs);
12616 ffesymbol_signal_unreported (fs);
12621 /* ffestc_R1227 -- RETURN statement
12623 ffestc_R1227(expr,expr_token);
12625 Make sure statement is valid here; implement. expr and expr_token are
12626 both NULL if there was no expression. */
12629 ffestc_R1227 (ffebld expr, ffelexToken expr_token)
12633 ffestc_check_simple_ ();
12634 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
12636 ffestc_labeldef_notloop_begin_ ();
12638 for (b = ffestw_stack_top (); ; b = ffestw_previous (b))
12640 switch (ffestw_state (b))
12642 case FFESTV_statePROGRAM4:
12643 case FFESTV_stateSUBROUTINE4:
12644 case FFESTV_stateFUNCTION4:
12645 goto base; /* :::::::::::::::::::: */
12647 case FFESTV_stateNIL:
12648 assert ("bad state" == NULL);
12657 switch (ffestw_state (b))
12659 case FFESTV_statePROGRAM4:
12660 if (ffe_is_pedantic ())
12662 ffebad_start (FFEBAD_RETURN_IN_MAIN);
12663 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
12664 ffelex_token_where_column (ffesta_tokens[0]));
12669 ffebad_start (FFEBAD_ALTRETURN_IN_PROGRAM);
12670 ffebad_here (0, ffelex_token_where_line (expr_token),
12671 ffelex_token_where_column (expr_token));
12677 case FFESTV_stateSUBROUTINE4:
12680 case FFESTV_stateFUNCTION4:
12683 ffebad_start (FFEBAD_ALTRETURN_IN_FUNCTION);
12684 ffebad_here (0, ffelex_token_where_line (expr_token),
12685 ffelex_token_where_column (expr_token));
12692 assert ("bad state #2" == NULL);
12696 ffestd_R1227 (expr);
12698 if (ffestc_shriek_after1_ != NULL)
12699 (*ffestc_shriek_after1_) (TRUE);
12701 /* notloop's that are actionif's can be the target of a loop-end
12702 statement if they're in the "then" part of a logical IF, as
12703 in "DO 10", "10 IF (...) RETURN". */
12705 ffestc_labeldef_branch_end_ ();
12708 /* ffestc_R1228 -- CONTAINS statement
12716 ffestc_check_simple_ ();
12717 if (ffestc_order_contains_ () != FFESTC_orderOK_)
12719 ffestc_labeldef_useless_ ();
12723 ffe_terminate_3 ();
12728 /* ffestc_R1229_start -- STMTFUNCTION statement begin
12730 ffestc_R1229_start(func_name,func_arg_list,close_paren);
12732 Verify that STMTFUNCTION is valid here, establish func_arg_list in a new
12733 "live" scope within the current scope, and expect the actual expression
12734 (or NULL) in ffestc_R1229_finish. The reason there are two ffestc
12735 functions to handle this is so the scope can be established, allowing
12736 ffeexpr to assign proper characteristics to references to the dummy
12740 ffestc_R1229_start (ffelexToken name, ffesttTokenList args,
12741 ffelexToken final UNUSED)
12747 ffestc_check_start_ ();
12748 if (ffestc_order_sfunc_ () != FFESTC_orderOK_)
12750 ffestc_ok_ = FALSE;
12753 ffestc_labeldef_useless_ ();
12755 assert (name != NULL);
12756 assert (args != NULL);
12758 s = ffesymbol_declare_local (name, FALSE);
12759 sa = ffesymbol_attrs (s);
12761 /* Figure out what kind of object we've got based on previous declarations
12762 of or references to the object. */
12764 if (!ffesymbol_is_specable (s))
12765 na = FFESYMBOL_attrsetNONE; /* Can't dcl sym ref'd in sfuncdef. */
12766 else if (sa & FFESYMBOL_attrsANY)
12767 na = FFESYMBOL_attrsANY;
12768 else if (!(sa & ~FFESYMBOL_attrsTYPE))
12769 na = sa | FFESYMBOL_attrsSFUNC;
12771 na = FFESYMBOL_attrsetNONE;
12773 /* Now see what we've got for a new object: NONE means a new error cropped
12774 up; ANY means an old error to be ignored; otherwise, everything's ok,
12775 update the object (symbol) and continue on. */
12777 if (na == FFESYMBOL_attrsetNONE)
12779 ffesymbol_error (s, name);
12780 ffestc_parent_ok_ = FALSE;
12782 else if (na & FFESYMBOL_attrsANY)
12783 ffestc_parent_ok_ = FALSE;
12786 ffesymbol_set_attrs (s, na);
12787 ffesymbol_set_state (s, FFESYMBOL_stateSEEN);
12788 if (!ffeimplic_establish_symbol (s)
12789 || ((ffesymbol_basictype (s) == FFEINFO_basictypeCHARACTER)
12790 && (ffesymbol_size (s) == FFETARGET_charactersizeNONE)))
12792 ffesymbol_error (s, ffesta_tokens[0]);
12793 ffestc_parent_ok_ = FALSE;
12797 /* Tell ffeexpr that sfunc def is in progress. */
12798 ffesymbol_set_sfexpr (s, ffebld_new_any ());
12799 ffestc_parent_ok_ = TRUE;
12805 if (ffestc_parent_ok_)
12807 ffebld_init_list (&s->dummy_args, &ffestc_local_.dummy.list_bottom);
12808 ffestc_sfdummy_argno_ = 0;
12809 ffestt_tokenlist_drive (args, ffestc_promote_sfdummy_);
12810 ffebld_end_list (&ffestc_local_.dummy.list_bottom);
12813 ffestc_local_.sfunc.symbol = s;
12815 ffestd_R1229_start (name, args);
12820 /* ffestc_R1229_finish -- STMTFUNCTION statement list complete
12822 ffestc_R1229_finish(expr,expr_token);
12824 If expr is NULL, an error occurred parsing the expansion expression, so
12825 just cancel the effects of ffestc_R1229_start and pretend nothing
12826 happened. Otherwise, install the expression as the expansion for the
12827 statement function named in _start_, then clean up. */
12830 ffestc_R1229_finish (ffebld expr, ffelexToken expr_token)
12832 ffestc_check_finish_ ();
12836 if (ffestc_parent_ok_ && (expr != NULL))
12837 ffesymbol_set_sfexpr (ffestc_local_.sfunc.symbol,
12838 ffeexpr_convert_to_sym (expr,
12840 ffestc_local_.sfunc.symbol,
12841 ffesta_tokens[0]));
12843 ffestd_R1229_finish (ffestc_local_.sfunc.symbol);
12845 ffesymbol_signal_unreported (ffestc_local_.sfunc.symbol);
12847 ffe_terminate_4 ();
12850 /* ffestc_S3P4 -- INCLUDE line
12852 ffestc_S3P4(filename,filename_token);
12854 Make sure INCLUDE not preceded by any semicolons or a label def; implement. */
12857 ffestc_S3P4 (ffebld filename, ffelexToken filename_token UNUSED)
12859 ffestc_check_simple_ ();
12860 ffestc_labeldef_invalid_ ();
12862 ffestd_S3P4 (filename);
12865 /* ffestc_V003_start -- STRUCTURE statement list begin
12867 ffestc_V003_start(structure_name);
12869 Verify that STRUCTURE is valid here, and begin accepting items in the list. */
12873 ffestc_V003_start (ffelexToken structure_name)
12877 ffestc_check_start_ ();
12878 if (ffestc_order_vxtstructure_ () != FFESTC_orderOK_)
12880 ffestc_ok_ = FALSE;
12883 ffestc_labeldef_useless_ ();
12885 switch (ffestw_state (ffestw_stack_top ()))
12887 case FFESTV_stateSTRUCTURE:
12888 case FFESTV_stateMAP:
12889 ffestc_local_.V003.list_state = 2; /* Require at least one field
12891 ffestw_set_substate (ffestw_stack_top (), 1); /* Seen at least one
12896 ffestc_local_.V003.list_state = 0; /* No field names required. */
12897 if (structure_name == NULL)
12899 ffebad_start (FFEBAD_STRUCT_MISSING_NAME);
12900 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
12901 ffelex_token_where_column (ffesta_tokens[0]));
12907 b = ffestw_update (ffestw_push (NULL));
12908 ffestw_set_top_do (b, NULL);
12909 ffestw_set_state (b, FFESTV_stateSTRUCTURE);
12910 ffestw_set_blocknum (b, 0);
12911 ffestw_set_shriek (b, ffestc_shriek_structure_);
12912 ffestw_set_substate (b, 0); /* No field-declarations seen yet. */
12914 ffestd_V003_start (structure_name);
12919 /* ffestc_V003_item -- STRUCTURE statement for object-name
12921 ffestc_V003_item(name_token,dim_list);
12923 Make sure name_token identifies a valid object to be STRUCTUREd. */
12926 ffestc_V003_item (ffelexToken name, ffesttDimList dims)
12928 ffestc_check_item_ ();
12929 assert (name != NULL);
12933 if (ffestc_local_.V003.list_state < 2)
12935 if (ffestc_local_.V003.list_state == 0)
12937 ffestc_local_.V003.list_state = 1;
12938 ffebad_start (FFEBAD_STRUCT_IGNORING_FIELD);
12939 ffebad_here (0, ffelex_token_where_line (name),
12940 ffelex_token_where_column (name));
12945 ffestc_local_.V003.list_state = 3; /* Have at least one field name. */
12948 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
12950 ffestd_V003_item (name, dims);
12953 /* ffestc_V003_finish -- STRUCTURE statement list complete
12955 ffestc_V003_finish();
12957 Just wrap up any local activities. */
12960 ffestc_V003_finish ()
12962 ffestc_check_finish_ ();
12966 if (ffestc_local_.V003.list_state == 2)
12968 ffebad_start (FFEBAD_STRUCT_MISSING_FIELD);
12969 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
12970 ffelex_token_where_column (ffesta_tokens[0]));
12971 ffebad_here (1, ffestw_line (ffestw_previous (ffestw_stack_top ())),
12972 ffestw_col (ffestw_previous (ffestw_stack_top ())));
12976 ffestd_V003_finish ();
12979 /* ffestc_V004 -- END STRUCTURE statement
12983 Make sure ffestc_kind_ identifies a STRUCTURE block.
12984 Implement the end of the current STRUCTURE block. */
12989 ffestc_check_simple_ ();
12990 if (ffestc_order_structure_ () != FFESTC_orderOK_)
12992 ffestc_labeldef_useless_ ();
12994 if (ffestw_substate (ffestw_stack_top ()) != 1)
12996 ffebad_start (FFEBAD_STRUCT_NO_COMPONENTS);
12997 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
12998 ffelex_token_where_column (ffesta_tokens[0]));
12999 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
13003 ffestc_shriek_structure_ (TRUE);
13006 /* ffestc_V009 -- UNION statement
13015 ffestc_check_simple_ ();
13016 if (ffestc_order_structure_ () != FFESTC_orderOK_)
13018 ffestc_labeldef_useless_ ();
13020 ffestw_set_substate (ffestw_stack_top (), 1); /* Seen at least one member. */
13022 b = ffestw_update (ffestw_push (NULL));
13023 ffestw_set_top_do (b, NULL);
13024 ffestw_set_state (b, FFESTV_stateUNION);
13025 ffestw_set_blocknum (b, 0);
13026 ffestw_set_shriek (b, ffestc_shriek_union_);
13027 ffestw_set_substate (b, 0); /* No map decls seen yet. */
13032 /* ffestc_V010 -- END UNION statement
13036 Make sure ffestc_kind_ identifies a UNION block.
13037 Implement the end of the current UNION block. */
13042 ffestc_check_simple_ ();
13043 if (ffestc_order_union_ () != FFESTC_orderOK_)
13045 ffestc_labeldef_useless_ ();
13047 if (ffestw_substate (ffestw_stack_top ()) != 2)
13049 ffebad_start (FFEBAD_UNION_NO_TWO_MAPS);
13050 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
13051 ffelex_token_where_column (ffesta_tokens[0]));
13052 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
13056 ffestc_shriek_union_ (TRUE);
13059 /* ffestc_V012 -- MAP statement
13068 ffestc_check_simple_ ();
13069 if (ffestc_order_union_ () != FFESTC_orderOK_)
13071 ffestc_labeldef_useless_ ();
13073 if (ffestw_substate (ffestw_stack_top ()) != 2)
13074 ffestw_substate (ffestw_stack_top ())++; /* 0=>1, 1=>2. */
13076 b = ffestw_update (ffestw_push (NULL));
13077 ffestw_set_top_do (b, NULL);
13078 ffestw_set_state (b, FFESTV_stateMAP);
13079 ffestw_set_blocknum (b, 0);
13080 ffestw_set_shriek (b, ffestc_shriek_map_);
13081 ffestw_set_substate (b, 0); /* No field-declarations seen yet. */
13086 /* ffestc_V013 -- END MAP statement
13090 Make sure ffestc_kind_ identifies a MAP block.
13091 Implement the end of the current MAP block. */
13096 ffestc_check_simple_ ();
13097 if (ffestc_order_map_ () != FFESTC_orderOK_)
13099 ffestc_labeldef_useless_ ();
13101 if (ffestw_substate (ffestw_stack_top ()) != 1)
13103 ffebad_start (FFEBAD_MAP_NO_COMPONENTS);
13104 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
13105 ffelex_token_where_column (ffesta_tokens[0]));
13106 ffebad_here (1, ffestw_line (ffestw_stack_top ()), ffestw_col (ffestw_stack_top ()));
13110 ffestc_shriek_map_ (TRUE);
13114 /* ffestc_V014_start -- VOLATILE statement list begin
13116 ffestc_V014_start();
13118 Verify that VOLATILE is valid here, and begin accepting items in the
13122 ffestc_V014_start ()
13124 ffestc_check_start_ ();
13125 if (ffestc_order_progspec_ () != FFESTC_orderOK_)
13127 ffestc_ok_ = FALSE;
13130 ffestc_labeldef_useless_ ();
13132 ffestd_V014_start ();
13137 /* ffestc_V014_item_object -- VOLATILE statement for object-name
13139 ffestc_V014_item_object(name_token);
13141 Make sure name_token identifies a valid object to be VOLATILEd. */
13144 ffestc_V014_item_object (ffelexToken name)
13146 ffestc_check_item_ ();
13147 assert (name != NULL);
13151 ffestd_V014_item_object (name);
13154 /* ffestc_V014_item_cblock -- VOLATILE statement for common-block-name
13156 ffestc_V014_item_cblock(name_token);
13158 Make sure name_token identifies a valid common block to be VOLATILEd. */
13161 ffestc_V014_item_cblock (ffelexToken name)
13163 ffestc_check_item_ ();
13164 assert (name != NULL);
13168 ffestd_V014_item_cblock (name);
13171 /* ffestc_V014_finish -- VOLATILE statement list complete
13173 ffestc_V014_finish();
13175 Just wrap up any local activities. */
13178 ffestc_V014_finish ()
13180 ffestc_check_finish_ ();
13184 ffestd_V014_finish ();
13187 /* ffestc_V016_start -- RECORD statement list begin
13189 ffestc_V016_start();
13191 Verify that RECORD is valid here, and begin accepting items in the list. */
13195 ffestc_V016_start ()
13197 ffestc_check_start_ ();
13198 if (ffestc_order_record_ () != FFESTC_orderOK_)
13200 ffestc_ok_ = FALSE;
13203 ffestc_labeldef_useless_ ();
13205 switch (ffestw_state (ffestw_stack_top ()))
13207 case FFESTV_stateSTRUCTURE:
13208 case FFESTV_stateMAP:
13209 ffestw_set_substate (ffestw_stack_top (), 1); /* Seen at least one
13217 ffestd_V016_start ();
13222 /* ffestc_V016_item_structure -- RECORD statement for common-block-name
13224 ffestc_V016_item_structure(name_token);
13226 Make sure name_token identifies a valid structure to be RECORDed. */
13229 ffestc_V016_item_structure (ffelexToken name)
13231 ffestc_check_item_ ();
13232 assert (name != NULL);
13236 ffestd_V016_item_structure (name);
13239 /* ffestc_V016_item_object -- RECORD statement for object-name
13241 ffestc_V016_item_object(name_token,dim_list);
13243 Make sure name_token identifies a valid object to be RECORDd. */
13246 ffestc_V016_item_object (ffelexToken name, ffesttDimList dims)
13248 ffestc_check_item_ ();
13249 assert (name != NULL);
13254 ffesta_set_outpooldisp (FFESTA_pooldispPRESERVE);
13256 ffestd_V016_item_object (name, dims);
13259 /* ffestc_V016_finish -- RECORD statement list complete
13261 ffestc_V016_finish();
13263 Just wrap up any local activities. */
13266 ffestc_V016_finish ()
13268 ffestc_check_finish_ ();
13272 ffestd_V016_finish ();
13275 /* ffestc_V018_start -- REWRITE(...) statement list begin
13277 ffestc_V018_start();
13279 Verify that REWRITE is valid here, and begin accepting items in the
13283 ffestc_V018_start ()
13285 ffestvFormat format;
13287 ffestc_check_start_ ();
13288 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
13290 ffestc_ok_ = FALSE;
13293 ffestc_labeldef_branch_begin_ ();
13295 if (!ffestc_subr_is_branch_
13296 (&ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixERR])
13297 || !ffestc_subr_is_format_
13298 (&ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixFMT])
13299 || !ffestc_subr_is_present_ ("UNIT",
13300 &ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixUNIT]))
13302 ffestc_ok_ = FALSE;
13306 format = ffestc_subr_format_
13307 (&ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixFMT]);
13310 case FFESTV_formatNAMELIST:
13311 case FFESTV_formatASTERISK:
13312 ffebad_start (FFEBAD_CONFLICTING_SPECS);
13313 ffebad_here (0, ffelex_token_where_line (ffesta_tokens[0]),
13314 ffelex_token_where_column (ffesta_tokens[0]));
13315 assert (ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixFMT].kw_or_val_present);
13316 if (ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixFMT].kw_present)
13318 ffebad_here (0, ffelex_token_where_line
13319 (ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixFMT].kw),
13320 ffelex_token_where_column
13321 (ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixFMT].kw));
13325 ffebad_here (1, ffelex_token_where_line
13326 (ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixFMT].value),
13327 ffelex_token_where_column
13328 (ffestp_file.rewrite.rewrite_spec[FFESTP_rewriteixFMT].value));
13331 ffestc_ok_ = FALSE;
13338 ffestd_V018_start (format);
13343 /* ffestc_V018_item -- REWRITE statement i/o item
13345 ffestc_V018_item(expr,expr_token);
13347 Implement output-list expression. */
13350 ffestc_V018_item (ffebld expr, ffelexToken expr_token)
13352 ffestc_check_item_ ();
13356 ffestd_V018_item (expr);
13359 /* ffestc_V018_finish -- REWRITE statement list complete
13361 ffestc_V018_finish();
13363 Just wrap up any local activities. */
13366 ffestc_V018_finish ()
13368 ffestc_check_finish_ ();
13372 ffestd_V018_finish ();
13374 if (ffestc_shriek_after1_ != NULL)
13375 (*ffestc_shriek_after1_) (TRUE);
13376 ffestc_labeldef_branch_end_ ();
13379 /* ffestc_V019_start -- ACCEPT statement list begin
13381 ffestc_V019_start();
13383 Verify that ACCEPT is valid here, and begin accepting items in the
13387 ffestc_V019_start ()
13389 ffestvFormat format;
13391 ffestc_check_start_ ();
13392 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
13394 ffestc_ok_ = FALSE;
13397 ffestc_labeldef_branch_begin_ ();
13399 if (!ffestc_subr_is_format_
13400 (&ffestp_file.accept.accept_spec[FFESTP_acceptixFORMAT]))
13402 ffestc_ok_ = FALSE;
13406 format = ffestc_subr_format_
13407 (&ffestp_file.accept.accept_spec[FFESTP_acceptixFORMAT]);
13408 ffestc_namelist_ = (format == FFESTV_formatNAMELIST);
13410 ffestd_V019_start (format);
13415 /* ffestc_V019_item -- ACCEPT statement i/o item
13417 ffestc_V019_item(expr,expr_token);
13419 Implement output-list expression. */
13422 ffestc_V019_item (ffebld expr, ffelexToken expr_token)
13424 ffestc_check_item_ ();
13428 if (ffestc_namelist_ != 0)
13430 if (ffestc_namelist_ == 1)
13432 ffestc_namelist_ = 2;
13433 ffebad_start (FFEBAD_NAMELIST_ITEMS);
13434 ffebad_here (0, ffelex_token_where_line (expr_token),
13435 ffelex_token_where_column (expr_token));
13441 ffestd_V019_item (expr);
13444 /* ffestc_V019_finish -- ACCEPT statement list complete
13446 ffestc_V019_finish();
13448 Just wrap up any local activities. */
13451 ffestc_V019_finish ()
13453 ffestc_check_finish_ ();
13457 ffestd_V019_finish ();
13459 if (ffestc_shriek_after1_ != NULL)
13460 (*ffestc_shriek_after1_) (TRUE);
13461 ffestc_labeldef_branch_end_ ();
13465 /* ffestc_V020_start -- TYPE statement list begin
13467 ffestc_V020_start();
13469 Verify that TYPE is valid here, and begin accepting items in the
13473 ffestc_V020_start ()
13475 ffestvFormat format;
13477 ffestc_check_start_ ();
13478 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
13480 ffestc_ok_ = FALSE;
13483 ffestc_labeldef_branch_begin_ ();
13485 if (!ffestc_subr_is_format_
13486 (&ffestp_file.type.type_spec[FFESTP_typeixFORMAT]))
13488 ffestc_ok_ = FALSE;
13492 format = ffestc_subr_format_
13493 (&ffestp_file.type.type_spec[FFESTP_typeixFORMAT]);
13494 ffestc_namelist_ = (format == FFESTV_formatNAMELIST);
13496 ffestd_V020_start (format);
13501 /* ffestc_V020_item -- TYPE statement i/o item
13503 ffestc_V020_item(expr,expr_token);
13505 Implement output-list expression. */
13508 ffestc_V020_item (ffebld expr, ffelexToken expr_token)
13510 ffestc_check_item_ ();
13514 if (ffestc_namelist_ != 0)
13516 if (ffestc_namelist_ == 1)
13518 ffestc_namelist_ = 2;
13519 ffebad_start (FFEBAD_NAMELIST_ITEMS);
13520 ffebad_here (0, ffelex_token_where_line (expr_token),
13521 ffelex_token_where_column (expr_token));
13527 ffestd_V020_item (expr);
13530 /* ffestc_V020_finish -- TYPE statement list complete
13532 ffestc_V020_finish();
13534 Just wrap up any local activities. */
13537 ffestc_V020_finish ()
13539 ffestc_check_finish_ ();
13543 ffestd_V020_finish ();
13545 if (ffestc_shriek_after1_ != NULL)
13546 (*ffestc_shriek_after1_) (TRUE);
13547 ffestc_labeldef_branch_end_ ();
13550 /* ffestc_V021 -- DELETE statement
13554 Make sure a DELETE is valid in the current context, and implement it. */
13560 ffestc_check_simple_ ();
13561 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
13563 ffestc_labeldef_branch_begin_ ();
13565 if (ffestc_subr_is_branch_
13566 (&ffestp_file.delete.delete_spec[FFESTP_deleteixERR])
13567 && ffestc_subr_is_present_ ("UNIT",
13568 &ffestp_file.delete.delete_spec[FFESTP_deleteixUNIT]))
13571 if (ffestc_shriek_after1_ != NULL)
13572 (*ffestc_shriek_after1_) (TRUE);
13573 ffestc_labeldef_branch_end_ ();
13576 /* ffestc_V022 -- UNLOCK statement
13580 Make sure a UNLOCK is valid in the current context, and implement it. */
13585 ffestc_check_simple_ ();
13586 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
13588 ffestc_labeldef_branch_begin_ ();
13590 if (ffestc_subr_is_branch_
13591 (&ffestp_file.beru.beru_spec[FFESTP_beruixERR])
13592 && ffestc_subr_is_present_ ("UNIT",
13593 &ffestp_file.beru.beru_spec[FFESTP_beruixUNIT]))
13596 if (ffestc_shriek_after1_ != NULL)
13597 (*ffestc_shriek_after1_) (TRUE);
13598 ffestc_labeldef_branch_end_ ();
13601 /* ffestc_V023_start -- ENCODE(...) statement list begin
13603 ffestc_V023_start();
13605 Verify that ENCODE is valid here, and begin accepting items in the
13609 ffestc_V023_start ()
13611 ffestc_check_start_ ();
13612 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
13614 ffestc_ok_ = FALSE;
13617 ffestc_labeldef_branch_begin_ ();
13619 if (!ffestc_subr_is_branch_
13620 (&ffestp_file.vxtcode.vxtcode_spec[FFESTP_vxtcodeixERR]))
13622 ffestc_ok_ = FALSE;
13626 ffestd_V023_start ();
13631 /* ffestc_V023_item -- ENCODE statement i/o item
13633 ffestc_V023_item(expr,expr_token);
13635 Implement output-list expression. */
13638 ffestc_V023_item (ffebld expr, ffelexToken expr_token)
13640 ffestc_check_item_ ();
13644 ffestd_V023_item (expr);
13647 /* ffestc_V023_finish -- ENCODE statement list complete
13649 ffestc_V023_finish();
13651 Just wrap up any local activities. */
13654 ffestc_V023_finish ()
13656 ffestc_check_finish_ ();
13660 ffestd_V023_finish ();
13662 if (ffestc_shriek_after1_ != NULL)
13663 (*ffestc_shriek_after1_) (TRUE);
13664 ffestc_labeldef_branch_end_ ();
13667 /* ffestc_V024_start -- DECODE(...) statement list begin
13669 ffestc_V024_start();
13671 Verify that DECODE is valid here, and begin accepting items in the
13675 ffestc_V024_start ()
13677 ffestc_check_start_ ();
13678 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
13680 ffestc_ok_ = FALSE;
13683 ffestc_labeldef_branch_begin_ ();
13685 if (!ffestc_subr_is_branch_
13686 (&ffestp_file.vxtcode.vxtcode_spec[FFESTP_vxtcodeixERR]))
13688 ffestc_ok_ = FALSE;
13692 ffestd_V024_start ();
13697 /* ffestc_V024_item -- DECODE statement i/o item
13699 ffestc_V024_item(expr,expr_token);
13701 Implement output-list expression. */
13704 ffestc_V024_item (ffebld expr, ffelexToken expr_token)
13706 ffestc_check_item_ ();
13710 ffestd_V024_item (expr);
13713 /* ffestc_V024_finish -- DECODE statement list complete
13715 ffestc_V024_finish();
13717 Just wrap up any local activities. */
13720 ffestc_V024_finish ()
13722 ffestc_check_finish_ ();
13726 ffestd_V024_finish ();
13728 if (ffestc_shriek_after1_ != NULL)
13729 (*ffestc_shriek_after1_) (TRUE);
13730 ffestc_labeldef_branch_end_ ();
13733 /* ffestc_V025_start -- DEFINEFILE statement list begin
13735 ffestc_V025_start();
13737 Verify that DEFINEFILE is valid here, and begin accepting items in the
13741 ffestc_V025_start ()
13743 ffestc_check_start_ ();
13744 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
13746 ffestc_ok_ = FALSE;
13749 ffestc_labeldef_branch_begin_ ();
13751 ffestd_V025_start ();
13756 /* ffestc_V025_item -- DEFINE FILE statement item
13758 ffestc_V025_item(u,ut,m,mt,n,nt,asv,asvt);
13763 ffestc_V025_item (ffebld u, ffelexToken ut, ffebld m, ffelexToken mt,
13764 ffebld n, ffelexToken nt, ffebld asv, ffelexToken asvt)
13766 ffestc_check_item_ ();
13770 ffestd_V025_item (u, m, n, asv);
13773 /* ffestc_V025_finish -- DEFINE FILE statement list complete
13775 ffestc_V025_finish();
13777 Just wrap up any local activities. */
13780 ffestc_V025_finish ()
13782 ffestc_check_finish_ ();
13786 ffestd_V025_finish ();
13788 if (ffestc_shriek_after1_ != NULL)
13789 (*ffestc_shriek_after1_) (TRUE);
13790 ffestc_labeldef_branch_end_ ();
13793 /* ffestc_V026 -- FIND statement
13797 Make sure a FIND is valid in the current context, and implement it. */
13802 ffestc_check_simple_ ();
13803 if (ffestc_order_actionif_ () != FFESTC_orderOK_)
13805 ffestc_labeldef_branch_begin_ ();
13807 if (ffestc_subr_is_branch_
13808 (&ffestp_file.find.find_spec[FFESTP_findixERR])
13809 && ffestc_subr_is_present_ ("UNIT",
13810 &ffestp_file.find.find_spec[FFESTP_findixUNIT])
13811 && ffestc_subr_is_present_ ("REC",
13812 &ffestp_file.find.find_spec[FFESTP_findixREC]))
13815 if (ffestc_shriek_after1_ != NULL)
13816 (*ffestc_shriek_after1_) (TRUE);
13817 ffestc_labeldef_branch_end_ ();
13821 /* ffestc_V027_start -- VXT PARAMETER statement list begin
13823 ffestc_V027_start();
13825 Verify that PARAMETER is valid here, and begin accepting items in the list. */
13828 ffestc_V027_start ()
13830 ffestc_check_start_ ();
13831 if (ffestc_order_parameter_ () != FFESTC_orderOK_)
13833 ffestc_ok_ = FALSE;
13836 ffestc_labeldef_useless_ ();
13838 ffestd_V027_start ();
13843 /* ffestc_V027_item -- VXT PARAMETER statement assignment
13845 ffestc_V027_item(dest,dest_token,source,source_token);
13847 Make sure the source is a valid source for the destination; make the
13851 ffestc_V027_item (ffelexToken dest_token, ffebld source,
13852 ffelexToken source_token UNUSED)
13854 ffestc_check_item_ ();
13858 ffestd_V027_item (dest_token, source);
13861 /* ffestc_V027_finish -- VXT PARAMETER statement list complete
13863 ffestc_V027_finish();
13865 Just wrap up any local activities. */
13868 ffestc_V027_finish ()
13870 ffestc_check_finish_ ();
13874 ffestd_V027_finish ();
13877 /* Any executable statement. Mainly make sure that one-shot things
13878 like the statement for a logical IF are reset. */
13883 ffestc_check_simple_ ();
13885 ffestc_order_any_ ();
13887 ffestc_labeldef_any_ ();
13889 if (ffestc_shriek_after1_ == NULL)
13894 (*ffestc_shriek_after1_) (TRUE);