1 /* Deal with I/O statements & related stuff.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
4 Contributed by Andy Vaught
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
30 gfc_st_label format_asterisk =
31 {0, NULL, NULL, -1, ST_LABEL_FORMAT, ST_LABEL_FORMAT, NULL,
36 const char *name, *spec;
42 tag_file = { "FILE", " file = %e", BT_CHARACTER },
43 tag_status = { "STATUS", " status = %e", BT_CHARACTER},
44 tag_e_access = {"ACCESS", " access = %e", BT_CHARACTER},
45 tag_e_form = {"FORM", " form = %e", BT_CHARACTER},
46 tag_e_recl = {"RECL", " recl = %e", BT_INTEGER},
47 tag_e_blank = {"BLANK", " blank = %e", BT_CHARACTER},
48 tag_e_position = {"POSITION", " position = %e", BT_CHARACTER},
49 tag_e_action = {"ACTION", " action = %e", BT_CHARACTER},
50 tag_e_delim = {"DELIM", " delim = %e", BT_CHARACTER},
51 tag_e_pad = {"PAD", " pad = %e", BT_CHARACTER},
52 tag_unit = {"UNIT", " unit = %e", BT_INTEGER},
53 tag_advance = {"ADVANCE", " advance = %e", BT_CHARACTER},
54 tag_rec = {"REC", " rec = %e", BT_INTEGER},
55 tag_format = {"FORMAT", NULL, BT_CHARACTER},
56 tag_iomsg = {"IOMSG", " iomsg = %e", BT_CHARACTER},
57 tag_iostat = {"IOSTAT", " iostat = %v", BT_INTEGER},
58 tag_size = {"SIZE", " size = %v", BT_INTEGER},
59 tag_exist = {"EXIST", " exist = %v", BT_LOGICAL},
60 tag_opened = {"OPENED", " opened = %v", BT_LOGICAL},
61 tag_named = {"NAMED", " named = %v", BT_LOGICAL},
62 tag_name = {"NAME", " name = %v", BT_CHARACTER},
63 tag_number = {"NUMBER", " number = %v", BT_INTEGER},
64 tag_s_access = {"ACCESS", " access = %v", BT_CHARACTER},
65 tag_sequential = {"SEQUENTIAL", " sequential = %v", BT_CHARACTER},
66 tag_direct = {"DIRECT", " direct = %v", BT_CHARACTER},
67 tag_s_form = {"FORM", " form = %v", BT_CHARACTER},
68 tag_formatted = {"FORMATTED", " formatted = %v", BT_CHARACTER},
69 tag_unformatted = {"UNFORMATTED", " unformatted = %v", BT_CHARACTER},
70 tag_s_recl = {"RECL", " recl = %v", BT_INTEGER},
71 tag_nextrec = {"NEXTREC", " nextrec = %v", BT_INTEGER},
72 tag_s_blank = {"BLANK", " blank = %v", BT_CHARACTER},
73 tag_s_position = {"POSITION", " position = %v", BT_CHARACTER},
74 tag_s_action = {"ACTION", " action = %v", BT_CHARACTER},
75 tag_read = {"READ", " read = %v", BT_CHARACTER},
76 tag_write = {"WRITE", " write = %v", BT_CHARACTER},
77 tag_readwrite = {"READWRITE", " readwrite = %v", BT_CHARACTER},
78 tag_s_delim = {"DELIM", " delim = %v", BT_CHARACTER},
79 tag_s_pad = {"PAD", " pad = %v", BT_CHARACTER},
80 tag_iolength = {"IOLENGTH", " iolength = %v", BT_INTEGER},
81 tag_convert = {"CONVERT", " convert = %e", BT_CHARACTER},
82 tag_err = {"ERR", " err = %l", BT_UNKNOWN},
83 tag_end = {"END", " end = %l", BT_UNKNOWN},
84 tag_eor = {"EOR", " eor = %l", BT_UNKNOWN};
86 static gfc_dt *current_dt;
88 #define RESOLVE_TAG(x, y) if (resolve_tag(x, y) == FAILURE) return FAILURE;
91 /**************** Fortran 95 FORMAT parser *****************/
93 /* FORMAT tokens returned by format_lex(). */
96 FMT_NONE, FMT_UNKNOWN, FMT_SIGNED_INT, FMT_ZERO, FMT_POSINT, FMT_PERIOD,
97 FMT_COMMA, FMT_COLON, FMT_SLASH, FMT_DOLLAR, FMT_POS, FMT_LPAREN,
98 FMT_RPAREN, FMT_X, FMT_SIGN, FMT_BLANK, FMT_CHAR, FMT_P, FMT_IBOZ, FMT_F,
99 FMT_E, FMT_EXT, FMT_G, FMT_L, FMT_A, FMT_D, FMT_H, FMT_END
103 /* Local variables for checking format strings. The saved_token is
104 used to back up by a single format token during the parsing
106 static char *format_string;
107 static int format_length, use_last_char;
109 static format_token saved_token;
112 { MODE_STRING, MODE_FORMAT, MODE_COPY }
116 /* Return the next character in the format string. */
119 next_char (int in_string)
131 if (mode == MODE_STRING)
132 c = *format_string++;
135 c = gfc_next_char_literal (in_string);
139 if (mode == MODE_COPY)
140 *format_string++ = c;
148 /* Back up one character position. Only works once. */
157 /* Eat up the spaces and return a character. */
160 next_char_not_space(void)
167 while (gfc_is_whitespace (c));
171 static int value = 0;
173 /* Simple lexical analyzer for getting the next token in a FORMAT
184 if (saved_token != FMT_NONE)
187 saved_token = FMT_NONE;
191 c = next_char_not_space ();
199 c = next_char_not_space ();
210 c = next_char_not_space ();
212 value = 10 * value + c - '0';
221 token = FMT_SIGNED_INT;
240 c = next_char_not_space ();
244 value = 10 * value + c - '0';
249 token = zflag ? FMT_ZERO : FMT_POSINT;
273 c = next_char_not_space ();
274 if (c != 'L' && c != 'R')
293 c = next_char_not_space ();
294 if (c != 'P' && c != 'S')
301 c = next_char_not_space ();
302 if (c == 'N' || c == 'Z')
363 c = next_char_not_space ();
364 if (c == 'N' || c == 'S')
407 /* Check a format statement. The format string, either from a FORMAT
408 statement or a constant in an I/O statement has already been parsed
409 by itself, and we are checking it for validity. The dual origin
410 means that the warning message is a little less than great. */
415 const char *posint_required = _("Positive width required");
416 const char *period_required = _("Period required");
417 const char *nonneg_required = _("Nonnegative width required");
418 const char *unexpected_element = _("Unexpected element");
419 const char *unexpected_end = _("Unexpected end of format string");
428 saved_token = FMT_NONE;
436 error = _("Missing leading left parenthesis");
442 goto finished; /* Empty format is legal */
446 /* In this state, the next thing has to be a format item. */
470 /* Signed integer can only precede a P format. */
474 error = _("Expected P edit descriptor");
481 /* P requires a prior number. */
482 error = _("P descriptor requires leading scale factor");
486 /* X requires a prior number if we're being pedantic. */
487 if (gfc_notify_std (GFC_STD_GNU, "Extension: X descriptor "
488 "requires leading space count at %C")
498 goto extension_optional_comma;
507 if (gfc_notify_std (GFC_STD_GNU, "Extension: $ descriptor at %C")
510 if (t != FMT_RPAREN || level > 0)
512 error = _("$ must be the last specifier");
533 error = unexpected_end;
537 error = unexpected_element;
542 /* In this state, t must currently be a data descriptor.
543 Deal with things that can/must follow the descriptor. */
557 error = _("Repeat count cannot follow P descriptor");
572 error = posint_required;
588 error = posint_required;
595 error = period_required;
600 if (u != FMT_ZERO && u != FMT_POSINT)
602 error = nonneg_required;
609 /* Look for optional exponent. */
620 error = _("Positive exponent width required");
629 if (t != FMT_ZERO && t != FMT_POSINT)
631 error = nonneg_required;
638 error = period_required;
643 if (t != FMT_ZERO && t != FMT_POSINT)
645 error = nonneg_required;
652 if(mode == MODE_STRING)
654 format_string += value;
655 format_length -= value;
669 if (t != FMT_ZERO && t != FMT_POSINT)
671 error = nonneg_required;
683 if (t != FMT_ZERO && t != FMT_POSINT)
685 error = nonneg_required;
693 error = unexpected_element;
698 /* Between a descriptor and what comes next. */
717 error = unexpected_end;
721 if (gfc_notify_std (GFC_STD_GNU, "Extension: Missing comma at %C")
728 /* Optional comma is a weird between state where we've just finished
729 reading a colon, slash or P descriptor. */
743 /* Assume that we have another format item. */
750 extension_optional_comma:
751 /* As a GNU extension, permit a missing comma after a string literal. */
769 error = unexpected_end;
773 if (gfc_notify_std (GFC_STD_GNU, "Extension: Missing comma at %C")
783 /* Something went wrong. If the format we're checking is a string,
784 generate a warning, since the program is correct. If the format
785 is in a FORMAT statement, this messes up parsing, which is an
787 if (mode != MODE_STRING)
788 gfc_error ("%s in format string at %C", error);
791 gfc_warning ("%s in format string at %C", error);
793 /* TODO: More elaborate measures are needed to show where a problem
794 is within a format string that has been calculated. */
804 /* Given an expression node that is a constant string, see if it looks
805 like a format string. */
808 check_format_string (gfc_expr * e)
812 format_string = e->value.character.string;
817 /************ Fortran 95 I/O statement matchers *************/
819 /* Match a FORMAT statement. This amounts to actually parsing the
820 format descriptors in order to correctly locate the end of the
824 gfc_match_format (void)
829 if (gfc_current_ns->proc_name
830 && gfc_current_ns->proc_name->attr.flavor == FL_MODULE)
832 gfc_error ("Format statement in module main block at %C.");
836 if (gfc_statement_label == NULL)
838 gfc_error ("Missing format label at %C");
841 gfc_gobble_whitespace ();
846 start = gfc_current_locus;
848 if (check_format () == FAILURE)
851 if (gfc_match_eos () != MATCH_YES)
853 gfc_syntax_error (ST_FORMAT);
857 /* The label doesn't get created until after the statement is done
858 being matched, so we have to leave the string for later. */
860 gfc_current_locus = start; /* Back to the beginning */
863 new_st.op = EXEC_NOP;
866 e->expr_type = EXPR_CONSTANT;
867 e->ts.type = BT_CHARACTER;
868 e->ts.kind = gfc_default_character_kind;
870 e->value.character.string = format_string = gfc_getmem(format_length+1);
871 e->value.character.length = format_length;
872 gfc_statement_label->format = e;
875 check_format (); /* Guaranteed to succeed */
876 gfc_match_eos (); /* Guaranteed to succeed */
882 /* Match an expression I/O tag of some sort. */
885 match_etag (const io_tag * tag, gfc_expr ** v)
890 m = gfc_match (tag->spec, &result);
896 gfc_error ("Duplicate %s specification at %C", tag->name);
897 gfc_free_expr (result);
906 /* Match a variable I/O tag of some sort. */
909 match_vtag (const io_tag * tag, gfc_expr ** v)
914 m = gfc_match (tag->spec, &result);
920 gfc_error ("Duplicate %s specification at %C", tag->name);
921 gfc_free_expr (result);
925 if (result->symtree->n.sym->attr.intent == INTENT_IN)
927 gfc_error ("Variable tag cannot be INTENT(IN) at %C");
928 gfc_free_expr (result);
932 if (gfc_pure (NULL) && gfc_impure_variable (result->symtree->n.sym))
934 gfc_error ("Variable tag cannot be assigned in PURE procedure at %C");
935 gfc_free_expr (result);
944 /* Match I/O tags that cause variables to become redefined. */
947 match_out_tag(const io_tag *tag, gfc_expr **result)
951 m = match_vtag(tag, result);
953 gfc_check_do_variable((*result)->symtree);
959 /* Match a label I/O tag. */
962 match_ltag (const io_tag * tag, gfc_st_label ** label)
968 m = gfc_match (tag->spec, label);
969 if (m == MATCH_YES && old != 0)
971 gfc_error ("Duplicate %s label specification at %C", tag->name);
979 /* Do expression resolution and type-checking on an expression tag. */
982 resolve_tag (const io_tag * tag, gfc_expr * e)
988 if (gfc_resolve_expr (e) == FAILURE)
991 if (e->ts.type != tag->type && tag != &tag_format)
993 gfc_error ("%s tag at %L must be of type %s", tag->name,
994 &e->where, gfc_basic_typename (tag->type));
998 if (tag == &tag_format)
1000 if (e->expr_type == EXPR_CONSTANT
1001 && (e->ts.type != BT_CHARACTER
1002 || e->ts.kind != gfc_default_character_kind))
1004 gfc_error ("Constant expression in FORMAT tag at %L must be "
1005 "of type default CHARACTER", &e->where);
1009 /* If e's rank is zero and e is not an element of an array, it should be
1010 of integer or character type. The integer variable should be
1012 if (e->symtree == NULL || e->symtree->n.sym->as == NULL
1013 || e->symtree->n.sym->as->rank == 0)
1015 if (e->ts.type != BT_CHARACTER && e->ts.type != BT_INTEGER)
1017 gfc_error ("%s tag at %L must be of type %s or %s", tag->name,
1018 &e->where, gfc_basic_typename (BT_CHARACTER),
1019 gfc_basic_typename (BT_INTEGER));
1022 else if (e->ts.type == BT_INTEGER && e->expr_type == EXPR_VARIABLE)
1024 if (gfc_notify_std (GFC_STD_F95_DEL,
1025 "Obsolete: ASSIGNED variable in FORMAT tag at %L",
1026 &e->where) == FAILURE)
1028 if (e->symtree->n.sym->attr.assign != 1)
1030 gfc_error ("Variable '%s' at %L has not been assigned a "
1031 "format label", e->symtree->n.sym->name, &e->where);
1039 /* if rank is nonzero, we allow the type to be character under
1040 GFC_STD_GNU and other type under GFC_STD_LEGACY. It may be
1041 assigned an Hollerith constant. */
1042 if (e->ts.type == BT_CHARACTER)
1044 if (gfc_notify_std (GFC_STD_GNU,
1045 "Extension: Character array in FORMAT tag at %L",
1046 &e->where) == FAILURE)
1051 if (gfc_notify_std (GFC_STD_LEGACY,
1052 "Extension: Non-character in FORMAT tag at %L",
1053 &e->where) == FAILURE)
1063 gfc_error ("%s tag at %L must be scalar", tag->name, &e->where);
1067 if (tag == &tag_iomsg)
1069 if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: IOMSG tag at %L",
1070 &e->where) == FAILURE)
1074 if (tag == &tag_iostat && e->ts.kind != gfc_default_integer_kind)
1076 if (gfc_notify_std (GFC_STD_GNU, "Fortran 95 requires default "
1077 "INTEGER in IOSTAT tag at %L",
1078 &e->where) == FAILURE)
1082 if (tag == &tag_size && e->ts.kind != gfc_default_integer_kind)
1084 if (gfc_notify_std (GFC_STD_GNU, "Fortran 95 requires default "
1085 "INTEGER in SIZE tag at %L",
1086 &e->where) == FAILURE)
1090 if (tag == &tag_convert)
1092 if (gfc_notify_std (GFC_STD_GNU, "Extension: CONVERT tag at %L",
1093 &e->where) == FAILURE)
1102 /* Match a single tag of an OPEN statement. */
1105 match_open_element (gfc_open * open)
1109 m = match_etag (&tag_unit, &open->unit);
1112 m = match_out_tag (&tag_iomsg, &open->iomsg);
1115 m = match_out_tag (&tag_iostat, &open->iostat);
1118 m = match_etag (&tag_file, &open->file);
1121 m = match_etag (&tag_status, &open->status);
1124 m = match_etag (&tag_e_access, &open->access);
1127 m = match_etag (&tag_e_form, &open->form);
1130 m = match_etag (&tag_e_recl, &open->recl);
1133 m = match_etag (&tag_e_blank, &open->blank);
1136 m = match_etag (&tag_e_position, &open->position);
1139 m = match_etag (&tag_e_action, &open->action);
1142 m = match_etag (&tag_e_delim, &open->delim);
1145 m = match_etag (&tag_e_pad, &open->pad);
1148 m = match_ltag (&tag_err, &open->err);
1151 m = match_etag (&tag_convert, &open->convert);
1159 /* Free the gfc_open structure and all the expressions it contains. */
1162 gfc_free_open (gfc_open * open)
1168 gfc_free_expr (open->unit);
1169 gfc_free_expr (open->iomsg);
1170 gfc_free_expr (open->iostat);
1171 gfc_free_expr (open->file);
1172 gfc_free_expr (open->status);
1173 gfc_free_expr (open->access);
1174 gfc_free_expr (open->form);
1175 gfc_free_expr (open->recl);
1176 gfc_free_expr (open->blank);
1177 gfc_free_expr (open->position);
1178 gfc_free_expr (open->action);
1179 gfc_free_expr (open->delim);
1180 gfc_free_expr (open->pad);
1181 gfc_free_expr (open->convert);
1187 /* Resolve everything in a gfc_open structure. */
1190 gfc_resolve_open (gfc_open * open)
1193 RESOLVE_TAG (&tag_unit, open->unit);
1194 RESOLVE_TAG (&tag_iomsg, open->iomsg);
1195 RESOLVE_TAG (&tag_iostat, open->iostat);
1196 RESOLVE_TAG (&tag_file, open->file);
1197 RESOLVE_TAG (&tag_status, open->status);
1198 RESOLVE_TAG (&tag_e_access, open->access);
1199 RESOLVE_TAG (&tag_e_form, open->form);
1200 RESOLVE_TAG (&tag_e_recl, open->recl);
1202 RESOLVE_TAG (&tag_e_blank, open->blank);
1203 RESOLVE_TAG (&tag_e_position, open->position);
1204 RESOLVE_TAG (&tag_e_action, open->action);
1205 RESOLVE_TAG (&tag_e_delim, open->delim);
1206 RESOLVE_TAG (&tag_e_pad, open->pad);
1207 RESOLVE_TAG (&tag_convert, open->convert);
1209 if (gfc_reference_st_label (open->err, ST_LABEL_TARGET) == FAILURE)
1216 /* Match an OPEN statement. */
1219 gfc_match_open (void)
1224 m = gfc_match_char ('(');
1228 open = gfc_getmem (sizeof (gfc_open));
1230 m = match_open_element (open);
1232 if (m == MATCH_ERROR)
1236 m = gfc_match_expr (&open->unit);
1239 if (m == MATCH_ERROR)
1245 if (gfc_match_char (')') == MATCH_YES)
1247 if (gfc_match_char (',') != MATCH_YES)
1250 m = match_open_element (open);
1251 if (m == MATCH_ERROR)
1257 if (gfc_match_eos () == MATCH_NO)
1260 if (gfc_pure (NULL))
1262 gfc_error ("OPEN statement not allowed in PURE procedure at %C");
1266 new_st.op = EXEC_OPEN;
1267 new_st.ext.open = open;
1271 gfc_syntax_error (ST_OPEN);
1274 gfc_free_open (open);
1279 /* Free a gfc_close structure an all its expressions. */
1282 gfc_free_close (gfc_close * close)
1288 gfc_free_expr (close->unit);
1289 gfc_free_expr (close->iomsg);
1290 gfc_free_expr (close->iostat);
1291 gfc_free_expr (close->status);
1297 /* Match elements of a CLOSE statement. */
1300 match_close_element (gfc_close * close)
1304 m = match_etag (&tag_unit, &close->unit);
1307 m = match_etag (&tag_status, &close->status);
1310 m = match_out_tag (&tag_iomsg, &close->iomsg);
1313 m = match_out_tag (&tag_iostat, &close->iostat);
1316 m = match_ltag (&tag_err, &close->err);
1324 /* Match a CLOSE statement. */
1327 gfc_match_close (void)
1332 m = gfc_match_char ('(');
1336 close = gfc_getmem (sizeof (gfc_close));
1338 m = match_close_element (close);
1340 if (m == MATCH_ERROR)
1344 m = gfc_match_expr (&close->unit);
1347 if (m == MATCH_ERROR)
1353 if (gfc_match_char (')') == MATCH_YES)
1355 if (gfc_match_char (',') != MATCH_YES)
1358 m = match_close_element (close);
1359 if (m == MATCH_ERROR)
1365 if (gfc_match_eos () == MATCH_NO)
1368 if (gfc_pure (NULL))
1370 gfc_error ("CLOSE statement not allowed in PURE procedure at %C");
1374 new_st.op = EXEC_CLOSE;
1375 new_st.ext.close = close;
1379 gfc_syntax_error (ST_CLOSE);
1382 gfc_free_close (close);
1387 /* Resolve everything in a gfc_close structure. */
1390 gfc_resolve_close (gfc_close * close)
1393 RESOLVE_TAG (&tag_unit, close->unit);
1394 RESOLVE_TAG (&tag_iomsg, close->iomsg);
1395 RESOLVE_TAG (&tag_iostat, close->iostat);
1396 RESOLVE_TAG (&tag_status, close->status);
1398 if (gfc_reference_st_label (close->err, ST_LABEL_TARGET) == FAILURE)
1405 /* Free a gfc_filepos structure. */
1408 gfc_free_filepos (gfc_filepos * fp)
1411 gfc_free_expr (fp->unit);
1412 gfc_free_expr (fp->iomsg);
1413 gfc_free_expr (fp->iostat);
1418 /* Match elements of a REWIND, BACKSPACE, ENDFILE, or FLUSH statement. */
1421 match_file_element (gfc_filepos * fp)
1425 m = match_etag (&tag_unit, &fp->unit);
1428 m = match_out_tag (&tag_iomsg, &fp->iomsg);
1431 m = match_out_tag (&tag_iostat, &fp->iostat);
1434 m = match_ltag (&tag_err, &fp->err);
1442 /* Match the second half of the file-positioning statements, REWIND,
1443 BACKSPACE, ENDFILE, or the FLUSH statement. */
1446 match_filepos (gfc_statement st, gfc_exec_op op)
1451 fp = gfc_getmem (sizeof (gfc_filepos));
1453 if (gfc_match_char ('(') == MATCH_NO)
1455 m = gfc_match_expr (&fp->unit);
1456 if (m == MATCH_ERROR)
1464 m = match_file_element (fp);
1465 if (m == MATCH_ERROR)
1469 m = gfc_match_expr (&fp->unit);
1470 if (m == MATCH_ERROR)
1478 if (gfc_match_char (')') == MATCH_YES)
1480 if (gfc_match_char (',') != MATCH_YES)
1483 m = match_file_element (fp);
1484 if (m == MATCH_ERROR)
1491 if (gfc_match_eos () != MATCH_YES)
1494 if (gfc_pure (NULL))
1496 gfc_error ("%s statement not allowed in PURE procedure at %C",
1497 gfc_ascii_statement (st));
1503 new_st.ext.filepos = fp;
1507 gfc_syntax_error (st);
1510 gfc_free_filepos (fp);
1516 gfc_resolve_filepos (gfc_filepos * fp)
1519 RESOLVE_TAG (&tag_unit, fp->unit);
1520 RESOLVE_TAG (&tag_iostat, fp->iostat);
1521 RESOLVE_TAG (&tag_iomsg, fp->iomsg);
1522 if (gfc_reference_st_label (fp->err, ST_LABEL_TARGET) == FAILURE)
1529 /* Match the file positioning statements: ENDFILE, BACKSPACE, REWIND,
1530 and the FLUSH statement. */
1533 gfc_match_endfile (void)
1536 return match_filepos (ST_END_FILE, EXEC_ENDFILE);
1540 gfc_match_backspace (void)
1543 return match_filepos (ST_BACKSPACE, EXEC_BACKSPACE);
1547 gfc_match_rewind (void)
1550 return match_filepos (ST_REWIND, EXEC_REWIND);
1554 gfc_match_flush (void)
1556 if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: FLUSH statement at %C") == FAILURE)
1559 return match_filepos (ST_FLUSH, EXEC_FLUSH);
1562 /******************** Data Transfer Statements *********************/
1565 { M_READ, M_WRITE, M_PRINT, M_INQUIRE }
1569 /* Return a default unit number. */
1572 default_unit (io_kind k)
1581 return gfc_int_expr (unit);
1585 /* Match a unit specification for a data transfer statement. */
1588 match_dt_unit (io_kind k, gfc_dt * dt)
1592 if (gfc_match_char ('*') == MATCH_YES)
1594 if (dt->io_unit != NULL)
1597 dt->io_unit = default_unit (k);
1601 if (gfc_match_expr (&e) == MATCH_YES)
1603 if (dt->io_unit != NULL)
1616 gfc_error ("Duplicate UNIT specification at %C");
1621 /* Match a format specification. */
1624 match_dt_format (gfc_dt * dt)
1628 gfc_st_label *label;
1630 where = gfc_current_locus;
1632 if (gfc_match_char ('*') == MATCH_YES)
1634 if (dt->format_expr != NULL || dt->format_label != NULL)
1637 dt->format_label = &format_asterisk;
1641 if (gfc_match_st_label (&label) == MATCH_YES)
1643 if (dt->format_expr != NULL || dt->format_label != NULL)
1645 gfc_free_st_label (label);
1649 if (gfc_reference_st_label (label, ST_LABEL_FORMAT) == FAILURE)
1652 dt->format_label = label;
1656 if (gfc_match_expr (&e) == MATCH_YES)
1658 if (dt->format_expr != NULL || dt->format_label != NULL)
1663 dt->format_expr = e;
1667 gfc_current_locus = where; /* The only case where we have to restore */
1672 gfc_error ("Duplicate format specification at %C");
1677 /* Traverse a namelist that is part of a READ statement to make sure
1678 that none of the variables in the namelist are INTENT(IN). Returns
1679 nonzero if we find such a variable. */
1682 check_namelist (gfc_symbol * sym)
1686 for (p = sym->namelist; p; p = p->next)
1687 if (p->sym->attr.intent == INTENT_IN)
1689 gfc_error ("Symbol '%s' in namelist '%s' is INTENT(IN) at %C",
1690 p->sym->name, sym->name);
1698 /* Match a single data transfer element. */
1701 match_dt_element (io_kind k, gfc_dt * dt)
1703 char name[GFC_MAX_SYMBOL_LEN + 1];
1707 if (gfc_match (" unit =") == MATCH_YES)
1709 m = match_dt_unit (k, dt);
1714 if (gfc_match (" fmt =") == MATCH_YES)
1716 m = match_dt_format (dt);
1721 if (gfc_match (" nml = %n", name) == MATCH_YES)
1723 if (dt->namelist != NULL)
1725 gfc_error ("Duplicate NML specification at %C");
1729 if (gfc_find_symbol (name, NULL, 1, &sym))
1732 if (sym == NULL || sym->attr.flavor != FL_NAMELIST)
1734 gfc_error ("Symbol '%s' at %C must be a NAMELIST group name",
1735 sym != NULL ? sym->name : name);
1740 if (k == M_READ && check_namelist (sym))
1746 m = match_etag (&tag_rec, &dt->rec);
1749 m = match_out_tag (&tag_iomsg, &dt->iomsg);
1752 m = match_out_tag (&tag_iostat, &dt->iostat);
1755 m = match_ltag (&tag_err, &dt->err);
1757 dt->err_where = gfc_current_locus;
1760 m = match_etag (&tag_advance, &dt->advance);
1763 m = match_out_tag (&tag_size, &dt->size);
1767 m = match_ltag (&tag_end, &dt->end);
1772 gfc_error ("END tag at %C not allowed in output statement");
1775 dt->end_where = gfc_current_locus;
1780 m = match_ltag (&tag_eor, &dt->eor);
1782 dt->eor_where = gfc_current_locus;
1790 /* Free a data transfer structure and everything below it. */
1793 gfc_free_dt (gfc_dt * dt)
1799 gfc_free_expr (dt->io_unit);
1800 gfc_free_expr (dt->format_expr);
1801 gfc_free_expr (dt->rec);
1802 gfc_free_expr (dt->advance);
1803 gfc_free_expr (dt->iomsg);
1804 gfc_free_expr (dt->iostat);
1805 gfc_free_expr (dt->size);
1811 /* Resolve everything in a gfc_dt structure. */
1814 gfc_resolve_dt (gfc_dt * dt)
1818 RESOLVE_TAG (&tag_format, dt->format_expr);
1819 RESOLVE_TAG (&tag_rec, dt->rec);
1820 RESOLVE_TAG (&tag_advance, dt->advance);
1821 RESOLVE_TAG (&tag_iomsg, dt->iomsg);
1822 RESOLVE_TAG (&tag_iostat, dt->iostat);
1823 RESOLVE_TAG (&tag_size, dt->size);
1826 if (gfc_resolve_expr (e) == SUCCESS
1827 && (e->ts.type != BT_INTEGER
1828 && (e->ts.type != BT_CHARACTER
1829 || e->expr_type != EXPR_VARIABLE)))
1832 ("UNIT specification at %L must be an INTEGER expression or a "
1833 "CHARACTER variable", &e->where);
1837 if (e->ts.type == BT_CHARACTER)
1839 if (gfc_has_vector_index (e))
1841 gfc_error ("Internal unit with vector subscript at %L",
1847 if (e->rank && e->ts.type != BT_CHARACTER)
1849 gfc_error ("External IO UNIT cannot be an array at %L", &e->where);
1855 if (gfc_reference_st_label (dt->err, ST_LABEL_TARGET) == FAILURE)
1857 if (dt->err->defined == ST_LABEL_UNKNOWN)
1859 gfc_error ("ERR tag label %d at %L not defined",
1860 dt->err->value, &dt->err_where);
1867 if (gfc_reference_st_label (dt->end, ST_LABEL_TARGET) == FAILURE)
1869 if (dt->end->defined == ST_LABEL_UNKNOWN)
1871 gfc_error ("END tag label %d at %L not defined",
1872 dt->end->value, &dt->end_where);
1879 if (gfc_reference_st_label (dt->eor, ST_LABEL_TARGET) == FAILURE)
1881 if (dt->eor->defined == ST_LABEL_UNKNOWN)
1883 gfc_error ("EOR tag label %d at %L not defined",
1884 dt->eor->value, &dt->eor_where);
1889 /* Check the format label actually exists. */
1890 if (dt->format_label && dt->format_label != &format_asterisk
1891 && dt->format_label->defined == ST_LABEL_UNKNOWN)
1893 gfc_error ("FORMAT label %d at %L not defined", dt->format_label->value,
1894 &dt->format_label->where);
1901 /* Given an io_kind, return its name. */
1904 io_kind_name (io_kind k)
1923 gfc_internal_error ("io_kind_name(): bad I/O-kind");
1930 /* Match an IO iteration statement of the form:
1932 ( [<IO element> ,] <IO element>, I = <expr>, <expr> [, <expr> ] )
1934 which is equivalent to a single IO element. This function is
1935 mutually recursive with match_io_element(). */
1937 static match match_io_element (io_kind k, gfc_code **);
1940 match_io_iterator (io_kind k, gfc_code ** result)
1942 gfc_code *head, *tail, *new;
1950 old_loc = gfc_current_locus;
1952 if (gfc_match_char ('(') != MATCH_YES)
1955 m = match_io_element (k, &head);
1958 if (m != MATCH_YES || gfc_match_char (',') != MATCH_YES)
1964 /* Can't be anything but an IO iterator. Build a list. */
1965 iter = gfc_get_iterator ();
1969 m = gfc_match_iterator (iter, 0);
1970 if (m == MATCH_ERROR)
1974 gfc_check_do_variable (iter->var->symtree);
1978 m = match_io_element (k, &new);
1979 if (m == MATCH_ERROR)
1988 tail = gfc_append_code (tail, new);
1990 if (gfc_match_char (',') != MATCH_YES)
1999 if (gfc_match_char (')') != MATCH_YES)
2002 new = gfc_get_code ();
2004 new->ext.iterator = iter;
2006 new->block = gfc_get_code ();
2007 new->block->op = EXEC_DO;
2008 new->block->next = head;
2014 gfc_error ("Syntax error in I/O iterator at %C");
2018 gfc_free_iterator (iter, 1);
2019 gfc_free_statements (head);
2020 gfc_current_locus = old_loc;
2025 /* Match a single element of an IO list, which is either a single
2026 expression or an IO Iterator. */
2029 match_io_element (io_kind k, gfc_code ** cpp)
2037 m = match_io_iterator (k, cpp);
2043 m = gfc_match_variable (&expr, 0);
2045 gfc_error ("Expected variable in READ statement at %C");
2049 m = gfc_match_expr (&expr);
2051 gfc_error ("Expected expression in %s statement at %C",
2059 if (expr->symtree->n.sym->attr.intent == INTENT_IN)
2062 ("Variable '%s' in input list at %C cannot be INTENT(IN)",
2063 expr->symtree->n.sym->name);
2068 && gfc_impure_variable (expr->symtree->n.sym)
2069 && current_dt->io_unit->ts.type == BT_CHARACTER)
2071 gfc_error ("Cannot read to variable '%s' in PURE procedure at %C",
2072 expr->symtree->n.sym->name);
2076 if (gfc_check_do_variable (expr->symtree))
2082 if (current_dt->io_unit->ts.type == BT_CHARACTER
2084 && current_dt->io_unit->expr_type == EXPR_VARIABLE
2085 && gfc_impure_variable (current_dt->io_unit->symtree->n.sym))
2088 ("Cannot write to internal file unit '%s' at %C inside a "
2089 "PURE procedure", current_dt->io_unit->symtree->n.sym->name);
2101 gfc_free_expr (expr);
2105 cp = gfc_get_code ();
2106 cp->op = EXEC_TRANSFER;
2114 /* Match an I/O list, building gfc_code structures as we go. */
2117 match_io_list (io_kind k, gfc_code ** head_p)
2119 gfc_code *head, *tail, *new;
2122 *head_p = head = tail = NULL;
2123 if (gfc_match_eos () == MATCH_YES)
2128 m = match_io_element (k, &new);
2129 if (m == MATCH_ERROR)
2134 tail = gfc_append_code (tail, new);
2138 if (gfc_match_eos () == MATCH_YES)
2140 if (gfc_match_char (',') != MATCH_YES)
2148 gfc_error ("Syntax error in %s statement at %C", io_kind_name (k));
2151 gfc_free_statements (head);
2156 /* Attach the data transfer end node. */
2159 terminate_io (gfc_code * io_code)
2163 if (io_code == NULL)
2164 io_code = new_st.block;
2166 c = gfc_get_code ();
2167 c->op = EXEC_DT_END;
2169 /* Point to structure that is already there */
2170 c->ext.dt = new_st.ext.dt;
2171 gfc_append_code (io_code, c);
2175 /* Check the constraints for a data transfer statement. The majority of the
2176 constraints appearing in 9.4 of the standard appear here. Some are handled
2177 in resolve_tag and others in gfc_resolve_dt. */
2180 check_io_constraints (io_kind k, gfc_dt *dt, gfc_code * io_code, locus * spec_end)
2182 #define io_constraint(condition,msg,arg)\
2185 gfc_error(msg,arg);\
2191 gfc_symbol * sym = NULL;
2196 if (expr && expr->expr_type == EXPR_VARIABLE
2197 && expr->ts.type == BT_CHARACTER)
2199 sym = expr->symtree->n.sym;
2201 io_constraint (k == M_WRITE && sym->attr.intent == INTENT_IN,
2202 "Internal file at %L must not be INTENT(IN)",
2205 io_constraint (gfc_has_vector_index (dt->io_unit),
2206 "Internal file incompatible with vector subscript at %L",
2209 io_constraint (dt->rec != NULL,
2210 "REC tag at %L is incompatible with internal file",
2213 io_constraint (dt->namelist != NULL,
2214 "Internal file at %L is incompatible with namelist",
2217 io_constraint (dt->advance != NULL,
2218 "ADVANCE tag at %L is incompatible with internal file",
2219 &dt->advance->where);
2222 if (expr && expr->ts.type != BT_CHARACTER)
2225 io_constraint (gfc_pure (NULL)
2226 && (k == M_READ || k == M_WRITE),
2227 "IO UNIT in %s statement at %C must be "
2228 "an internal file in a PURE procedure",
2235 io_constraint (dt->end,
2236 "END tag not allowed with output at %L",
2239 io_constraint (dt->eor,
2240 "EOR tag not allowed with output at %L",
2243 io_constraint (k != M_READ && dt->size,
2244 "SIZE=specifier not allowed with output at %L",
2249 io_constraint (dt->size && dt->advance == NULL,
2250 "SIZE tag at %L requires an ADVANCE tag",
2253 io_constraint (dt->eor && dt->advance == NULL,
2254 "EOR tag at %L requires an ADVANCE tag",
2262 io_constraint (io_code && dt->namelist,
2263 "NAMELIST cannot be followed by IO-list at %L",
2266 io_constraint (dt->format_expr,
2267 "IO spec-list cannot contain both NAMELIST group name "
2268 "and format specification at %L.",
2269 &dt->format_expr->where);
2271 io_constraint (dt->format_label,
2272 "IO spec-list cannot contain both NAMELIST group name "
2273 "and format label at %L", spec_end);
2275 io_constraint (dt->rec,
2276 "NAMELIST IO is not allowed with a REC=specifier "
2277 "at %L.", &dt->rec->where);
2279 io_constraint (dt->advance,
2280 "NAMELIST IO is not allowed with a ADVANCE=specifier "
2281 "at %L.", &dt->advance->where);
2286 io_constraint (dt->end,
2287 "An END tag is not allowed with a "
2288 "REC=specifier at %L.", &dt->end_where);
2291 io_constraint (dt->format_label == &format_asterisk,
2292 "FMT=* is not allowed with a REC=specifier "
2293 "at %L.", spec_end);
2298 const char * advance;
2299 int not_yes, not_no;
2301 advance = expr->value.character.string;
2303 io_constraint (dt->format_label == &format_asterisk,
2304 "List directed format(*) is not allowed with a "
2305 "ADVANCE=specifier at %L.", &expr->where);
2307 not_no = strncasecmp (advance, "no", 2) != 0;
2308 not_yes = strncasecmp (advance, "yes", 2) != 0;
2310 io_constraint (expr->expr_type == EXPR_CONSTANT
2311 && not_no && not_yes,
2312 "ADVANCE=specifier at %L must have value = "
2313 "YES or NO.", &expr->where);
2315 io_constraint (dt->size && expr->expr_type == EXPR_CONSTANT
2316 && not_no && k == M_READ,
2317 "SIZE tag at %L requires an ADVANCE = 'NO'",
2320 io_constraint (dt->eor && expr->expr_type == EXPR_CONSTANT
2321 && not_no && k == M_READ,
2322 "EOR tag at %L requires an ADVANCE = 'NO'",
2326 expr = dt->format_expr;
2327 if (expr != NULL && expr->expr_type == EXPR_CONSTANT)
2328 check_format_string (expr);
2332 #undef io_constraint
2334 /* Match a READ, WRITE or PRINT statement. */
2337 match_io (io_kind k)
2339 char name[GFC_MAX_SYMBOL_LEN + 1];
2348 where = gfc_current_locus;
2350 current_dt = dt = gfc_getmem (sizeof (gfc_dt));
2351 if (gfc_match_char ('(') == MATCH_NO)
2353 where = gfc_current_locus;
2356 else if (k == M_PRINT)
2358 /* Treat the non-standard case of PRINT namelist. */
2359 if ((gfc_current_form == FORM_FIXED || gfc_peek_char () == ' ')
2360 && gfc_match_name (name) == MATCH_YES)
2362 gfc_find_symbol (name, NULL, 1, &sym);
2363 if (sym && sym->attr.flavor == FL_NAMELIST)
2365 if (gfc_notify_std (GFC_STD_GNU, "PRINT namelist at "
2366 "%C is an extension") == FAILURE)
2372 dt->io_unit = default_unit (k);
2377 gfc_current_locus = where;
2381 if (gfc_current_form == FORM_FREE)
2383 c = gfc_peek_char();
2384 if (c != ' ' && c != '*' && c != '\'' && c != '"')
2391 m = match_dt_format (dt);
2392 if (m == MATCH_ERROR)
2398 dt->io_unit = default_unit (k);
2402 /* Match a control list */
2403 if (match_dt_element (k, dt) == MATCH_YES)
2405 if (match_dt_unit (k, dt) != MATCH_YES)
2408 if (gfc_match_char (')') == MATCH_YES)
2410 if (gfc_match_char (',') != MATCH_YES)
2413 m = match_dt_element (k, dt);
2416 if (m == MATCH_ERROR)
2419 m = match_dt_format (dt);
2422 if (m == MATCH_ERROR)
2425 where = gfc_current_locus;
2427 m = gfc_match_name (name);
2430 gfc_find_symbol (name, NULL, 1, &sym);
2431 if (sym && sym->attr.flavor == FL_NAMELIST)
2434 if (k == M_READ && check_namelist (sym))
2443 gfc_current_locus = where;
2445 goto loop; /* No matches, try regular elements */
2448 if (gfc_match_char (')') == MATCH_YES)
2450 if (gfc_match_char (',') != MATCH_YES)
2456 m = match_dt_element (k, dt);
2459 if (m == MATCH_ERROR)
2462 if (gfc_match_char (')') == MATCH_YES)
2464 if (gfc_match_char (',') != MATCH_YES)
2470 /* Used in check_io_constraints, where no locus is available. */
2471 spec_end = gfc_current_locus;
2473 /* Optional leading comma (non-standard). */
2475 && gfc_match_char (',') == MATCH_YES
2477 && gfc_notify_std (GFC_STD_GNU, "Extension: Comma before output "
2478 "item list at %C is an extension") == FAILURE)
2482 if (gfc_match_eos () != MATCH_YES)
2484 if (comma_flag && gfc_match_char (',') != MATCH_YES)
2486 gfc_error ("Expected comma in I/O list at %C");
2491 m = match_io_list (k, &io_code);
2492 if (m == MATCH_ERROR)
2498 /* A full IO statement has been matched. Check the constraints. spec_end is
2499 supplied for cases where no locus is supplied. */
2500 m = check_io_constraints (k, dt, io_code, &spec_end);
2502 if (m == MATCH_ERROR)
2505 new_st.op = (k == M_READ) ? EXEC_READ : EXEC_WRITE;
2507 new_st.block = gfc_get_code ();
2508 new_st.block->op = new_st.op;
2509 new_st.block->next = io_code;
2511 terminate_io (io_code);
2516 gfc_error ("Syntax error in %s statement at %C", io_kind_name (k));
2526 gfc_match_read (void)
2528 return match_io (M_READ);
2532 gfc_match_write (void)
2534 return match_io (M_WRITE);
2538 gfc_match_print (void)
2542 m = match_io (M_PRINT);
2546 if (gfc_pure (NULL))
2548 gfc_error ("PRINT statement at %C not allowed within PURE procedure");
2556 /* Free a gfc_inquire structure. */
2559 gfc_free_inquire (gfc_inquire * inquire)
2562 if (inquire == NULL)
2565 gfc_free_expr (inquire->unit);
2566 gfc_free_expr (inquire->file);
2567 gfc_free_expr (inquire->iomsg);
2568 gfc_free_expr (inquire->iostat);
2569 gfc_free_expr (inquire->exist);
2570 gfc_free_expr (inquire->opened);
2571 gfc_free_expr (inquire->number);
2572 gfc_free_expr (inquire->named);
2573 gfc_free_expr (inquire->name);
2574 gfc_free_expr (inquire->access);
2575 gfc_free_expr (inquire->sequential);
2576 gfc_free_expr (inquire->direct);
2577 gfc_free_expr (inquire->form);
2578 gfc_free_expr (inquire->formatted);
2579 gfc_free_expr (inquire->unformatted);
2580 gfc_free_expr (inquire->recl);
2581 gfc_free_expr (inquire->nextrec);
2582 gfc_free_expr (inquire->blank);
2583 gfc_free_expr (inquire->position);
2584 gfc_free_expr (inquire->action);
2585 gfc_free_expr (inquire->read);
2586 gfc_free_expr (inquire->write);
2587 gfc_free_expr (inquire->readwrite);
2588 gfc_free_expr (inquire->delim);
2589 gfc_free_expr (inquire->pad);
2590 gfc_free_expr (inquire->iolength);
2591 gfc_free_expr (inquire->convert);
2597 /* Match an element of an INQUIRE statement. */
2599 #define RETM if (m != MATCH_NO) return m;
2602 match_inquire_element (gfc_inquire * inquire)
2606 m = match_etag (&tag_unit, &inquire->unit);
2607 RETM m = match_etag (&tag_file, &inquire->file);
2608 RETM m = match_ltag (&tag_err, &inquire->err);
2609 RETM m = match_out_tag (&tag_iomsg, &inquire->iomsg);
2610 RETM m = match_out_tag (&tag_iostat, &inquire->iostat);
2611 RETM m = match_vtag (&tag_exist, &inquire->exist);
2612 RETM m = match_vtag (&tag_opened, &inquire->opened);
2613 RETM m = match_vtag (&tag_named, &inquire->named);
2614 RETM m = match_vtag (&tag_name, &inquire->name);
2615 RETM m = match_out_tag (&tag_number, &inquire->number);
2616 RETM m = match_vtag (&tag_s_access, &inquire->access);
2617 RETM m = match_vtag (&tag_sequential, &inquire->sequential);
2618 RETM m = match_vtag (&tag_direct, &inquire->direct);
2619 RETM m = match_vtag (&tag_s_form, &inquire->form);
2620 RETM m = match_vtag (&tag_formatted, &inquire->formatted);
2621 RETM m = match_vtag (&tag_unformatted, &inquire->unformatted);
2622 RETM m = match_out_tag (&tag_s_recl, &inquire->recl);
2623 RETM m = match_out_tag (&tag_nextrec, &inquire->nextrec);
2624 RETM m = match_vtag (&tag_s_blank, &inquire->blank);
2625 RETM m = match_vtag (&tag_s_position, &inquire->position);
2626 RETM m = match_vtag (&tag_s_action, &inquire->action);
2627 RETM m = match_vtag (&tag_read, &inquire->read);
2628 RETM m = match_vtag (&tag_write, &inquire->write);
2629 RETM m = match_vtag (&tag_readwrite, &inquire->readwrite);
2630 RETM m = match_vtag (&tag_s_delim, &inquire->delim);
2631 RETM m = match_vtag (&tag_s_pad, &inquire->pad);
2632 RETM m = match_vtag (&tag_iolength, &inquire->iolength);
2633 RETM m = match_vtag (&tag_convert, &inquire->convert);
2634 RETM return MATCH_NO;
2641 gfc_match_inquire (void)
2643 gfc_inquire *inquire;
2648 m = gfc_match_char ('(');
2652 inquire = gfc_getmem (sizeof (gfc_inquire));
2654 loc = gfc_current_locus;
2656 m = match_inquire_element (inquire);
2657 if (m == MATCH_ERROR)
2661 m = gfc_match_expr (&inquire->unit);
2662 if (m == MATCH_ERROR)
2668 /* See if we have the IOLENGTH form of the inquire statement. */
2669 if (inquire->iolength != NULL)
2671 if (gfc_match_char (')') != MATCH_YES)
2674 m = match_io_list (M_INQUIRE, &code);
2675 if (m == MATCH_ERROR)
2680 new_st.op = EXEC_IOLENGTH;
2681 new_st.expr = inquire->iolength;
2682 new_st.ext.inquire = inquire;
2684 if (gfc_pure (NULL))
2686 gfc_free_statements (code);
2687 gfc_error ("INQUIRE statement not allowed in PURE procedure at %C");
2691 new_st.block = gfc_get_code ();
2692 new_st.block->op = EXEC_IOLENGTH;
2693 terminate_io (code);
2694 new_st.block->next = code;
2698 /* At this point, we have the non-IOLENGTH inquire statement. */
2701 if (gfc_match_char (')') == MATCH_YES)
2703 if (gfc_match_char (',') != MATCH_YES)
2706 m = match_inquire_element (inquire);
2707 if (m == MATCH_ERROR)
2712 if (inquire->iolength != NULL)
2714 gfc_error ("IOLENGTH tag invalid in INQUIRE statement at %C");
2719 if (gfc_match_eos () != MATCH_YES)
2722 if (inquire->unit != NULL && inquire->file != NULL)
2724 gfc_error ("INQUIRE statement at %L cannot contain both FILE and"
2725 " UNIT specifiers", &loc);
2729 if (inquire->unit == NULL && inquire->file == NULL)
2731 gfc_error ("INQUIRE statement at %L requires either FILE or"
2732 " UNIT specifier", &loc);
2736 if (gfc_pure (NULL))
2738 gfc_error ("INQUIRE statement not allowed in PURE procedure at %C");
2742 new_st.op = EXEC_INQUIRE;
2743 new_st.ext.inquire = inquire;
2747 gfc_syntax_error (ST_INQUIRE);
2750 gfc_free_inquire (inquire);
2755 /* Resolve everything in a gfc_inquire structure. */
2758 gfc_resolve_inquire (gfc_inquire * inquire)
2761 RESOLVE_TAG (&tag_unit, inquire->unit);
2762 RESOLVE_TAG (&tag_file, inquire->file);
2763 RESOLVE_TAG (&tag_iomsg, inquire->iomsg);
2764 RESOLVE_TAG (&tag_iostat, inquire->iostat);
2765 RESOLVE_TAG (&tag_exist, inquire->exist);
2766 RESOLVE_TAG (&tag_opened, inquire->opened);
2767 RESOLVE_TAG (&tag_number, inquire->number);
2768 RESOLVE_TAG (&tag_named, inquire->named);
2769 RESOLVE_TAG (&tag_name, inquire->name);
2770 RESOLVE_TAG (&tag_s_access, inquire->access);
2771 RESOLVE_TAG (&tag_sequential, inquire->sequential);
2772 RESOLVE_TAG (&tag_direct, inquire->direct);
2773 RESOLVE_TAG (&tag_s_form, inquire->form);
2774 RESOLVE_TAG (&tag_formatted, inquire->formatted);
2775 RESOLVE_TAG (&tag_unformatted, inquire->unformatted);
2776 RESOLVE_TAG (&tag_s_recl, inquire->recl);
2777 RESOLVE_TAG (&tag_nextrec, inquire->nextrec);
2778 RESOLVE_TAG (&tag_s_blank, inquire->blank);
2779 RESOLVE_TAG (&tag_s_position, inquire->position);
2780 RESOLVE_TAG (&tag_s_action, inquire->action);
2781 RESOLVE_TAG (&tag_read, inquire->read);
2782 RESOLVE_TAG (&tag_write, inquire->write);
2783 RESOLVE_TAG (&tag_readwrite, inquire->readwrite);
2784 RESOLVE_TAG (&tag_s_delim, inquire->delim);
2785 RESOLVE_TAG (&tag_s_pad, inquire->pad);
2786 RESOLVE_TAG (&tag_iolength, inquire->iolength);
2787 RESOLVE_TAG (&tag_convert, inquire->convert);
2789 if (gfc_reference_st_label (inquire->err, ST_LABEL_TARGET) == FAILURE)