2 Copyright (C) 2003, 2004, 2005, 2006, 2007
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 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
24 /* Actually this is just a collection of routines that used to be
25 scattered around the sources. Now that they are all in a single
26 file, almost all of them can be static, and the other files don't
27 have this mess in them.
29 As a nice side-effect, this file can act as documentation of the
30 gfc_code and gfc_expr structures and all their friends and
38 /* Keep track of indentation for symbol tree dumps. */
39 static int show_level
= 0;
41 /* Do indentation for a specific level. */
44 code_indent (int level
, gfc_st_label
*label
)
49 gfc_status ("%-5d ", label
->value
);
53 for (i
= 0; i
< 2 * level
; i
++)
54 gfc_status_char (' ');
58 /* Simple indentation at the current level. This one
59 is used to show symbols. */
65 code_indent (show_level
, NULL
);
69 /* Show type-specific information. */
72 gfc_show_typespec (gfc_typespec
*ts
)
74 gfc_status ("(%s ", gfc_basic_typename (ts
->type
));
79 gfc_status ("%s", ts
->derived
->name
);
83 gfc_show_expr (ts
->cl
->length
);
87 gfc_status ("%d", ts
->kind
);
95 /* Show an actual argument list. */
98 gfc_show_actual_arglist (gfc_actual_arglist
*a
)
102 for (; a
; a
= a
->next
)
104 gfc_status_char ('(');
106 gfc_status ("%s = ", a
->name
);
108 gfc_show_expr (a
->expr
);
110 gfc_status ("(arg not-present)");
112 gfc_status_char (')');
121 /* Show a gfc_array_spec array specification structure. */
124 gfc_show_array_spec (gfc_array_spec
*as
)
135 gfc_status ("(%d", as
->rank
);
141 case AS_EXPLICIT
: c
= "AS_EXPLICIT"; break;
142 case AS_DEFERRED
: c
= "AS_DEFERRED"; break;
143 case AS_ASSUMED_SIZE
: c
= "AS_ASSUMED_SIZE"; break;
144 case AS_ASSUMED_SHAPE
: c
= "AS_ASSUMED_SHAPE"; break;
146 gfc_internal_error ("gfc_show_array_spec(): Unhandled array shape "
149 gfc_status (" %s ", c
);
151 for (i
= 0; i
< as
->rank
; i
++)
153 gfc_show_expr (as
->lower
[i
]);
154 gfc_status_char (' ');
155 gfc_show_expr (as
->upper
[i
]);
156 gfc_status_char (' ');
164 /* Show a gfc_array_ref array reference structure. */
167 gfc_show_array_ref (gfc_array_ref
* ar
)
171 gfc_status_char ('(');
180 for (i
= 0; i
< ar
->dimen
; i
++)
182 /* There are two types of array sections: either the
183 elements are identified by an integer array ('vector'),
184 or by an index range. In the former case we only have to
185 print the start expression which contains the vector, in
186 the latter case we have to print any of lower and upper
187 bound and the stride, if they're present. */
189 if (ar
->start
[i
] != NULL
)
190 gfc_show_expr (ar
->start
[i
]);
192 if (ar
->dimen_type
[i
] == DIMEN_RANGE
)
194 gfc_status_char (':');
196 if (ar
->end
[i
] != NULL
)
197 gfc_show_expr (ar
->end
[i
]);
199 if (ar
->stride
[i
] != NULL
)
201 gfc_status_char (':');
202 gfc_show_expr (ar
->stride
[i
]);
206 if (i
!= ar
->dimen
- 1)
212 for (i
= 0; i
< ar
->dimen
; i
++)
214 gfc_show_expr (ar
->start
[i
]);
215 if (i
!= ar
->dimen
- 1)
221 gfc_status ("UNKNOWN");
225 gfc_internal_error ("gfc_show_array_ref(): Unknown array reference");
228 gfc_status_char (')');
232 /* Show a list of gfc_ref structures. */
235 gfc_show_ref (gfc_ref
*p
)
237 for (; p
; p
= p
->next
)
241 gfc_show_array_ref (&p
->u
.ar
);
245 gfc_status (" %% %s", p
->u
.c
.component
->name
);
249 gfc_status_char ('(');
250 gfc_show_expr (p
->u
.ss
.start
);
251 gfc_status_char (':');
252 gfc_show_expr (p
->u
.ss
.end
);
253 gfc_status_char (')');
257 gfc_internal_error ("gfc_show_ref(): Bad component code");
262 /* Display a constructor. Works recursively for array constructors. */
265 gfc_show_constructor (gfc_constructor
*c
)
267 for (; c
; c
= c
->next
)
269 if (c
->iterator
== NULL
)
270 gfc_show_expr (c
->expr
);
273 gfc_status_char ('(');
274 gfc_show_expr (c
->expr
);
276 gfc_status_char (' ');
277 gfc_show_expr (c
->iterator
->var
);
278 gfc_status_char ('=');
279 gfc_show_expr (c
->iterator
->start
);
280 gfc_status_char (',');
281 gfc_show_expr (c
->iterator
->end
);
282 gfc_status_char (',');
283 gfc_show_expr (c
->iterator
->step
);
285 gfc_status_char (')');
294 /* Show an expression. */
297 gfc_show_expr (gfc_expr
*p
)
308 switch (p
->expr_type
)
311 c
= p
->value
.character
.string
;
313 for (i
= 0; i
< p
->value
.character
.length
; i
++, c
++)
318 gfc_status ("%c", *c
);
321 gfc_show_ref (p
->ref
);
325 gfc_status ("%s(", p
->ts
.derived
->name
);
326 gfc_show_constructor (p
->value
.constructor
);
327 gfc_status_char (')');
332 gfc_show_constructor (p
->value
.constructor
);
335 gfc_show_ref (p
->ref
);
339 gfc_status ("NULL()");
346 mpz_out_str (stdout
, 10, p
->value
.integer
);
348 if (p
->ts
.kind
!= gfc_default_integer_kind
)
349 gfc_status ("_%d", p
->ts
.kind
);
353 if (p
->value
.logical
)
354 gfc_status (".true.");
356 gfc_status (".false.");
360 mpfr_out_str (stdout
, 10, 0, p
->value
.real
, GFC_RND_MODE
);
361 if (p
->ts
.kind
!= gfc_default_real_kind
)
362 gfc_status ("_%d", p
->ts
.kind
);
366 c
= p
->value
.character
.string
;
368 gfc_status_char ('\'');
370 for (i
= 0; i
< p
->value
.character
.length
; i
++, c
++)
375 gfc_status_char (*c
);
378 gfc_status_char ('\'');
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 ");
495 case INTRINSIC_PARENTHESES
:
496 gfc_status ("parens");
501 ("gfc_show_expr(): Bad intrinsic in expression!");
504 gfc_show_expr (p
->value
.op
.op1
);
509 gfc_show_expr (p
->value
.op
.op2
);
516 if (p
->value
.function
.name
== NULL
)
518 gfc_status ("%s[", p
->symtree
->n
.sym
->name
);
519 gfc_show_actual_arglist (p
->value
.function
.actual
);
520 gfc_status_char (']');
524 gfc_status ("%s[[", p
->value
.function
.name
);
525 gfc_show_actual_arglist (p
->value
.function
.actual
);
526 gfc_status_char (']');
527 gfc_status_char (']');
533 gfc_internal_error ("gfc_show_expr(): Don't know how to show expr");
538 /* Show symbol attributes. The flavor and intent are followed by
539 whatever single bit attributes are present. */
542 gfc_show_attr (symbol_attribute
*attr
)
545 gfc_status ("(%s %s %s %s", gfc_code2string (flavors
, attr
->flavor
),
546 gfc_intent_string (attr
->intent
),
547 gfc_code2string (access_types
, attr
->access
),
548 gfc_code2string (procedures
, attr
->proc
));
550 if (attr
->allocatable
)
551 gfc_status (" ALLOCATABLE");
553 gfc_status (" DIMENSION");
555 gfc_status (" EXTERNAL");
557 gfc_status (" INTRINSIC");
559 gfc_status (" OPTIONAL");
561 gfc_status (" POINTER");
563 gfc_status (" PROTECTED");
565 gfc_status (" SAVE");
567 gfc_status (" VALUE");
569 gfc_status (" VOLATILE");
570 if (attr
->threadprivate
)
571 gfc_status (" THREADPRIVATE");
573 gfc_status (" TARGET");
575 gfc_status (" DUMMY");
577 gfc_status (" RESULT");
579 gfc_status (" ENTRY");
582 gfc_status (" DATA");
584 gfc_status (" USE-ASSOC");
585 if (attr
->in_namelist
)
586 gfc_status (" IN-NAMELIST");
588 gfc_status (" IN-COMMON");
591 gfc_status (" FUNCTION");
592 if (attr
->subroutine
)
593 gfc_status (" SUBROUTINE");
594 if (attr
->implicit_type
)
595 gfc_status (" IMPLICIT-TYPE");
598 gfc_status (" SEQUENCE");
600 gfc_status (" ELEMENTAL");
602 gfc_status (" PURE");
604 gfc_status (" RECURSIVE");
610 /* Show components of a derived type. */
613 gfc_show_components (gfc_symbol
*sym
)
617 for (c
= sym
->components
; c
; c
= c
->next
)
619 gfc_status ("(%s ", c
->name
);
620 gfc_show_typespec (&c
->ts
);
622 gfc_status (" POINTER");
624 gfc_status (" DIMENSION");
625 gfc_status_char (' ');
626 gfc_show_array_spec (c
->as
);
628 gfc_status (" %s", gfc_code2string (access_types
, c
->access
));
631 gfc_status_char (' ');
636 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
637 show the interface. Information needed to reconstruct the list of
638 specific interfaces associated with a generic symbol is done within
642 gfc_show_symbol (gfc_symbol
*sym
)
644 gfc_formal_arglist
*formal
;
652 gfc_status ("symbol %s ", sym
->name
);
653 gfc_show_typespec (&sym
->ts
);
654 gfc_show_attr (&sym
->attr
);
659 gfc_status ("value: ");
660 gfc_show_expr (sym
->value
);
666 gfc_status ("Array spec:");
667 gfc_show_array_spec (sym
->as
);
673 gfc_status ("Generic interfaces:");
674 for (intr
= sym
->generic
; intr
; intr
= intr
->next
)
675 gfc_status (" %s", intr
->sym
->name
);
681 gfc_status ("result: %s", sym
->result
->name
);
687 gfc_status ("components: ");
688 gfc_show_components (sym
);
694 gfc_status ("Formal arglist:");
696 for (formal
= sym
->formal
; formal
; formal
= formal
->next
)
698 if (formal
->sym
!= NULL
)
699 gfc_status (" %s", formal
->sym
->name
);
701 gfc_status (" [Alt Return]");
708 gfc_status ("Formal namespace");
709 gfc_show_namespace (sym
->formal_ns
);
712 gfc_status_char ('\n');
716 /* Show a user-defined operator. Just prints an operator
717 and the name of the associated subroutine, really. */
720 show_uop (gfc_user_op
*uop
)
725 gfc_status ("%s:", uop
->name
);
727 for (intr
= uop
->operator; intr
; intr
= intr
->next
)
728 gfc_status (" %s", intr
->sym
->name
);
732 /* Workhorse function for traversing the user operator symtree. */
735 traverse_uop (gfc_symtree
*st
, void (*func
) (gfc_user_op
*))
742 traverse_uop (st
->left
, func
);
743 traverse_uop (st
->right
, func
);
747 /* Traverse the tree of user operator nodes. */
750 gfc_traverse_user_op (gfc_namespace
*ns
, void (*func
) (gfc_user_op
*))
752 traverse_uop (ns
->uop_root
, func
);
756 /* Function to display a common block. */
759 show_common (gfc_symtree
*st
)
764 gfc_status ("common: /%s/ ", st
->name
);
766 s
= st
->n
.common
->head
;
769 gfc_status ("%s", s
->name
);
774 gfc_status_char ('\n');
778 /* Worker function to display the symbol tree. */
781 show_symtree (gfc_symtree
*st
)
784 gfc_status ("symtree: %s Ambig %d", st
->name
, st
->ambiguous
);
786 if (st
->n
.sym
->ns
!= gfc_current_ns
)
787 gfc_status (" from namespace %s", st
->n
.sym
->ns
->proc_name
->name
);
789 gfc_show_symbol (st
->n
.sym
);
793 /******************* Show gfc_code structures **************/
797 static void gfc_show_code_node (int, gfc_code
*);
799 /* Show a list of code structures. Mutually recursive with
800 gfc_show_code_node(). */
803 gfc_show_code (int level
, gfc_code
*c
)
805 for (; c
; c
= c
->next
)
806 gfc_show_code_node (level
, c
);
810 gfc_show_namelist (gfc_namelist
*n
)
812 for (; n
->next
; n
= n
->next
)
813 gfc_status ("%s,", n
->sym
->name
);
814 gfc_status ("%s", n
->sym
->name
);
817 /* Show a single OpenMP directive node and everything underneath it
821 gfc_show_omp_node (int level
, gfc_code
*c
)
823 gfc_omp_clauses
*omp_clauses
= NULL
;
824 const char *name
= NULL
;
828 case EXEC_OMP_ATOMIC
: name
= "ATOMIC"; break;
829 case EXEC_OMP_BARRIER
: name
= "BARRIER"; break;
830 case EXEC_OMP_CRITICAL
: name
= "CRITICAL"; break;
831 case EXEC_OMP_FLUSH
: name
= "FLUSH"; break;
832 case EXEC_OMP_DO
: name
= "DO"; break;
833 case EXEC_OMP_MASTER
: name
= "MASTER"; break;
834 case EXEC_OMP_ORDERED
: name
= "ORDERED"; break;
835 case EXEC_OMP_PARALLEL
: name
= "PARALLEL"; break;
836 case EXEC_OMP_PARALLEL_DO
: name
= "PARALLEL DO"; break;
837 case EXEC_OMP_PARALLEL_SECTIONS
: name
= "PARALLEL SECTIONS"; break;
838 case EXEC_OMP_PARALLEL_WORKSHARE
: name
= "PARALLEL WORKSHARE"; break;
839 case EXEC_OMP_SECTIONS
: name
= "SECTIONS"; break;
840 case EXEC_OMP_SINGLE
: name
= "SINGLE"; break;
841 case EXEC_OMP_WORKSHARE
: name
= "WORKSHARE"; break;
845 gfc_status ("!$OMP %s", name
);
849 case EXEC_OMP_PARALLEL
:
850 case EXEC_OMP_PARALLEL_DO
:
851 case EXEC_OMP_PARALLEL_SECTIONS
:
852 case EXEC_OMP_SECTIONS
:
853 case EXEC_OMP_SINGLE
:
854 case EXEC_OMP_WORKSHARE
:
855 case EXEC_OMP_PARALLEL_WORKSHARE
:
856 omp_clauses
= c
->ext
.omp_clauses
;
858 case EXEC_OMP_CRITICAL
:
860 gfc_status (" (%s)", c
->ext
.omp_name
);
863 if (c
->ext
.omp_namelist
)
866 gfc_show_namelist (c
->ext
.omp_namelist
);
867 gfc_status_char (')');
870 case EXEC_OMP_BARRIER
:
879 if (omp_clauses
->if_expr
)
882 gfc_show_expr (omp_clauses
->if_expr
);
883 gfc_status_char (')');
885 if (omp_clauses
->num_threads
)
887 gfc_status (" NUM_THREADS(");
888 gfc_show_expr (omp_clauses
->num_threads
);
889 gfc_status_char (')');
891 if (omp_clauses
->sched_kind
!= OMP_SCHED_NONE
)
894 switch (omp_clauses
->sched_kind
)
896 case OMP_SCHED_STATIC
: type
= "STATIC"; break;
897 case OMP_SCHED_DYNAMIC
: type
= "DYNAMIC"; break;
898 case OMP_SCHED_GUIDED
: type
= "GUIDED"; break;
899 case OMP_SCHED_RUNTIME
: type
= "RUNTIME"; break;
903 gfc_status (" SCHEDULE (%s", type
);
904 if (omp_clauses
->chunk_size
)
906 gfc_status_char (',');
907 gfc_show_expr (omp_clauses
->chunk_size
);
909 gfc_status_char (')');
911 if (omp_clauses
->default_sharing
!= OMP_DEFAULT_UNKNOWN
)
914 switch (omp_clauses
->default_sharing
)
916 case OMP_DEFAULT_NONE
: type
= "NONE"; break;
917 case OMP_DEFAULT_PRIVATE
: type
= "PRIVATE"; break;
918 case OMP_DEFAULT_SHARED
: type
= "SHARED"; break;
919 case OMP_SCHED_RUNTIME
: type
= "RUNTIME"; break;
923 gfc_status (" DEFAULT(%s)", type
);
925 if (omp_clauses
->ordered
)
926 gfc_status (" ORDERED");
927 for (list_type
= 0; list_type
< OMP_LIST_NUM
; list_type
++)
928 if (omp_clauses
->lists
[list_type
] != NULL
929 && list_type
!= OMP_LIST_COPYPRIVATE
)
932 if (list_type
>= OMP_LIST_REDUCTION_FIRST
)
936 case OMP_LIST_PLUS
: type
= "+"; break;
937 case OMP_LIST_MULT
: type
= "*"; break;
938 case OMP_LIST_SUB
: type
= "-"; break;
939 case OMP_LIST_AND
: type
= ".AND."; break;
940 case OMP_LIST_OR
: type
= ".OR."; break;
941 case OMP_LIST_EQV
: type
= ".EQV."; break;
942 case OMP_LIST_NEQV
: type
= ".NEQV."; break;
943 case OMP_LIST_MAX
: type
= "MAX"; break;
944 case OMP_LIST_MIN
: type
= "MIN"; break;
945 case OMP_LIST_IAND
: type
= "IAND"; break;
946 case OMP_LIST_IOR
: type
= "IOR"; break;
947 case OMP_LIST_IEOR
: type
= "IEOR"; break;
951 gfc_status (" REDUCTION(%s:", type
);
957 case OMP_LIST_PRIVATE
: type
= "PRIVATE"; break;
958 case OMP_LIST_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
959 case OMP_LIST_LASTPRIVATE
: type
= "LASTPRIVATE"; break;
960 case OMP_LIST_SHARED
: type
= "SHARED"; break;
961 case OMP_LIST_COPYIN
: type
= "COPYIN"; break;
965 gfc_status (" %s(", type
);
967 gfc_show_namelist (omp_clauses
->lists
[list_type
]);
968 gfc_status_char (')');
971 gfc_status_char ('\n');
972 if (c
->op
== EXEC_OMP_SECTIONS
|| c
->op
== EXEC_OMP_PARALLEL_SECTIONS
)
974 gfc_code
*d
= c
->block
;
977 gfc_show_code (level
+ 1, d
->next
);
978 if (d
->block
== NULL
)
980 code_indent (level
, 0);
981 gfc_status ("!$OMP SECTION\n");
986 gfc_show_code (level
+ 1, c
->block
->next
);
987 if (c
->op
== EXEC_OMP_ATOMIC
)
989 code_indent (level
, 0);
990 gfc_status ("!$OMP END %s", name
);
991 if (omp_clauses
!= NULL
)
993 if (omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
])
995 gfc_status (" COPYPRIVATE(");
996 gfc_show_namelist (omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
]);
997 gfc_status_char (')');
999 else if (omp_clauses
->nowait
)
1000 gfc_status (" NOWAIT");
1002 else if (c
->op
== EXEC_OMP_CRITICAL
&& c
->ext
.omp_name
)
1003 gfc_status (" (%s)", c
->ext
.omp_name
);
1007 /* Show a single code node and everything underneath it if necessary. */
1010 gfc_show_code_node (int level
, gfc_code
*c
)
1012 gfc_forall_iterator
*fa
;
1022 code_indent (level
, c
->here
);
1031 gfc_status ("CONTINUE");
1035 gfc_status ("ENTRY %s", c
->ext
.entry
->sym
->name
);
1038 case EXEC_INIT_ASSIGN
:
1040 gfc_status ("ASSIGN ");
1041 gfc_show_expr (c
->expr
);
1042 gfc_status_char (' ');
1043 gfc_show_expr (c
->expr2
);
1046 case EXEC_LABEL_ASSIGN
:
1047 gfc_status ("LABEL ASSIGN ");
1048 gfc_show_expr (c
->expr
);
1049 gfc_status (" %d", c
->label
->value
);
1052 case EXEC_POINTER_ASSIGN
:
1053 gfc_status ("POINTER ASSIGN ");
1054 gfc_show_expr (c
->expr
);
1055 gfc_status_char (' ');
1056 gfc_show_expr (c
->expr2
);
1060 gfc_status ("GOTO ");
1062 gfc_status ("%d", c
->label
->value
);
1065 gfc_show_expr (c
->expr
);
1070 for (; d
; d
= d
->block
)
1072 code_indent (level
, d
->label
);
1073 if (d
->block
!= NULL
)
1074 gfc_status_char (',');
1076 gfc_status_char (')');
1083 if (c
->resolved_sym
)
1084 gfc_status ("CALL %s ", c
->resolved_sym
->name
);
1085 else if (c
->symtree
)
1086 gfc_status ("CALL %s ", c
->symtree
->name
);
1088 gfc_status ("CALL ?? ");
1090 gfc_show_actual_arglist (c
->ext
.actual
);
1094 gfc_status ("RETURN ");
1096 gfc_show_expr (c
->expr
);
1100 gfc_status ("PAUSE ");
1102 if (c
->expr
!= NULL
)
1103 gfc_show_expr (c
->expr
);
1105 gfc_status ("%d", c
->ext
.stop_code
);
1110 gfc_status ("STOP ");
1112 if (c
->expr
!= NULL
)
1113 gfc_show_expr (c
->expr
);
1115 gfc_status ("%d", c
->ext
.stop_code
);
1119 case EXEC_ARITHMETIC_IF
:
1121 gfc_show_expr (c
->expr
);
1122 gfc_status (" %d, %d, %d",
1123 c
->label
->value
, c
->label2
->value
, c
->label3
->value
);
1129 gfc_show_expr (d
->expr
);
1130 gfc_status_char ('\n');
1131 gfc_show_code (level
+ 1, d
->next
);
1134 for (; d
; d
= d
->block
)
1136 code_indent (level
, 0);
1138 if (d
->expr
== NULL
)
1139 gfc_status ("ELSE\n");
1142 gfc_status ("ELSE IF ");
1143 gfc_show_expr (d
->expr
);
1144 gfc_status_char ('\n');
1147 gfc_show_code (level
+ 1, d
->next
);
1150 code_indent (level
, c
->label
);
1152 gfc_status ("ENDIF");
1157 gfc_status ("SELECT CASE ");
1158 gfc_show_expr (c
->expr
);
1159 gfc_status_char ('\n');
1161 for (; d
; d
= d
->block
)
1163 code_indent (level
, 0);
1165 gfc_status ("CASE ");
1166 for (cp
= d
->ext
.case_list
; cp
; cp
= cp
->next
)
1168 gfc_status_char ('(');
1169 gfc_show_expr (cp
->low
);
1170 gfc_status_char (' ');
1171 gfc_show_expr (cp
->high
);
1172 gfc_status_char (')');
1173 gfc_status_char (' ');
1175 gfc_status_char ('\n');
1177 gfc_show_code (level
+ 1, d
->next
);
1180 code_indent (level
, c
->label
);
1181 gfc_status ("END SELECT");
1185 gfc_status ("WHERE ");
1188 gfc_show_expr (d
->expr
);
1189 gfc_status_char ('\n');
1191 gfc_show_code (level
+ 1, d
->next
);
1193 for (d
= d
->block
; d
; d
= d
->block
)
1195 code_indent (level
, 0);
1196 gfc_status ("ELSE WHERE ");
1197 gfc_show_expr (d
->expr
);
1198 gfc_status_char ('\n');
1199 gfc_show_code (level
+ 1, d
->next
);
1202 code_indent (level
, 0);
1203 gfc_status ("END WHERE");
1208 gfc_status ("FORALL ");
1209 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
1211 gfc_show_expr (fa
->var
);
1212 gfc_status_char (' ');
1213 gfc_show_expr (fa
->start
);
1214 gfc_status_char (':');
1215 gfc_show_expr (fa
->end
);
1216 gfc_status_char (':');
1217 gfc_show_expr (fa
->stride
);
1219 if (fa
->next
!= NULL
)
1220 gfc_status_char (',');
1223 if (c
->expr
!= NULL
)
1225 gfc_status_char (',');
1226 gfc_show_expr (c
->expr
);
1228 gfc_status_char ('\n');
1230 gfc_show_code (level
+ 1, c
->block
->next
);
1232 code_indent (level
, 0);
1233 gfc_status ("END FORALL");
1239 gfc_show_expr (c
->ext
.iterator
->var
);
1240 gfc_status_char ('=');
1241 gfc_show_expr (c
->ext
.iterator
->start
);
1242 gfc_status_char (' ');
1243 gfc_show_expr (c
->ext
.iterator
->end
);
1244 gfc_status_char (' ');
1245 gfc_show_expr (c
->ext
.iterator
->step
);
1246 gfc_status_char ('\n');
1248 gfc_show_code (level
+ 1, c
->block
->next
);
1250 code_indent (level
, 0);
1251 gfc_status ("END DO");
1255 gfc_status ("DO WHILE ");
1256 gfc_show_expr (c
->expr
);
1257 gfc_status_char ('\n');
1259 gfc_show_code (level
+ 1, c
->block
->next
);
1261 code_indent (level
, c
->label
);
1262 gfc_status ("END DO");
1266 gfc_status ("CYCLE");
1268 gfc_status (" %s", c
->symtree
->n
.sym
->name
);
1272 gfc_status ("EXIT");
1274 gfc_status (" %s", c
->symtree
->n
.sym
->name
);
1278 gfc_status ("ALLOCATE ");
1281 gfc_status (" STAT=");
1282 gfc_show_expr (c
->expr
);
1285 for (a
= c
->ext
.alloc_list
; a
; a
= a
->next
)
1287 gfc_status_char (' ');
1288 gfc_show_expr (a
->expr
);
1293 case EXEC_DEALLOCATE
:
1294 gfc_status ("DEALLOCATE ");
1297 gfc_status (" STAT=");
1298 gfc_show_expr (c
->expr
);
1301 for (a
= c
->ext
.alloc_list
; a
; a
= a
->next
)
1303 gfc_status_char (' ');
1304 gfc_show_expr (a
->expr
);
1310 gfc_status ("OPEN");
1315 gfc_status (" UNIT=");
1316 gfc_show_expr (open
->unit
);
1320 gfc_status (" IOMSG=");
1321 gfc_show_expr (open
->iomsg
);
1325 gfc_status (" IOSTAT=");
1326 gfc_show_expr (open
->iostat
);
1330 gfc_status (" FILE=");
1331 gfc_show_expr (open
->file
);
1335 gfc_status (" STATUS=");
1336 gfc_show_expr (open
->status
);
1340 gfc_status (" ACCESS=");
1341 gfc_show_expr (open
->access
);
1345 gfc_status (" FORM=");
1346 gfc_show_expr (open
->form
);
1350 gfc_status (" RECL=");
1351 gfc_show_expr (open
->recl
);
1355 gfc_status (" BLANK=");
1356 gfc_show_expr (open
->blank
);
1360 gfc_status (" POSITION=");
1361 gfc_show_expr (open
->position
);
1365 gfc_status (" ACTION=");
1366 gfc_show_expr (open
->action
);
1370 gfc_status (" DELIM=");
1371 gfc_show_expr (open
->delim
);
1375 gfc_status (" PAD=");
1376 gfc_show_expr (open
->pad
);
1380 gfc_status (" CONVERT=");
1381 gfc_show_expr (open
->convert
);
1383 if (open
->err
!= NULL
)
1384 gfc_status (" ERR=%d", open
->err
->value
);
1389 gfc_status ("CLOSE");
1390 close
= c
->ext
.close
;
1394 gfc_status (" UNIT=");
1395 gfc_show_expr (close
->unit
);
1399 gfc_status (" IOMSG=");
1400 gfc_show_expr (close
->iomsg
);
1404 gfc_status (" IOSTAT=");
1405 gfc_show_expr (close
->iostat
);
1409 gfc_status (" STATUS=");
1410 gfc_show_expr (close
->status
);
1412 if (close
->err
!= NULL
)
1413 gfc_status (" ERR=%d", close
->err
->value
);
1416 case EXEC_BACKSPACE
:
1417 gfc_status ("BACKSPACE");
1421 gfc_status ("ENDFILE");
1425 gfc_status ("REWIND");
1429 gfc_status ("FLUSH");
1432 fp
= c
->ext
.filepos
;
1436 gfc_status (" UNIT=");
1437 gfc_show_expr (fp
->unit
);
1441 gfc_status (" IOMSG=");
1442 gfc_show_expr (fp
->iomsg
);
1446 gfc_status (" IOSTAT=");
1447 gfc_show_expr (fp
->iostat
);
1449 if (fp
->err
!= NULL
)
1450 gfc_status (" ERR=%d", fp
->err
->value
);
1454 gfc_status ("INQUIRE");
1459 gfc_status (" UNIT=");
1460 gfc_show_expr (i
->unit
);
1464 gfc_status (" FILE=");
1465 gfc_show_expr (i
->file
);
1470 gfc_status (" IOMSG=");
1471 gfc_show_expr (i
->iomsg
);
1475 gfc_status (" IOSTAT=");
1476 gfc_show_expr (i
->iostat
);
1480 gfc_status (" EXIST=");
1481 gfc_show_expr (i
->exist
);
1485 gfc_status (" OPENED=");
1486 gfc_show_expr (i
->opened
);
1490 gfc_status (" NUMBER=");
1491 gfc_show_expr (i
->number
);
1495 gfc_status (" NAMED=");
1496 gfc_show_expr (i
->named
);
1500 gfc_status (" NAME=");
1501 gfc_show_expr (i
->name
);
1505 gfc_status (" ACCESS=");
1506 gfc_show_expr (i
->access
);
1510 gfc_status (" SEQUENTIAL=");
1511 gfc_show_expr (i
->sequential
);
1516 gfc_status (" DIRECT=");
1517 gfc_show_expr (i
->direct
);
1521 gfc_status (" FORM=");
1522 gfc_show_expr (i
->form
);
1526 gfc_status (" FORMATTED");
1527 gfc_show_expr (i
->formatted
);
1531 gfc_status (" UNFORMATTED=");
1532 gfc_show_expr (i
->unformatted
);
1536 gfc_status (" RECL=");
1537 gfc_show_expr (i
->recl
);
1541 gfc_status (" NEXTREC=");
1542 gfc_show_expr (i
->nextrec
);
1546 gfc_status (" BLANK=");
1547 gfc_show_expr (i
->blank
);
1551 gfc_status (" POSITION=");
1552 gfc_show_expr (i
->position
);
1556 gfc_status (" ACTION=");
1557 gfc_show_expr (i
->action
);
1561 gfc_status (" READ=");
1562 gfc_show_expr (i
->read
);
1566 gfc_status (" WRITE=");
1567 gfc_show_expr (i
->write
);
1571 gfc_status (" READWRITE=");
1572 gfc_show_expr (i
->readwrite
);
1576 gfc_status (" DELIM=");
1577 gfc_show_expr (i
->delim
);
1581 gfc_status (" PAD=");
1582 gfc_show_expr (i
->pad
);
1586 gfc_status (" CONVERT=");
1587 gfc_show_expr (i
->convert
);
1591 gfc_status (" ERR=%d", i
->err
->value
);
1595 gfc_status ("IOLENGTH ");
1596 gfc_show_expr (c
->expr
);
1601 gfc_status ("READ");
1605 gfc_status ("WRITE");
1611 gfc_status (" UNIT=");
1612 gfc_show_expr (dt
->io_unit
);
1615 if (dt
->format_expr
)
1617 gfc_status (" FMT=");
1618 gfc_show_expr (dt
->format_expr
);
1621 if (dt
->format_label
!= NULL
)
1622 gfc_status (" FMT=%d", dt
->format_label
->value
);
1624 gfc_status (" NML=%s", dt
->namelist
->name
);
1628 gfc_status (" IOMSG=");
1629 gfc_show_expr (dt
->iomsg
);
1633 gfc_status (" IOSTAT=");
1634 gfc_show_expr (dt
->iostat
);
1638 gfc_status (" SIZE=");
1639 gfc_show_expr (dt
->size
);
1643 gfc_status (" REC=");
1644 gfc_show_expr (dt
->rec
);
1648 gfc_status (" ADVANCE=");
1649 gfc_show_expr (dt
->advance
);
1653 gfc_status_char ('\n');
1654 for (c
= c
->block
->next
; c
; c
= c
->next
)
1655 gfc_show_code_node (level
+ (c
->next
!= NULL
), c
);
1659 gfc_status ("TRANSFER ");
1660 gfc_show_expr (c
->expr
);
1664 gfc_status ("DT_END");
1667 if (dt
->err
!= NULL
)
1668 gfc_status (" ERR=%d", dt
->err
->value
);
1669 if (dt
->end
!= NULL
)
1670 gfc_status (" END=%d", dt
->end
->value
);
1671 if (dt
->eor
!= NULL
)
1672 gfc_status (" EOR=%d", dt
->eor
->value
);
1675 case EXEC_OMP_ATOMIC
:
1676 case EXEC_OMP_BARRIER
:
1677 case EXEC_OMP_CRITICAL
:
1678 case EXEC_OMP_FLUSH
:
1680 case EXEC_OMP_MASTER
:
1681 case EXEC_OMP_ORDERED
:
1682 case EXEC_OMP_PARALLEL
:
1683 case EXEC_OMP_PARALLEL_DO
:
1684 case EXEC_OMP_PARALLEL_SECTIONS
:
1685 case EXEC_OMP_PARALLEL_WORKSHARE
:
1686 case EXEC_OMP_SECTIONS
:
1687 case EXEC_OMP_SINGLE
:
1688 case EXEC_OMP_WORKSHARE
:
1689 gfc_show_omp_node (level
, c
);
1693 gfc_internal_error ("gfc_show_code_node(): Bad statement code");
1696 gfc_status_char ('\n');
1700 /* Show an equivalence chain. */
1703 gfc_show_equiv (gfc_equiv
*eq
)
1706 gfc_status ("Equivalence: ");
1709 gfc_show_expr (eq
->expr
);
1717 /* Show a freakin' whole namespace. */
1720 gfc_show_namespace (gfc_namespace
*ns
)
1722 gfc_interface
*intr
;
1723 gfc_namespace
*save
;
1724 gfc_intrinsic_op op
;
1728 save
= gfc_current_ns
;
1732 gfc_status ("Namespace:");
1740 while (i
< GFC_LETTERS
- 1
1741 && gfc_compare_types(&ns
->default_type
[i
+1],
1742 &ns
->default_type
[l
]))
1746 gfc_status(" %c-%c: ", l
+'A', i
+'A');
1748 gfc_status(" %c: ", l
+'A');
1750 gfc_show_typespec(&ns
->default_type
[l
]);
1752 } while (i
< GFC_LETTERS
);
1754 if (ns
->proc_name
!= NULL
)
1757 gfc_status ("procedure name = %s", ns
->proc_name
->name
);
1760 gfc_current_ns
= ns
;
1761 gfc_traverse_symtree (ns
->common_root
, show_common
);
1763 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
1765 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; op
++)
1767 /* User operator interfaces */
1768 intr
= ns
->operator[op
];
1773 gfc_status ("Operator interfaces for %s:", gfc_op2string (op
));
1775 for (; intr
; intr
= intr
->next
)
1776 gfc_status (" %s", intr
->sym
->name
);
1779 if (ns
->uop_root
!= NULL
)
1782 gfc_status ("User operators:\n");
1783 gfc_traverse_user_op (ns
, show_uop
);
1787 for (eq
= ns
->equiv
; eq
; eq
= eq
->next
)
1788 gfc_show_equiv (eq
);
1790 gfc_status_char ('\n');
1791 gfc_status_char ('\n');
1793 gfc_show_code (0, ns
->code
);
1795 for (ns
= ns
->contained
; ns
; ns
= ns
->sibling
)
1798 gfc_status ("CONTAINS\n");
1799 gfc_show_namespace (ns
);
1803 gfc_status_char ('\n');
1804 gfc_current_ns
= save
;