2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
3 Free Software Foundation, Inc.
4 Contributed by Steven Bosscher
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 3, 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 COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
23 /* Actually this is just a collection of routines that used to be
24 scattered around the sources. Now that they are all in a single
25 file, almost all of them can be static, and the other files don't
26 have this mess in them.
28 As a nice side-effect, this file can act as documentation of the
29 gfc_code and gfc_expr structures and all their friends and
37 /* Keep track of indentation for symbol tree dumps. */
38 static int show_level = 0;
40 /* Do indentation for a specific level. */
43 code_indent (int level, gfc_st_label *label)
48 gfc_status ("%-5d ", label->value);
52 for (i = 0; i < 2 * level; i++)
53 gfc_status_char (' ');
57 /* Simple indentation at the current level. This one
58 is used to show symbols. */
64 code_indent (show_level, NULL);
68 /* Show type-specific information. */
71 gfc_show_typespec (gfc_typespec *ts)
73 gfc_status ("(%s ", gfc_basic_typename (ts->type));
78 gfc_status ("%s", ts->derived->name);
82 gfc_show_expr (ts->cl->length);
86 gfc_status ("%d", ts->kind);
94 /* Show an actual argument list. */
97 gfc_show_actual_arglist (gfc_actual_arglist *a)
101 for (; a; a = a->next)
103 gfc_status_char ('(');
105 gfc_status ("%s = ", a->name);
107 gfc_show_expr (a->expr);
109 gfc_status ("(arg not-present)");
111 gfc_status_char (')');
120 /* Show a gfc_array_spec array specification structure. */
123 gfc_show_array_spec (gfc_array_spec *as)
134 gfc_status ("(%d", as->rank);
140 case AS_EXPLICIT: c = "AS_EXPLICIT"; break;
141 case AS_DEFERRED: c = "AS_DEFERRED"; break;
142 case AS_ASSUMED_SIZE: c = "AS_ASSUMED_SIZE"; break;
143 case AS_ASSUMED_SHAPE: c = "AS_ASSUMED_SHAPE"; break;
145 gfc_internal_error ("gfc_show_array_spec(): Unhandled array shape "
148 gfc_status (" %s ", c);
150 for (i = 0; i < as->rank; i++)
152 gfc_show_expr (as->lower[i]);
153 gfc_status_char (' ');
154 gfc_show_expr (as->upper[i]);
155 gfc_status_char (' ');
163 /* Show a gfc_array_ref array reference structure. */
166 gfc_show_array_ref (gfc_array_ref * ar)
170 gfc_status_char ('(');
179 for (i = 0; i < ar->dimen; i++)
181 /* There are two types of array sections: either the
182 elements are identified by an integer array ('vector'),
183 or by an index range. In the former case we only have to
184 print the start expression which contains the vector, in
185 the latter case we have to print any of lower and upper
186 bound and the stride, if they're present. */
188 if (ar->start[i] != NULL)
189 gfc_show_expr (ar->start[i]);
191 if (ar->dimen_type[i] == DIMEN_RANGE)
193 gfc_status_char (':');
195 if (ar->end[i] != NULL)
196 gfc_show_expr (ar->end[i]);
198 if (ar->stride[i] != NULL)
200 gfc_status_char (':');
201 gfc_show_expr (ar->stride[i]);
205 if (i != ar->dimen - 1)
211 for (i = 0; i < ar->dimen; i++)
213 gfc_show_expr (ar->start[i]);
214 if (i != ar->dimen - 1)
220 gfc_status ("UNKNOWN");
224 gfc_internal_error ("gfc_show_array_ref(): Unknown array reference");
227 gfc_status_char (')');
231 /* Show a list of gfc_ref structures. */
234 gfc_show_ref (gfc_ref *p)
236 for (; p; p = p->next)
240 gfc_show_array_ref (&p->u.ar);
244 gfc_status (" %% %s", p->u.c.component->name);
248 gfc_status_char ('(');
249 gfc_show_expr (p->u.ss.start);
250 gfc_status_char (':');
251 gfc_show_expr (p->u.ss.end);
252 gfc_status_char (')');
256 gfc_internal_error ("gfc_show_ref(): Bad component code");
261 /* Display a constructor. Works recursively for array constructors. */
264 gfc_show_constructor (gfc_constructor *c)
266 for (; c; c = c->next)
268 if (c->iterator == NULL)
269 gfc_show_expr (c->expr);
272 gfc_status_char ('(');
273 gfc_show_expr (c->expr);
275 gfc_status_char (' ');
276 gfc_show_expr (c->iterator->var);
277 gfc_status_char ('=');
278 gfc_show_expr (c->iterator->start);
279 gfc_status_char (',');
280 gfc_show_expr (c->iterator->end);
281 gfc_status_char (',');
282 gfc_show_expr (c->iterator->step);
284 gfc_status_char (')');
294 show_char_const (const char *c, int length)
298 gfc_status_char ('\'');
299 for (i = 0; i < length; i++)
303 else if (ISPRINT (c[i]))
304 gfc_status_char (c[i]);
307 gfc_status ("' // ACHAR(");
309 gfc_status (") // '");
312 gfc_status_char ('\'');
315 /* Show an expression. */
318 gfc_show_expr (gfc_expr *p)
329 switch (p->expr_type)
332 show_char_const (p->value.character.string, p->value.character.length);
333 gfc_show_ref (p->ref);
337 gfc_status ("%s(", p->ts.derived->name);
338 gfc_show_constructor (p->value.constructor);
339 gfc_status_char (')');
344 gfc_show_constructor (p->value.constructor);
347 gfc_show_ref (p->ref);
351 gfc_status ("NULL()");
358 mpz_out_str (stdout, 10, p->value.integer);
360 if (p->ts.kind != gfc_default_integer_kind)
361 gfc_status ("_%d", p->ts.kind);
365 if (p->value.logical)
366 gfc_status (".true.");
368 gfc_status (".false.");
372 mpfr_out_str (stdout, 10, 0, p->value.real, GFC_RND_MODE);
373 if (p->ts.kind != gfc_default_real_kind)
374 gfc_status ("_%d", p->ts.kind);
378 show_char_const (p->value.character.string,
379 p->value.character.length);
383 gfc_status ("(complex ");
385 mpfr_out_str (stdout, 10, 0, p->value.complex.r, GFC_RND_MODE);
386 if (p->ts.kind != gfc_default_complex_kind)
387 gfc_status ("_%d", p->ts.kind);
391 mpfr_out_str (stdout, 10, 0, p->value.complex.i, GFC_RND_MODE);
392 if (p->ts.kind != gfc_default_complex_kind)
393 gfc_status ("_%d", p->ts.kind);
399 gfc_status ("%dH", p->representation.length);
400 c = p->representation.string;
401 for (i = 0; i < p->representation.length; i++, c++)
403 gfc_status_char (*c);
412 if (p->representation.string)
415 c = p->representation.string;
416 for (i = 0; i < p->representation.length; i++, c++)
418 gfc_status ("%.2x", (unsigned int) *c);
419 if (i < p->representation.length - 1)
420 gfc_status_char (',');
422 gfc_status_char ('}');
428 if (p->symtree->n.sym->ns && p->symtree->n.sym->ns->proc_name)
429 gfc_status ("%s:", p->symtree->n.sym->ns->proc_name->name);
430 gfc_status ("%s", p->symtree->n.sym->name);
431 gfc_show_ref (p->ref);
436 switch (p->value.op.operator)
438 case INTRINSIC_UPLUS:
441 case INTRINSIC_UMINUS:
447 case INTRINSIC_MINUS:
450 case INTRINSIC_TIMES:
453 case INTRINSIC_DIVIDE:
456 case INTRINSIC_POWER:
459 case INTRINSIC_CONCAT:
472 gfc_status ("NEQV ");
475 case INTRINSIC_EQ_OS:
479 case INTRINSIC_NE_OS:
483 case INTRINSIC_GT_OS:
487 case INTRINSIC_GE_OS:
491 case INTRINSIC_LT_OS:
495 case INTRINSIC_LE_OS:
501 case INTRINSIC_PARENTHESES:
502 gfc_status ("parens");
507 ("gfc_show_expr(): Bad intrinsic in expression!");
510 gfc_show_expr (p->value.op.op1);
515 gfc_show_expr (p->value.op.op2);
522 if (p->value.function.name == NULL)
524 gfc_status ("%s[", p->symtree->n.sym->name);
525 gfc_show_actual_arglist (p->value.function.actual);
526 gfc_status_char (']');
530 gfc_status ("%s[[", p->value.function.name);
531 gfc_show_actual_arglist (p->value.function.actual);
532 gfc_status_char (']');
533 gfc_status_char (']');
539 gfc_internal_error ("gfc_show_expr(): Don't know how to show expr");
543 /* Show an expression for diagnostic purposes. */
545 gfc_show_expr_n (const char * msg, gfc_expr *e)
550 gfc_status_char ('\n');
553 /* Show symbol attributes. The flavor and intent are followed by
554 whatever single bit attributes are present. */
557 gfc_show_attr (symbol_attribute *attr)
560 gfc_status ("(%s %s %s %s %s", gfc_code2string (flavors, attr->flavor),
561 gfc_intent_string (attr->intent),
562 gfc_code2string (access_types, attr->access),
563 gfc_code2string (procedures, attr->proc),
564 gfc_code2string (save_status, attr->save));
566 if (attr->allocatable)
567 gfc_status (" ALLOCATABLE");
569 gfc_status (" DIMENSION");
571 gfc_status (" EXTERNAL");
573 gfc_status (" INTRINSIC");
575 gfc_status (" OPTIONAL");
577 gfc_status (" POINTER");
579 gfc_status (" PROTECTED");
581 gfc_status (" VALUE");
583 gfc_status (" VOLATILE");
584 if (attr->threadprivate)
585 gfc_status (" THREADPRIVATE");
587 gfc_status (" TARGET");
589 gfc_status (" DUMMY");
591 gfc_status (" RESULT");
593 gfc_status (" ENTRY");
595 gfc_status (" BIND(C)");
598 gfc_status (" DATA");
600 gfc_status (" USE-ASSOC");
601 if (attr->in_namelist)
602 gfc_status (" IN-NAMELIST");
604 gfc_status (" IN-COMMON");
607 gfc_status (" ABSTRACT INTERFACE");
609 gfc_status (" FUNCTION");
610 if (attr->subroutine)
611 gfc_status (" SUBROUTINE");
612 if (attr->implicit_type)
613 gfc_status (" IMPLICIT-TYPE");
616 gfc_status (" SEQUENCE");
618 gfc_status (" ELEMENTAL");
620 gfc_status (" PURE");
622 gfc_status (" RECURSIVE");
628 /* Show components of a derived type. */
631 gfc_show_components (gfc_symbol *sym)
635 for (c = sym->components; c; c = c->next)
637 gfc_status ("(%s ", c->name);
638 gfc_show_typespec (&c->ts);
640 gfc_status (" POINTER");
642 gfc_status (" DIMENSION");
643 gfc_status_char (' ');
644 gfc_show_array_spec (c->as);
646 gfc_status (" %s", gfc_code2string (access_types, c->access));
649 gfc_status_char (' ');
654 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
655 show the interface. Information needed to reconstruct the list of
656 specific interfaces associated with a generic symbol is done within
660 gfc_show_symbol (gfc_symbol *sym)
662 gfc_formal_arglist *formal;
670 gfc_status ("symbol %s ", sym->name);
671 gfc_show_typespec (&sym->ts);
672 gfc_show_attr (&sym->attr);
677 gfc_status ("value: ");
678 gfc_show_expr (sym->value);
684 gfc_status ("Array spec:");
685 gfc_show_array_spec (sym->as);
691 gfc_status ("Generic interfaces:");
692 for (intr = sym->generic; intr; intr = intr->next)
693 gfc_status (" %s", intr->sym->name);
699 gfc_status ("result: %s", sym->result->name);
705 gfc_status ("components: ");
706 gfc_show_components (sym);
712 gfc_status ("Formal arglist:");
714 for (formal = sym->formal; formal; formal = formal->next)
716 if (formal->sym != NULL)
717 gfc_status (" %s", formal->sym->name);
719 gfc_status (" [Alt Return]");
726 gfc_status ("Formal namespace");
727 gfc_show_namespace (sym->formal_ns);
730 gfc_status_char ('\n');
734 /* Show a symbol for diagnostic purposes. */
736 gfc_show_symbol_n (const char * msg, gfc_symbol *sym)
740 gfc_show_symbol (sym);
741 gfc_status_char ('\n');
745 /* Show a user-defined operator. Just prints an operator
746 and the name of the associated subroutine, really. */
749 show_uop (gfc_user_op *uop)
754 gfc_status ("%s:", uop->name);
756 for (intr = uop->operator; intr; intr = intr->next)
757 gfc_status (" %s", intr->sym->name);
761 /* Workhorse function for traversing the user operator symtree. */
764 traverse_uop (gfc_symtree *st, void (*func) (gfc_user_op *))
771 traverse_uop (st->left, func);
772 traverse_uop (st->right, func);
776 /* Traverse the tree of user operator nodes. */
779 gfc_traverse_user_op (gfc_namespace *ns, void (*func) (gfc_user_op *))
781 traverse_uop (ns->uop_root, func);
785 /* Function to display a common block. */
788 show_common (gfc_symtree *st)
793 gfc_status ("common: /%s/ ", st->name);
795 s = st->n.common->head;
798 gfc_status ("%s", s->name);
803 gfc_status_char ('\n');
807 /* Worker function to display the symbol tree. */
810 show_symtree (gfc_symtree *st)
813 gfc_status ("symtree: %s Ambig %d", st->name, st->ambiguous);
815 if (st->n.sym->ns != gfc_current_ns)
816 gfc_status (" from namespace %s", st->n.sym->ns->proc_name->name);
818 gfc_show_symbol (st->n.sym);
822 /******************* Show gfc_code structures **************/
826 static void gfc_show_code_node (int, gfc_code *);
828 /* Show a list of code structures. Mutually recursive with
829 gfc_show_code_node(). */
832 gfc_show_code (int level, gfc_code *c)
834 for (; c; c = c->next)
835 gfc_show_code_node (level, c);
839 gfc_show_namelist (gfc_namelist *n)
841 for (; n->next; n = n->next)
842 gfc_status ("%s,", n->sym->name);
843 gfc_status ("%s", n->sym->name);
846 /* Show a single OpenMP directive node and everything underneath it
850 gfc_show_omp_node (int level, gfc_code *c)
852 gfc_omp_clauses *omp_clauses = NULL;
853 const char *name = NULL;
857 case EXEC_OMP_ATOMIC: name = "ATOMIC"; break;
858 case EXEC_OMP_BARRIER: name = "BARRIER"; break;
859 case EXEC_OMP_CRITICAL: name = "CRITICAL"; break;
860 case EXEC_OMP_FLUSH: name = "FLUSH"; break;
861 case EXEC_OMP_DO: name = "DO"; break;
862 case EXEC_OMP_MASTER: name = "MASTER"; break;
863 case EXEC_OMP_ORDERED: name = "ORDERED"; break;
864 case EXEC_OMP_PARALLEL: name = "PARALLEL"; break;
865 case EXEC_OMP_PARALLEL_DO: name = "PARALLEL DO"; break;
866 case EXEC_OMP_PARALLEL_SECTIONS: name = "PARALLEL SECTIONS"; break;
867 case EXEC_OMP_PARALLEL_WORKSHARE: name = "PARALLEL WORKSHARE"; break;
868 case EXEC_OMP_SECTIONS: name = "SECTIONS"; break;
869 case EXEC_OMP_SINGLE: name = "SINGLE"; break;
870 case EXEC_OMP_WORKSHARE: name = "WORKSHARE"; break;
874 gfc_status ("!$OMP %s", name);
878 case EXEC_OMP_PARALLEL:
879 case EXEC_OMP_PARALLEL_DO:
880 case EXEC_OMP_PARALLEL_SECTIONS:
881 case EXEC_OMP_SECTIONS:
882 case EXEC_OMP_SINGLE:
883 case EXEC_OMP_WORKSHARE:
884 case EXEC_OMP_PARALLEL_WORKSHARE:
885 omp_clauses = c->ext.omp_clauses;
887 case EXEC_OMP_CRITICAL:
889 gfc_status (" (%s)", c->ext.omp_name);
892 if (c->ext.omp_namelist)
895 gfc_show_namelist (c->ext.omp_namelist);
896 gfc_status_char (')');
899 case EXEC_OMP_BARRIER:
908 if (omp_clauses->if_expr)
911 gfc_show_expr (omp_clauses->if_expr);
912 gfc_status_char (')');
914 if (omp_clauses->num_threads)
916 gfc_status (" NUM_THREADS(");
917 gfc_show_expr (omp_clauses->num_threads);
918 gfc_status_char (')');
920 if (omp_clauses->sched_kind != OMP_SCHED_NONE)
923 switch (omp_clauses->sched_kind)
925 case OMP_SCHED_STATIC: type = "STATIC"; break;
926 case OMP_SCHED_DYNAMIC: type = "DYNAMIC"; break;
927 case OMP_SCHED_GUIDED: type = "GUIDED"; break;
928 case OMP_SCHED_RUNTIME: type = "RUNTIME"; break;
932 gfc_status (" SCHEDULE (%s", type);
933 if (omp_clauses->chunk_size)
935 gfc_status_char (',');
936 gfc_show_expr (omp_clauses->chunk_size);
938 gfc_status_char (')');
940 if (omp_clauses->default_sharing != OMP_DEFAULT_UNKNOWN)
943 switch (omp_clauses->default_sharing)
945 case OMP_DEFAULT_NONE: type = "NONE"; break;
946 case OMP_DEFAULT_PRIVATE: type = "PRIVATE"; break;
947 case OMP_DEFAULT_SHARED: type = "SHARED"; break;
948 case OMP_SCHED_RUNTIME: type = "RUNTIME"; break;
952 gfc_status (" DEFAULT(%s)", type);
954 if (omp_clauses->ordered)
955 gfc_status (" ORDERED");
956 for (list_type = 0; list_type < OMP_LIST_NUM; list_type++)
957 if (omp_clauses->lists[list_type] != NULL
958 && list_type != OMP_LIST_COPYPRIVATE)
961 if (list_type >= OMP_LIST_REDUCTION_FIRST)
965 case OMP_LIST_PLUS: type = "+"; break;
966 case OMP_LIST_MULT: type = "*"; break;
967 case OMP_LIST_SUB: type = "-"; break;
968 case OMP_LIST_AND: type = ".AND."; break;
969 case OMP_LIST_OR: type = ".OR."; break;
970 case OMP_LIST_EQV: type = ".EQV."; break;
971 case OMP_LIST_NEQV: type = ".NEQV."; break;
972 case OMP_LIST_MAX: type = "MAX"; break;
973 case OMP_LIST_MIN: type = "MIN"; break;
974 case OMP_LIST_IAND: type = "IAND"; break;
975 case OMP_LIST_IOR: type = "IOR"; break;
976 case OMP_LIST_IEOR: type = "IEOR"; break;
980 gfc_status (" REDUCTION(%s:", type);
986 case OMP_LIST_PRIVATE: type = "PRIVATE"; break;
987 case OMP_LIST_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break;
988 case OMP_LIST_LASTPRIVATE: type = "LASTPRIVATE"; break;
989 case OMP_LIST_SHARED: type = "SHARED"; break;
990 case OMP_LIST_COPYIN: type = "COPYIN"; break;
994 gfc_status (" %s(", type);
996 gfc_show_namelist (omp_clauses->lists[list_type]);
997 gfc_status_char (')');
1000 gfc_status_char ('\n');
1001 if (c->op == EXEC_OMP_SECTIONS || c->op == EXEC_OMP_PARALLEL_SECTIONS)
1003 gfc_code *d = c->block;
1006 gfc_show_code (level + 1, d->next);
1007 if (d->block == NULL)
1009 code_indent (level, 0);
1010 gfc_status ("!$OMP SECTION\n");
1015 gfc_show_code (level + 1, c->block->next);
1016 if (c->op == EXEC_OMP_ATOMIC)
1018 code_indent (level, 0);
1019 gfc_status ("!$OMP END %s", name);
1020 if (omp_clauses != NULL)
1022 if (omp_clauses->lists[OMP_LIST_COPYPRIVATE])
1024 gfc_status (" COPYPRIVATE(");
1025 gfc_show_namelist (omp_clauses->lists[OMP_LIST_COPYPRIVATE]);
1026 gfc_status_char (')');
1028 else if (omp_clauses->nowait)
1029 gfc_status (" NOWAIT");
1031 else if (c->op == EXEC_OMP_CRITICAL && c->ext.omp_name)
1032 gfc_status (" (%s)", c->ext.omp_name);
1036 /* Show a single code node and everything underneath it if necessary. */
1039 gfc_show_code_node (int level, gfc_code *c)
1041 gfc_forall_iterator *fa;
1051 code_indent (level, c->here);
1060 gfc_status ("CONTINUE");
1064 gfc_status ("ENTRY %s", c->ext.entry->sym->name);
1067 case EXEC_INIT_ASSIGN:
1069 gfc_status ("ASSIGN ");
1070 gfc_show_expr (c->expr);
1071 gfc_status_char (' ');
1072 gfc_show_expr (c->expr2);
1075 case EXEC_LABEL_ASSIGN:
1076 gfc_status ("LABEL ASSIGN ");
1077 gfc_show_expr (c->expr);
1078 gfc_status (" %d", c->label->value);
1081 case EXEC_POINTER_ASSIGN:
1082 gfc_status ("POINTER ASSIGN ");
1083 gfc_show_expr (c->expr);
1084 gfc_status_char (' ');
1085 gfc_show_expr (c->expr2);
1089 gfc_status ("GOTO ");
1091 gfc_status ("%d", c->label->value);
1094 gfc_show_expr (c->expr);
1099 for (; d; d = d ->block)
1101 code_indent (level, d->label);
1102 if (d->block != NULL)
1103 gfc_status_char (',');
1105 gfc_status_char (')');
1112 case EXEC_ASSIGN_CALL:
1113 if (c->resolved_sym)
1114 gfc_status ("CALL %s ", c->resolved_sym->name);
1115 else if (c->symtree)
1116 gfc_status ("CALL %s ", c->symtree->name);
1118 gfc_status ("CALL ?? ");
1120 gfc_show_actual_arglist (c->ext.actual);
1124 gfc_status ("RETURN ");
1126 gfc_show_expr (c->expr);
1130 gfc_status ("PAUSE ");
1132 if (c->expr != NULL)
1133 gfc_show_expr (c->expr);
1135 gfc_status ("%d", c->ext.stop_code);
1140 gfc_status ("STOP ");
1142 if (c->expr != NULL)
1143 gfc_show_expr (c->expr);
1145 gfc_status ("%d", c->ext.stop_code);
1149 case EXEC_ARITHMETIC_IF:
1151 gfc_show_expr (c->expr);
1152 gfc_status (" %d, %d, %d",
1153 c->label->value, c->label2->value, c->label3->value);
1159 gfc_show_expr (d->expr);
1160 gfc_status_char ('\n');
1161 gfc_show_code (level + 1, d->next);
1164 for (; d; d = d->block)
1166 code_indent (level, 0);
1168 if (d->expr == NULL)
1169 gfc_status ("ELSE\n");
1172 gfc_status ("ELSE IF ");
1173 gfc_show_expr (d->expr);
1174 gfc_status_char ('\n');
1177 gfc_show_code (level + 1, d->next);
1180 code_indent (level, c->label);
1182 gfc_status ("ENDIF");
1187 gfc_status ("SELECT CASE ");
1188 gfc_show_expr (c->expr);
1189 gfc_status_char ('\n');
1191 for (; d; d = d->block)
1193 code_indent (level, 0);
1195 gfc_status ("CASE ");
1196 for (cp = d->ext.case_list; cp; cp = cp->next)
1198 gfc_status_char ('(');
1199 gfc_show_expr (cp->low);
1200 gfc_status_char (' ');
1201 gfc_show_expr (cp->high);
1202 gfc_status_char (')');
1203 gfc_status_char (' ');
1205 gfc_status_char ('\n');
1207 gfc_show_code (level + 1, d->next);
1210 code_indent (level, c->label);
1211 gfc_status ("END SELECT");
1215 gfc_status ("WHERE ");
1218 gfc_show_expr (d->expr);
1219 gfc_status_char ('\n');
1221 gfc_show_code (level + 1, d->next);
1223 for (d = d->block; d; d = d->block)
1225 code_indent (level, 0);
1226 gfc_status ("ELSE WHERE ");
1227 gfc_show_expr (d->expr);
1228 gfc_status_char ('\n');
1229 gfc_show_code (level + 1, d->next);
1232 code_indent (level, 0);
1233 gfc_status ("END WHERE");
1238 gfc_status ("FORALL ");
1239 for (fa = c->ext.forall_iterator; fa; fa = fa->next)
1241 gfc_show_expr (fa->var);
1242 gfc_status_char (' ');
1243 gfc_show_expr (fa->start);
1244 gfc_status_char (':');
1245 gfc_show_expr (fa->end);
1246 gfc_status_char (':');
1247 gfc_show_expr (fa->stride);
1249 if (fa->next != NULL)
1250 gfc_status_char (',');
1253 if (c->expr != NULL)
1255 gfc_status_char (',');
1256 gfc_show_expr (c->expr);
1258 gfc_status_char ('\n');
1260 gfc_show_code (level + 1, c->block->next);
1262 code_indent (level, 0);
1263 gfc_status ("END FORALL");
1269 gfc_show_expr (c->ext.iterator->var);
1270 gfc_status_char ('=');
1271 gfc_show_expr (c->ext.iterator->start);
1272 gfc_status_char (' ');
1273 gfc_show_expr (c->ext.iterator->end);
1274 gfc_status_char (' ');
1275 gfc_show_expr (c->ext.iterator->step);
1276 gfc_status_char ('\n');
1278 gfc_show_code (level + 1, c->block->next);
1280 code_indent (level, 0);
1281 gfc_status ("END DO");
1285 gfc_status ("DO WHILE ");
1286 gfc_show_expr (c->expr);
1287 gfc_status_char ('\n');
1289 gfc_show_code (level + 1, c->block->next);
1291 code_indent (level, c->label);
1292 gfc_status ("END DO");
1296 gfc_status ("CYCLE");
1298 gfc_status (" %s", c->symtree->n.sym->name);
1302 gfc_status ("EXIT");
1304 gfc_status (" %s", c->symtree->n.sym->name);
1308 gfc_status ("ALLOCATE ");
1311 gfc_status (" STAT=");
1312 gfc_show_expr (c->expr);
1315 for (a = c->ext.alloc_list; a; a = a->next)
1317 gfc_status_char (' ');
1318 gfc_show_expr (a->expr);
1323 case EXEC_DEALLOCATE:
1324 gfc_status ("DEALLOCATE ");
1327 gfc_status (" STAT=");
1328 gfc_show_expr (c->expr);
1331 for (a = c->ext.alloc_list; a; a = a->next)
1333 gfc_status_char (' ');
1334 gfc_show_expr (a->expr);
1340 gfc_status ("OPEN");
1345 gfc_status (" UNIT=");
1346 gfc_show_expr (open->unit);
1350 gfc_status (" IOMSG=");
1351 gfc_show_expr (open->iomsg);
1355 gfc_status (" IOSTAT=");
1356 gfc_show_expr (open->iostat);
1360 gfc_status (" FILE=");
1361 gfc_show_expr (open->file);
1365 gfc_status (" STATUS=");
1366 gfc_show_expr (open->status);
1370 gfc_status (" ACCESS=");
1371 gfc_show_expr (open->access);
1375 gfc_status (" FORM=");
1376 gfc_show_expr (open->form);
1380 gfc_status (" RECL=");
1381 gfc_show_expr (open->recl);
1385 gfc_status (" BLANK=");
1386 gfc_show_expr (open->blank);
1390 gfc_status (" POSITION=");
1391 gfc_show_expr (open->position);
1395 gfc_status (" ACTION=");
1396 gfc_show_expr (open->action);
1400 gfc_status (" DELIM=");
1401 gfc_show_expr (open->delim);
1405 gfc_status (" PAD=");
1406 gfc_show_expr (open->pad);
1410 gfc_status (" DECIMAL=");
1411 gfc_show_expr (open->decimal);
1415 gfc_status (" ENCODING=");
1416 gfc_show_expr (open->encoding);
1420 gfc_status (" ROUND=");
1421 gfc_show_expr (open->round);
1425 gfc_status (" SIGN=");
1426 gfc_show_expr (open->sign);
1430 gfc_status (" CONVERT=");
1431 gfc_show_expr (open->convert);
1433 if (open->asynchronous)
1435 gfc_status (" ASYNCHRONOUS=");
1436 gfc_show_expr (open->asynchronous);
1438 if (open->err != NULL)
1439 gfc_status (" ERR=%d", open->err->value);
1444 gfc_status ("CLOSE");
1445 close = c->ext.close;
1449 gfc_status (" UNIT=");
1450 gfc_show_expr (close->unit);
1454 gfc_status (" IOMSG=");
1455 gfc_show_expr (close->iomsg);
1459 gfc_status (" IOSTAT=");
1460 gfc_show_expr (close->iostat);
1464 gfc_status (" STATUS=");
1465 gfc_show_expr (close->status);
1467 if (close->err != NULL)
1468 gfc_status (" ERR=%d", close->err->value);
1471 case EXEC_BACKSPACE:
1472 gfc_status ("BACKSPACE");
1476 gfc_status ("ENDFILE");
1480 gfc_status ("REWIND");
1484 gfc_status ("FLUSH");
1487 fp = c->ext.filepos;
1491 gfc_status (" UNIT=");
1492 gfc_show_expr (fp->unit);
1496 gfc_status (" IOMSG=");
1497 gfc_show_expr (fp->iomsg);
1501 gfc_status (" IOSTAT=");
1502 gfc_show_expr (fp->iostat);
1504 if (fp->err != NULL)
1505 gfc_status (" ERR=%d", fp->err->value);
1509 gfc_status ("INQUIRE");
1514 gfc_status (" UNIT=");
1515 gfc_show_expr (i->unit);
1519 gfc_status (" FILE=");
1520 gfc_show_expr (i->file);
1525 gfc_status (" IOMSG=");
1526 gfc_show_expr (i->iomsg);
1530 gfc_status (" IOSTAT=");
1531 gfc_show_expr (i->iostat);
1535 gfc_status (" EXIST=");
1536 gfc_show_expr (i->exist);
1540 gfc_status (" OPENED=");
1541 gfc_show_expr (i->opened);
1545 gfc_status (" NUMBER=");
1546 gfc_show_expr (i->number);
1550 gfc_status (" NAMED=");
1551 gfc_show_expr (i->named);
1555 gfc_status (" NAME=");
1556 gfc_show_expr (i->name);
1560 gfc_status (" ACCESS=");
1561 gfc_show_expr (i->access);
1565 gfc_status (" SEQUENTIAL=");
1566 gfc_show_expr (i->sequential);
1571 gfc_status (" DIRECT=");
1572 gfc_show_expr (i->direct);
1576 gfc_status (" FORM=");
1577 gfc_show_expr (i->form);
1581 gfc_status (" FORMATTED");
1582 gfc_show_expr (i->formatted);
1586 gfc_status (" UNFORMATTED=");
1587 gfc_show_expr (i->unformatted);
1591 gfc_status (" RECL=");
1592 gfc_show_expr (i->recl);
1596 gfc_status (" NEXTREC=");
1597 gfc_show_expr (i->nextrec);
1601 gfc_status (" BLANK=");
1602 gfc_show_expr (i->blank);
1606 gfc_status (" POSITION=");
1607 gfc_show_expr (i->position);
1611 gfc_status (" ACTION=");
1612 gfc_show_expr (i->action);
1616 gfc_status (" READ=");
1617 gfc_show_expr (i->read);
1621 gfc_status (" WRITE=");
1622 gfc_show_expr (i->write);
1626 gfc_status (" READWRITE=");
1627 gfc_show_expr (i->readwrite);
1631 gfc_status (" DELIM=");
1632 gfc_show_expr (i->delim);
1636 gfc_status (" PAD=");
1637 gfc_show_expr (i->pad);
1641 gfc_status (" CONVERT=");
1642 gfc_show_expr (i->convert);
1644 if (i->asynchronous)
1646 gfc_status (" ASYNCHRONOUS=");
1647 gfc_show_expr (i->asynchronous);
1651 gfc_status (" DECIMAL=");
1652 gfc_show_expr (i->decimal);
1656 gfc_status (" ENCODING=");
1657 gfc_show_expr (i->encoding);
1661 gfc_status (" PENDING=");
1662 gfc_show_expr (i->pending);
1666 gfc_status (" ROUND=");
1667 gfc_show_expr (i->round);
1671 gfc_status (" SIGN=");
1672 gfc_show_expr (i->sign);
1676 gfc_status (" SIZE=");
1677 gfc_show_expr (i->size);
1681 gfc_status (" ID=");
1682 gfc_show_expr (i->id);
1686 gfc_status (" ERR=%d", i->err->value);
1690 gfc_status ("IOLENGTH ");
1691 gfc_show_expr (c->expr);
1696 gfc_status ("READ");
1700 gfc_status ("WRITE");
1706 gfc_status (" UNIT=");
1707 gfc_show_expr (dt->io_unit);
1710 if (dt->format_expr)
1712 gfc_status (" FMT=");
1713 gfc_show_expr (dt->format_expr);
1716 if (dt->format_label != NULL)
1717 gfc_status (" FMT=%d", dt->format_label->value);
1719 gfc_status (" NML=%s", dt->namelist->name);
1723 gfc_status (" IOMSG=");
1724 gfc_show_expr (dt->iomsg);
1728 gfc_status (" IOSTAT=");
1729 gfc_show_expr (dt->iostat);
1733 gfc_status (" SIZE=");
1734 gfc_show_expr (dt->size);
1738 gfc_status (" REC=");
1739 gfc_show_expr (dt->rec);
1743 gfc_status (" ADVANCE=");
1744 gfc_show_expr (dt->advance);
1748 gfc_status (" ID=");
1749 gfc_show_expr (dt->id);
1753 gfc_status (" POS=");
1754 gfc_show_expr (dt->pos);
1756 if (dt->asynchronous)
1758 gfc_status (" ASYNCHRONOUS=");
1759 gfc_show_expr (dt->asynchronous);
1763 gfc_status (" BLANK=");
1764 gfc_show_expr (dt->blank);
1768 gfc_status (" DECIMAL=");
1769 gfc_show_expr (dt->decimal);
1773 gfc_status (" DELIM=");
1774 gfc_show_expr (dt->delim);
1778 gfc_status (" PAD=");
1779 gfc_show_expr (dt->pad);
1783 gfc_status (" ROUND=");
1784 gfc_show_expr (dt->round);
1788 gfc_status (" SIGN=");
1789 gfc_show_expr (dt->sign);
1793 gfc_status_char ('\n');
1794 for (c = c->block->next; c; c = c->next)
1795 gfc_show_code_node (level + (c->next != NULL), c);
1799 gfc_status ("TRANSFER ");
1800 gfc_show_expr (c->expr);
1804 gfc_status ("DT_END");
1807 if (dt->err != NULL)
1808 gfc_status (" ERR=%d", dt->err->value);
1809 if (dt->end != NULL)
1810 gfc_status (" END=%d", dt->end->value);
1811 if (dt->eor != NULL)
1812 gfc_status (" EOR=%d", dt->eor->value);
1815 case EXEC_OMP_ATOMIC:
1816 case EXEC_OMP_BARRIER:
1817 case EXEC_OMP_CRITICAL:
1818 case EXEC_OMP_FLUSH:
1820 case EXEC_OMP_MASTER:
1821 case EXEC_OMP_ORDERED:
1822 case EXEC_OMP_PARALLEL:
1823 case EXEC_OMP_PARALLEL_DO:
1824 case EXEC_OMP_PARALLEL_SECTIONS:
1825 case EXEC_OMP_PARALLEL_WORKSHARE:
1826 case EXEC_OMP_SECTIONS:
1827 case EXEC_OMP_SINGLE:
1828 case EXEC_OMP_WORKSHARE:
1829 gfc_show_omp_node (level, c);
1833 gfc_internal_error ("gfc_show_code_node(): Bad statement code");
1836 gfc_status_char ('\n');
1840 /* Show an equivalence chain. */
1843 gfc_show_equiv (gfc_equiv *eq)
1846 gfc_status ("Equivalence: ");
1849 gfc_show_expr (eq->expr);
1857 /* Show a freakin' whole namespace. */
1860 gfc_show_namespace (gfc_namespace *ns)
1862 gfc_interface *intr;
1863 gfc_namespace *save;
1864 gfc_intrinsic_op op;
1868 save = gfc_current_ns;
1872 gfc_status ("Namespace:");
1880 while (i < GFC_LETTERS - 1
1881 && gfc_compare_types(&ns->default_type[i+1],
1882 &ns->default_type[l]))
1886 gfc_status(" %c-%c: ", l+'A', i+'A');
1888 gfc_status(" %c: ", l+'A');
1890 gfc_show_typespec(&ns->default_type[l]);
1892 } while (i < GFC_LETTERS);
1894 if (ns->proc_name != NULL)
1897 gfc_status ("procedure name = %s", ns->proc_name->name);
1900 gfc_current_ns = ns;
1901 gfc_traverse_symtree (ns->common_root, show_common);
1903 gfc_traverse_symtree (ns->sym_root, show_symtree);
1905 for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; op++)
1907 /* User operator interfaces */
1908 intr = ns->operator[op];
1913 gfc_status ("Operator interfaces for %s:", gfc_op2string (op));
1915 for (; intr; intr = intr->next)
1916 gfc_status (" %s", intr->sym->name);
1919 if (ns->uop_root != NULL)
1922 gfc_status ("User operators:\n");
1923 gfc_traverse_user_op (ns, show_uop);
1927 for (eq = ns->equiv; eq; eq = eq->next)
1928 gfc_show_equiv (eq);
1930 gfc_status_char ('\n');
1931 gfc_status_char ('\n');
1933 gfc_show_code (0, ns->code);
1935 for (ns = ns->contained; ns; ns = ns->sibling)
1938 gfc_status ("CONTAINS\n");
1939 gfc_show_namespace (ns);
1943 gfc_status_char ('\n');
1944 gfc_current_ns = save;