1760c2415Smrg /* Parse tree dumper
2*0bfacb9bSmrg    Copyright (C) 2003-2020 Free Software Foundation, Inc.
3760c2415Smrg    Contributed by Steven Bosscher
4760c2415Smrg 
5760c2415Smrg This file is part of GCC.
6760c2415Smrg 
7760c2415Smrg GCC is free software; you can redistribute it and/or modify it under
8760c2415Smrg the terms of the GNU General Public License as published by the Free
9760c2415Smrg Software Foundation; either version 3, or (at your option) any later
10760c2415Smrg version.
11760c2415Smrg 
12760c2415Smrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13760c2415Smrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
14760c2415Smrg FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15760c2415Smrg for more details.
16760c2415Smrg 
17760c2415Smrg You should have received a copy of the GNU General Public License
18760c2415Smrg along with GCC; see the file COPYING3.  If not see
19760c2415Smrg <http://www.gnu.org/licenses/>.  */
20760c2415Smrg 
21760c2415Smrg 
22760c2415Smrg /* Actually this is just a collection of routines that used to be
23760c2415Smrg    scattered around the sources.  Now that they are all in a single
24760c2415Smrg    file, almost all of them can be static, and the other files don't
25760c2415Smrg    have this mess in them.
26760c2415Smrg 
27760c2415Smrg    As a nice side-effect, this file can act as documentation of the
28760c2415Smrg    gfc_code and gfc_expr structures and all their friends and
29760c2415Smrg    relatives.
30760c2415Smrg 
31760c2415Smrg    TODO: Dump DATA.  */
32760c2415Smrg 
33760c2415Smrg #include "config.h"
34760c2415Smrg #include "system.h"
35760c2415Smrg #include "coretypes.h"
36760c2415Smrg #include "gfortran.h"
37760c2415Smrg #include "constructor.h"
38760c2415Smrg #include "version.h"
39760c2415Smrg 
40760c2415Smrg /* Keep track of indentation for symbol tree dumps.  */
41760c2415Smrg static int show_level = 0;
42760c2415Smrg 
43760c2415Smrg /* The file handle we're dumping to is kept in a static variable.  This
44760c2415Smrg    is not too cool, but it avoids a lot of passing it around.  */
45760c2415Smrg static FILE *dumpfile;
46760c2415Smrg 
47760c2415Smrg /* Forward declaration of some of the functions.  */
48760c2415Smrg static void show_expr (gfc_expr *p);
49760c2415Smrg static void show_code_node (int, gfc_code *);
50760c2415Smrg static void show_namespace (gfc_namespace *ns);
51760c2415Smrg static void show_code (int, gfc_code *);
52760c2415Smrg static void show_symbol (gfc_symbol *);
53760c2415Smrg static void show_typespec (gfc_typespec *);
54760c2415Smrg static void show_ref (gfc_ref *);
55760c2415Smrg static void show_attr (symbol_attribute *, const char *);
56760c2415Smrg 
57760c2415Smrg /* Allow dumping of an expression in the debugger.  */
58760c2415Smrg void gfc_debug_expr (gfc_expr *);
59760c2415Smrg 
debug(symbol_attribute * attr)60760c2415Smrg void debug (symbol_attribute *attr)
61760c2415Smrg {
62760c2415Smrg   FILE *tmp = dumpfile;
63760c2415Smrg   dumpfile = stderr;
64760c2415Smrg   show_attr (attr, NULL);
65760c2415Smrg   fputc ('\n', dumpfile);
66760c2415Smrg   dumpfile = tmp;
67760c2415Smrg }
68760c2415Smrg 
debug(gfc_formal_arglist * formal)69*0bfacb9bSmrg void debug (gfc_formal_arglist *formal)
70*0bfacb9bSmrg {
71*0bfacb9bSmrg   FILE *tmp = dumpfile;
72*0bfacb9bSmrg   dumpfile = stderr;
73*0bfacb9bSmrg   for (; formal; formal = formal->next)
74*0bfacb9bSmrg     {
75*0bfacb9bSmrg       fputc ('\n', dumpfile);
76*0bfacb9bSmrg       show_symbol (formal->sym);
77*0bfacb9bSmrg     }
78*0bfacb9bSmrg   fputc ('\n', dumpfile);
79*0bfacb9bSmrg   dumpfile = tmp;
80*0bfacb9bSmrg }
81*0bfacb9bSmrg 
debug(symbol_attribute attr)82760c2415Smrg void debug (symbol_attribute attr)
83760c2415Smrg {
84760c2415Smrg   debug (&attr);
85760c2415Smrg }
86760c2415Smrg 
debug(gfc_expr * e)87760c2415Smrg void debug (gfc_expr *e)
88760c2415Smrg {
89760c2415Smrg   FILE *tmp = dumpfile;
90760c2415Smrg   dumpfile = stderr;
91*0bfacb9bSmrg   if (e != NULL)
92*0bfacb9bSmrg     {
93760c2415Smrg       show_expr (e);
94760c2415Smrg       fputc (' ', dumpfile);
95760c2415Smrg       show_typespec (&e->ts);
96*0bfacb9bSmrg     }
97*0bfacb9bSmrg   else
98*0bfacb9bSmrg     fputs ("() ", dumpfile);
99*0bfacb9bSmrg 
100760c2415Smrg   fputc ('\n', dumpfile);
101760c2415Smrg   dumpfile = tmp;
102760c2415Smrg }
103760c2415Smrg 
debug(gfc_typespec * ts)104760c2415Smrg void debug (gfc_typespec *ts)
105760c2415Smrg {
106760c2415Smrg   FILE *tmp = dumpfile;
107760c2415Smrg   dumpfile = stderr;
108760c2415Smrg   show_typespec (ts);
109760c2415Smrg   fputc ('\n', dumpfile);
110760c2415Smrg   dumpfile = tmp;
111760c2415Smrg }
112760c2415Smrg 
debug(gfc_typespec ts)113760c2415Smrg void debug (gfc_typespec ts)
114760c2415Smrg {
115760c2415Smrg   debug (&ts);
116760c2415Smrg }
117760c2415Smrg 
debug(gfc_ref * p)118760c2415Smrg void debug (gfc_ref *p)
119760c2415Smrg {
120760c2415Smrg   FILE *tmp = dumpfile;
121760c2415Smrg   dumpfile = stderr;
122760c2415Smrg   show_ref (p);
123760c2415Smrg   fputc ('\n', dumpfile);
124760c2415Smrg   dumpfile = tmp;
125760c2415Smrg }
126760c2415Smrg 
127760c2415Smrg void
gfc_debug_expr(gfc_expr * e)128760c2415Smrg gfc_debug_expr (gfc_expr *e)
129760c2415Smrg {
130760c2415Smrg   FILE *tmp = dumpfile;
131760c2415Smrg   dumpfile = stderr;
132760c2415Smrg   show_expr (e);
133760c2415Smrg   fputc ('\n', dumpfile);
134760c2415Smrg   dumpfile = tmp;
135760c2415Smrg }
136760c2415Smrg 
137760c2415Smrg /* Allow for dumping of a piece of code in the debugger.  */
138760c2415Smrg void gfc_debug_code (gfc_code *c);
139760c2415Smrg 
140760c2415Smrg void
gfc_debug_code(gfc_code * c)141760c2415Smrg gfc_debug_code (gfc_code *c)
142760c2415Smrg {
143760c2415Smrg   FILE *tmp = dumpfile;
144760c2415Smrg   dumpfile = stderr;
145760c2415Smrg   show_code (1, c);
146760c2415Smrg   fputc ('\n', dumpfile);
147760c2415Smrg   dumpfile = tmp;
148760c2415Smrg }
149760c2415Smrg 
debug(gfc_symbol * sym)150760c2415Smrg void debug (gfc_symbol *sym)
151760c2415Smrg {
152760c2415Smrg   FILE *tmp = dumpfile;
153760c2415Smrg   dumpfile = stderr;
154760c2415Smrg   show_symbol (sym);
155760c2415Smrg   fputc ('\n', dumpfile);
156760c2415Smrg   dumpfile = tmp;
157760c2415Smrg }
158760c2415Smrg 
159760c2415Smrg /* Do indentation for a specific level.  */
160760c2415Smrg 
161760c2415Smrg static inline void
code_indent(int level,gfc_st_label * label)162760c2415Smrg code_indent (int level, gfc_st_label *label)
163760c2415Smrg {
164760c2415Smrg   int i;
165760c2415Smrg 
166760c2415Smrg   if (label != NULL)
167760c2415Smrg     fprintf (dumpfile, "%-5d ", label->value);
168760c2415Smrg 
169760c2415Smrg   for (i = 0; i < (2 * level - (label ? 6 : 0)); i++)
170760c2415Smrg     fputc (' ', dumpfile);
171760c2415Smrg }
172760c2415Smrg 
173760c2415Smrg 
174760c2415Smrg /* Simple indentation at the current level.  This one
175760c2415Smrg    is used to show symbols.  */
176760c2415Smrg 
177760c2415Smrg static inline void
show_indent(void)178760c2415Smrg show_indent (void)
179760c2415Smrg {
180760c2415Smrg   fputc ('\n', dumpfile);
181760c2415Smrg   code_indent (show_level, NULL);
182760c2415Smrg }
183760c2415Smrg 
184760c2415Smrg 
185760c2415Smrg /* Show type-specific information.  */
186760c2415Smrg 
187760c2415Smrg static void
show_typespec(gfc_typespec * ts)188760c2415Smrg show_typespec (gfc_typespec *ts)
189760c2415Smrg {
190760c2415Smrg   if (ts->type == BT_ASSUMED)
191760c2415Smrg     {
192760c2415Smrg       fputs ("(TYPE(*))", dumpfile);
193760c2415Smrg       return;
194760c2415Smrg     }
195760c2415Smrg 
196760c2415Smrg   fprintf (dumpfile, "(%s ", gfc_basic_typename (ts->type));
197760c2415Smrg 
198760c2415Smrg   switch (ts->type)
199760c2415Smrg     {
200760c2415Smrg     case BT_DERIVED:
201760c2415Smrg     case BT_CLASS:
202760c2415Smrg     case BT_UNION:
203760c2415Smrg       fprintf (dumpfile, "%s", ts->u.derived->name);
204760c2415Smrg       break;
205760c2415Smrg 
206760c2415Smrg     case BT_CHARACTER:
207760c2415Smrg       if (ts->u.cl)
208760c2415Smrg 	show_expr (ts->u.cl->length);
209760c2415Smrg       fprintf(dumpfile, " %d", ts->kind);
210760c2415Smrg       break;
211760c2415Smrg 
212760c2415Smrg     default:
213760c2415Smrg       fprintf (dumpfile, "%d", ts->kind);
214760c2415Smrg       break;
215760c2415Smrg     }
216760c2415Smrg   if (ts->is_c_interop)
217760c2415Smrg     fputs (" C_INTEROP", dumpfile);
218760c2415Smrg 
219760c2415Smrg   if (ts->is_iso_c)
220760c2415Smrg     fputs (" ISO_C", dumpfile);
221760c2415Smrg 
222760c2415Smrg   if (ts->deferred)
223760c2415Smrg     fputs (" DEFERRED", dumpfile);
224760c2415Smrg 
225760c2415Smrg   fputc (')', dumpfile);
226760c2415Smrg }
227760c2415Smrg 
228760c2415Smrg 
229760c2415Smrg /* Show an actual argument list.  */
230760c2415Smrg 
231760c2415Smrg static void
show_actual_arglist(gfc_actual_arglist * a)232760c2415Smrg show_actual_arglist (gfc_actual_arglist *a)
233760c2415Smrg {
234760c2415Smrg   fputc ('(', dumpfile);
235760c2415Smrg 
236760c2415Smrg   for (; a; a = a->next)
237760c2415Smrg     {
238760c2415Smrg       fputc ('(', dumpfile);
239760c2415Smrg       if (a->name != NULL)
240760c2415Smrg 	fprintf (dumpfile, "%s = ", a->name);
241760c2415Smrg       if (a->expr != NULL)
242760c2415Smrg 	show_expr (a->expr);
243760c2415Smrg       else
244760c2415Smrg 	fputs ("(arg not-present)", dumpfile);
245760c2415Smrg 
246760c2415Smrg       fputc (')', dumpfile);
247760c2415Smrg       if (a->next != NULL)
248760c2415Smrg 	fputc (' ', dumpfile);
249760c2415Smrg     }
250760c2415Smrg 
251760c2415Smrg   fputc (')', dumpfile);
252760c2415Smrg }
253760c2415Smrg 
254760c2415Smrg 
255760c2415Smrg /* Show a gfc_array_spec array specification structure.  */
256760c2415Smrg 
257760c2415Smrg static void
show_array_spec(gfc_array_spec * as)258760c2415Smrg show_array_spec (gfc_array_spec *as)
259760c2415Smrg {
260760c2415Smrg   const char *c;
261760c2415Smrg   int i;
262760c2415Smrg 
263760c2415Smrg   if (as == NULL)
264760c2415Smrg     {
265760c2415Smrg       fputs ("()", dumpfile);
266760c2415Smrg       return;
267760c2415Smrg     }
268760c2415Smrg 
269760c2415Smrg   fprintf (dumpfile, "(%d [%d]", as->rank, as->corank);
270760c2415Smrg 
271760c2415Smrg   if (as->rank + as->corank > 0 || as->rank == -1)
272760c2415Smrg     {
273760c2415Smrg       switch (as->type)
274760c2415Smrg       {
275760c2415Smrg 	case AS_EXPLICIT:      c = "AS_EXPLICIT";      break;
276760c2415Smrg 	case AS_DEFERRED:      c = "AS_DEFERRED";      break;
277760c2415Smrg 	case AS_ASSUMED_SIZE:  c = "AS_ASSUMED_SIZE";  break;
278760c2415Smrg 	case AS_ASSUMED_SHAPE: c = "AS_ASSUMED_SHAPE"; break;
279760c2415Smrg 	case AS_ASSUMED_RANK:  c = "AS_ASSUMED_RANK";  break;
280760c2415Smrg 	default:
281760c2415Smrg 	  gfc_internal_error ("show_array_spec(): Unhandled array shape "
282760c2415Smrg 			      "type.");
283760c2415Smrg       }
284760c2415Smrg       fprintf (dumpfile, " %s ", c);
285760c2415Smrg 
286760c2415Smrg       for (i = 0; i < as->rank + as->corank; i++)
287760c2415Smrg 	{
288760c2415Smrg 	  show_expr (as->lower[i]);
289760c2415Smrg 	  fputc (' ', dumpfile);
290760c2415Smrg 	  show_expr (as->upper[i]);
291760c2415Smrg 	  fputc (' ', dumpfile);
292760c2415Smrg 	}
293760c2415Smrg     }
294760c2415Smrg 
295760c2415Smrg   fputc (')', dumpfile);
296760c2415Smrg }
297760c2415Smrg 
298760c2415Smrg 
299760c2415Smrg /* Show a gfc_array_ref array reference structure.  */
300760c2415Smrg 
301760c2415Smrg static void
show_array_ref(gfc_array_ref * ar)302760c2415Smrg show_array_ref (gfc_array_ref * ar)
303760c2415Smrg {
304760c2415Smrg   int i;
305760c2415Smrg 
306760c2415Smrg   fputc ('(', dumpfile);
307760c2415Smrg 
308760c2415Smrg   switch (ar->type)
309760c2415Smrg     {
310760c2415Smrg     case AR_FULL:
311760c2415Smrg       fputs ("FULL", dumpfile);
312760c2415Smrg       break;
313760c2415Smrg 
314760c2415Smrg     case AR_SECTION:
315760c2415Smrg       for (i = 0; i < ar->dimen; i++)
316760c2415Smrg 	{
317760c2415Smrg 	  /* There are two types of array sections: either the
318760c2415Smrg 	     elements are identified by an integer array ('vector'),
319760c2415Smrg 	     or by an index range. In the former case we only have to
320760c2415Smrg 	     print the start expression which contains the vector, in
321760c2415Smrg 	     the latter case we have to print any of lower and upper
322760c2415Smrg 	     bound and the stride, if they're present.  */
323760c2415Smrg 
324760c2415Smrg 	  if (ar->start[i] != NULL)
325760c2415Smrg 	    show_expr (ar->start[i]);
326760c2415Smrg 
327760c2415Smrg 	  if (ar->dimen_type[i] == DIMEN_RANGE)
328760c2415Smrg 	    {
329760c2415Smrg 	      fputc (':', dumpfile);
330760c2415Smrg 
331760c2415Smrg 	      if (ar->end[i] != NULL)
332760c2415Smrg 		show_expr (ar->end[i]);
333760c2415Smrg 
334760c2415Smrg 	      if (ar->stride[i] != NULL)
335760c2415Smrg 		{
336760c2415Smrg 		  fputc (':', dumpfile);
337760c2415Smrg 		  show_expr (ar->stride[i]);
338760c2415Smrg 		}
339760c2415Smrg 	    }
340760c2415Smrg 
341760c2415Smrg 	  if (i != ar->dimen - 1)
342760c2415Smrg 	    fputs (" , ", dumpfile);
343760c2415Smrg 	}
344760c2415Smrg       break;
345760c2415Smrg 
346760c2415Smrg     case AR_ELEMENT:
347760c2415Smrg       for (i = 0; i < ar->dimen; i++)
348760c2415Smrg 	{
349760c2415Smrg 	  show_expr (ar->start[i]);
350760c2415Smrg 	  if (i != ar->dimen - 1)
351760c2415Smrg 	    fputs (" , ", dumpfile);
352760c2415Smrg 	}
353760c2415Smrg       break;
354760c2415Smrg 
355760c2415Smrg     case AR_UNKNOWN:
356760c2415Smrg       fputs ("UNKNOWN", dumpfile);
357760c2415Smrg       break;
358760c2415Smrg 
359760c2415Smrg     default:
360760c2415Smrg       gfc_internal_error ("show_array_ref(): Unknown array reference");
361760c2415Smrg     }
362760c2415Smrg 
363760c2415Smrg   fputc (')', dumpfile);
364760c2415Smrg }
365760c2415Smrg 
366760c2415Smrg 
367760c2415Smrg /* Show a list of gfc_ref structures.  */
368760c2415Smrg 
369760c2415Smrg static void
show_ref(gfc_ref * p)370760c2415Smrg show_ref (gfc_ref *p)
371760c2415Smrg {
372760c2415Smrg   for (; p; p = p->next)
373760c2415Smrg     switch (p->type)
374760c2415Smrg       {
375760c2415Smrg       case REF_ARRAY:
376760c2415Smrg 	show_array_ref (&p->u.ar);
377760c2415Smrg 	break;
378760c2415Smrg 
379760c2415Smrg       case REF_COMPONENT:
380760c2415Smrg 	fprintf (dumpfile, " %% %s", p->u.c.component->name);
381760c2415Smrg 	break;
382760c2415Smrg 
383760c2415Smrg       case REF_SUBSTRING:
384760c2415Smrg 	fputc ('(', dumpfile);
385760c2415Smrg 	show_expr (p->u.ss.start);
386760c2415Smrg 	fputc (':', dumpfile);
387760c2415Smrg 	show_expr (p->u.ss.end);
388760c2415Smrg 	fputc (')', dumpfile);
389760c2415Smrg 	break;
390760c2415Smrg 
391760c2415Smrg       case REF_INQUIRY:
392760c2415Smrg 	switch (p->u.i)
393760c2415Smrg 	{
394760c2415Smrg 	  case INQUIRY_KIND:
395760c2415Smrg 	    fprintf (dumpfile, " INQUIRY_KIND ");
396760c2415Smrg 	    break;
397760c2415Smrg 	  case INQUIRY_LEN:
398760c2415Smrg 	    fprintf (dumpfile, " INQUIRY_LEN ");
399760c2415Smrg 	    break;
400760c2415Smrg 	  case INQUIRY_RE:
401760c2415Smrg 	    fprintf (dumpfile, " INQUIRY_RE ");
402760c2415Smrg 	    break;
403760c2415Smrg 	  case INQUIRY_IM:
404760c2415Smrg 	    fprintf (dumpfile, " INQUIRY_IM ");
405760c2415Smrg 	}
406760c2415Smrg 	break;
407760c2415Smrg 
408760c2415Smrg       default:
409760c2415Smrg 	gfc_internal_error ("show_ref(): Bad component code");
410760c2415Smrg       }
411760c2415Smrg }
412760c2415Smrg 
413760c2415Smrg 
414760c2415Smrg /* Display a constructor.  Works recursively for array constructors.  */
415760c2415Smrg 
416760c2415Smrg static void
show_constructor(gfc_constructor_base base)417760c2415Smrg show_constructor (gfc_constructor_base base)
418760c2415Smrg {
419760c2415Smrg   gfc_constructor *c;
420760c2415Smrg   for (c = gfc_constructor_first (base); c; c = gfc_constructor_next (c))
421760c2415Smrg     {
422760c2415Smrg       if (c->iterator == NULL)
423760c2415Smrg 	show_expr (c->expr);
424760c2415Smrg       else
425760c2415Smrg 	{
426760c2415Smrg 	  fputc ('(', dumpfile);
427760c2415Smrg 	  show_expr (c->expr);
428760c2415Smrg 
429760c2415Smrg 	  fputc (' ', dumpfile);
430760c2415Smrg 	  show_expr (c->iterator->var);
431760c2415Smrg 	  fputc ('=', dumpfile);
432760c2415Smrg 	  show_expr (c->iterator->start);
433760c2415Smrg 	  fputc (',', dumpfile);
434760c2415Smrg 	  show_expr (c->iterator->end);
435760c2415Smrg 	  fputc (',', dumpfile);
436760c2415Smrg 	  show_expr (c->iterator->step);
437760c2415Smrg 
438760c2415Smrg 	  fputc (')', dumpfile);
439760c2415Smrg 	}
440760c2415Smrg 
441760c2415Smrg       if (gfc_constructor_next (c) != NULL)
442760c2415Smrg 	fputs (" , ", dumpfile);
443760c2415Smrg     }
444760c2415Smrg }
445760c2415Smrg 
446760c2415Smrg 
447760c2415Smrg static void
show_char_const(const gfc_char_t * c,gfc_charlen_t length)448760c2415Smrg show_char_const (const gfc_char_t *c, gfc_charlen_t length)
449760c2415Smrg {
450760c2415Smrg   fputc ('\'', dumpfile);
451760c2415Smrg   for (size_t i = 0; i < (size_t) length; i++)
452760c2415Smrg     {
453760c2415Smrg       if (c[i] == '\'')
454760c2415Smrg 	fputs ("''", dumpfile);
455760c2415Smrg       else
456760c2415Smrg 	fputs (gfc_print_wide_char (c[i]), dumpfile);
457760c2415Smrg     }
458760c2415Smrg   fputc ('\'', dumpfile);
459760c2415Smrg }
460760c2415Smrg 
461760c2415Smrg 
462760c2415Smrg /* Show a component-call expression.  */
463760c2415Smrg 
464760c2415Smrg static void
show_compcall(gfc_expr * p)465760c2415Smrg show_compcall (gfc_expr* p)
466760c2415Smrg {
467760c2415Smrg   gcc_assert (p->expr_type == EXPR_COMPCALL);
468760c2415Smrg 
469760c2415Smrg   fprintf (dumpfile, "%s", p->symtree->n.sym->name);
470760c2415Smrg   show_ref (p->ref);
471760c2415Smrg   fprintf (dumpfile, "%s", p->value.compcall.name);
472760c2415Smrg 
473760c2415Smrg   show_actual_arglist (p->value.compcall.actual);
474760c2415Smrg }
475760c2415Smrg 
476760c2415Smrg 
477760c2415Smrg /* Show an expression.  */
478760c2415Smrg 
479760c2415Smrg static void
show_expr(gfc_expr * p)480760c2415Smrg show_expr (gfc_expr *p)
481760c2415Smrg {
482760c2415Smrg   const char *c;
483760c2415Smrg   int i;
484760c2415Smrg 
485760c2415Smrg   if (p == NULL)
486760c2415Smrg     {
487760c2415Smrg       fputs ("()", dumpfile);
488760c2415Smrg       return;
489760c2415Smrg     }
490760c2415Smrg 
491760c2415Smrg   switch (p->expr_type)
492760c2415Smrg     {
493760c2415Smrg     case EXPR_SUBSTRING:
494760c2415Smrg       show_char_const (p->value.character.string, p->value.character.length);
495760c2415Smrg       show_ref (p->ref);
496760c2415Smrg       break;
497760c2415Smrg 
498760c2415Smrg     case EXPR_STRUCTURE:
499760c2415Smrg       fprintf (dumpfile, "%s(", p->ts.u.derived->name);
500760c2415Smrg       show_constructor (p->value.constructor);
501760c2415Smrg       fputc (')', dumpfile);
502760c2415Smrg       break;
503760c2415Smrg 
504760c2415Smrg     case EXPR_ARRAY:
505760c2415Smrg       fputs ("(/ ", dumpfile);
506760c2415Smrg       show_constructor (p->value.constructor);
507760c2415Smrg       fputs (" /)", dumpfile);
508760c2415Smrg 
509760c2415Smrg       show_ref (p->ref);
510760c2415Smrg       break;
511760c2415Smrg 
512760c2415Smrg     case EXPR_NULL:
513760c2415Smrg       fputs ("NULL()", dumpfile);
514760c2415Smrg       break;
515760c2415Smrg 
516760c2415Smrg     case EXPR_CONSTANT:
517760c2415Smrg       switch (p->ts.type)
518760c2415Smrg 	{
519760c2415Smrg 	case BT_INTEGER:
520760c2415Smrg 	  mpz_out_str (dumpfile, 10, p->value.integer);
521760c2415Smrg 
522760c2415Smrg 	  if (p->ts.kind != gfc_default_integer_kind)
523760c2415Smrg 	    fprintf (dumpfile, "_%d", p->ts.kind);
524760c2415Smrg 	  break;
525760c2415Smrg 
526760c2415Smrg 	case BT_LOGICAL:
527760c2415Smrg 	  if (p->value.logical)
528760c2415Smrg 	    fputs (".true.", dumpfile);
529760c2415Smrg 	  else
530760c2415Smrg 	    fputs (".false.", dumpfile);
531760c2415Smrg 	  break;
532760c2415Smrg 
533760c2415Smrg 	case BT_REAL:
534760c2415Smrg 	  mpfr_out_str (dumpfile, 10, 0, p->value.real, GFC_RND_MODE);
535760c2415Smrg 	  if (p->ts.kind != gfc_default_real_kind)
536760c2415Smrg 	    fprintf (dumpfile, "_%d", p->ts.kind);
537760c2415Smrg 	  break;
538760c2415Smrg 
539760c2415Smrg 	case BT_CHARACTER:
540760c2415Smrg 	  show_char_const (p->value.character.string,
541760c2415Smrg 			   p->value.character.length);
542760c2415Smrg 	  break;
543760c2415Smrg 
544760c2415Smrg 	case BT_COMPLEX:
545760c2415Smrg 	  fputs ("(complex ", dumpfile);
546760c2415Smrg 
547760c2415Smrg 	  mpfr_out_str (dumpfile, 10, 0, mpc_realref (p->value.complex),
548760c2415Smrg 			GFC_RND_MODE);
549760c2415Smrg 	  if (p->ts.kind != gfc_default_complex_kind)
550760c2415Smrg 	    fprintf (dumpfile, "_%d", p->ts.kind);
551760c2415Smrg 
552760c2415Smrg 	  fputc (' ', dumpfile);
553760c2415Smrg 
554760c2415Smrg 	  mpfr_out_str (dumpfile, 10, 0, mpc_imagref (p->value.complex),
555760c2415Smrg 			GFC_RND_MODE);
556760c2415Smrg 	  if (p->ts.kind != gfc_default_complex_kind)
557760c2415Smrg 	    fprintf (dumpfile, "_%d", p->ts.kind);
558760c2415Smrg 
559760c2415Smrg 	  fputc (')', dumpfile);
560760c2415Smrg 	  break;
561760c2415Smrg 
562*0bfacb9bSmrg 	case BT_BOZ:
563*0bfacb9bSmrg 	  if (p->boz.rdx == 2)
564*0bfacb9bSmrg 	    fputs ("b'", dumpfile);
565*0bfacb9bSmrg 	  else if (p->boz.rdx == 8)
566*0bfacb9bSmrg 	    fputs ("o'", dumpfile);
567*0bfacb9bSmrg 	  else
568*0bfacb9bSmrg 	    fputs ("z'", dumpfile);
569*0bfacb9bSmrg 	  fprintf (dumpfile, "%s'", p->boz.str);
570*0bfacb9bSmrg 	  break;
571*0bfacb9bSmrg 
572760c2415Smrg 	case BT_HOLLERITH:
573760c2415Smrg 	  fprintf (dumpfile, HOST_WIDE_INT_PRINT_DEC "H",
574760c2415Smrg 		   p->representation.length);
575760c2415Smrg 	  c = p->representation.string;
576760c2415Smrg 	  for (i = 0; i < p->representation.length; i++, c++)
577760c2415Smrg 	    {
578760c2415Smrg 	      fputc (*c, dumpfile);
579760c2415Smrg 	    }
580760c2415Smrg 	  break;
581760c2415Smrg 
582760c2415Smrg 	default:
583760c2415Smrg 	  fputs ("???", dumpfile);
584760c2415Smrg 	  break;
585760c2415Smrg 	}
586760c2415Smrg 
587760c2415Smrg       if (p->representation.string)
588760c2415Smrg 	{
589760c2415Smrg 	  fputs (" {", dumpfile);
590760c2415Smrg 	  c = p->representation.string;
591760c2415Smrg 	  for (i = 0; i < p->representation.length; i++, c++)
592760c2415Smrg 	    {
593760c2415Smrg 	      fprintf (dumpfile, "%.2x", (unsigned int) *c);
594760c2415Smrg 	      if (i < p->representation.length - 1)
595760c2415Smrg 		fputc (',', dumpfile);
596760c2415Smrg 	    }
597760c2415Smrg 	  fputc ('}', dumpfile);
598760c2415Smrg 	}
599760c2415Smrg 
600760c2415Smrg       break;
601760c2415Smrg 
602760c2415Smrg     case EXPR_VARIABLE:
603760c2415Smrg       if (p->symtree->n.sym->ns && p->symtree->n.sym->ns->proc_name)
604760c2415Smrg 	fprintf (dumpfile, "%s:", p->symtree->n.sym->ns->proc_name->name);
605760c2415Smrg       fprintf (dumpfile, "%s", p->symtree->n.sym->name);
606760c2415Smrg       show_ref (p->ref);
607760c2415Smrg       break;
608760c2415Smrg 
609760c2415Smrg     case EXPR_OP:
610760c2415Smrg       fputc ('(', dumpfile);
611760c2415Smrg       switch (p->value.op.op)
612760c2415Smrg 	{
613760c2415Smrg 	case INTRINSIC_UPLUS:
614760c2415Smrg 	  fputs ("U+ ", dumpfile);
615760c2415Smrg 	  break;
616760c2415Smrg 	case INTRINSIC_UMINUS:
617760c2415Smrg 	  fputs ("U- ", dumpfile);
618760c2415Smrg 	  break;
619760c2415Smrg 	case INTRINSIC_PLUS:
620760c2415Smrg 	  fputs ("+ ", dumpfile);
621760c2415Smrg 	  break;
622760c2415Smrg 	case INTRINSIC_MINUS:
623760c2415Smrg 	  fputs ("- ", dumpfile);
624760c2415Smrg 	  break;
625760c2415Smrg 	case INTRINSIC_TIMES:
626760c2415Smrg 	  fputs ("* ", dumpfile);
627760c2415Smrg 	  break;
628760c2415Smrg 	case INTRINSIC_DIVIDE:
629760c2415Smrg 	  fputs ("/ ", dumpfile);
630760c2415Smrg 	  break;
631760c2415Smrg 	case INTRINSIC_POWER:
632760c2415Smrg 	  fputs ("** ", dumpfile);
633760c2415Smrg 	  break;
634760c2415Smrg 	case INTRINSIC_CONCAT:
635760c2415Smrg 	  fputs ("// ", dumpfile);
636760c2415Smrg 	  break;
637760c2415Smrg 	case INTRINSIC_AND:
638760c2415Smrg 	  fputs ("AND ", dumpfile);
639760c2415Smrg 	  break;
640760c2415Smrg 	case INTRINSIC_OR:
641760c2415Smrg 	  fputs ("OR ", dumpfile);
642760c2415Smrg 	  break;
643760c2415Smrg 	case INTRINSIC_EQV:
644760c2415Smrg 	  fputs ("EQV ", dumpfile);
645760c2415Smrg 	  break;
646760c2415Smrg 	case INTRINSIC_NEQV:
647760c2415Smrg 	  fputs ("NEQV ", dumpfile);
648760c2415Smrg 	  break;
649760c2415Smrg 	case INTRINSIC_EQ:
650760c2415Smrg 	case INTRINSIC_EQ_OS:
651760c2415Smrg 	  fputs ("= ", dumpfile);
652760c2415Smrg 	  break;
653760c2415Smrg 	case INTRINSIC_NE:
654760c2415Smrg 	case INTRINSIC_NE_OS:
655760c2415Smrg 	  fputs ("/= ", dumpfile);
656760c2415Smrg 	  break;
657760c2415Smrg 	case INTRINSIC_GT:
658760c2415Smrg 	case INTRINSIC_GT_OS:
659760c2415Smrg 	  fputs ("> ", dumpfile);
660760c2415Smrg 	  break;
661760c2415Smrg 	case INTRINSIC_GE:
662760c2415Smrg 	case INTRINSIC_GE_OS:
663760c2415Smrg 	  fputs (">= ", dumpfile);
664760c2415Smrg 	  break;
665760c2415Smrg 	case INTRINSIC_LT:
666760c2415Smrg 	case INTRINSIC_LT_OS:
667760c2415Smrg 	  fputs ("< ", dumpfile);
668760c2415Smrg 	  break;
669760c2415Smrg 	case INTRINSIC_LE:
670760c2415Smrg 	case INTRINSIC_LE_OS:
671760c2415Smrg 	  fputs ("<= ", dumpfile);
672760c2415Smrg 	  break;
673760c2415Smrg 	case INTRINSIC_NOT:
674760c2415Smrg 	  fputs ("NOT ", dumpfile);
675760c2415Smrg 	  break;
676760c2415Smrg 	case INTRINSIC_PARENTHESES:
677760c2415Smrg 	  fputs ("parens ", dumpfile);
678760c2415Smrg 	  break;
679760c2415Smrg 
680760c2415Smrg 	default:
681760c2415Smrg 	  gfc_internal_error
682760c2415Smrg 	    ("show_expr(): Bad intrinsic in expression");
683760c2415Smrg 	}
684760c2415Smrg 
685760c2415Smrg       show_expr (p->value.op.op1);
686760c2415Smrg 
687760c2415Smrg       if (p->value.op.op2)
688760c2415Smrg 	{
689760c2415Smrg 	  fputc (' ', dumpfile);
690760c2415Smrg 	  show_expr (p->value.op.op2);
691760c2415Smrg 	}
692760c2415Smrg 
693760c2415Smrg       fputc (')', dumpfile);
694760c2415Smrg       break;
695760c2415Smrg 
696760c2415Smrg     case EXPR_FUNCTION:
697760c2415Smrg       if (p->value.function.name == NULL)
698760c2415Smrg 	{
699760c2415Smrg 	  fprintf (dumpfile, "%s", p->symtree->n.sym->name);
700760c2415Smrg 	  if (gfc_is_proc_ptr_comp (p))
701760c2415Smrg 	    show_ref (p->ref);
702760c2415Smrg 	  fputc ('[', dumpfile);
703760c2415Smrg 	  show_actual_arglist (p->value.function.actual);
704760c2415Smrg 	  fputc (']', dumpfile);
705760c2415Smrg 	}
706760c2415Smrg       else
707760c2415Smrg 	{
708760c2415Smrg 	  fprintf (dumpfile, "%s", p->value.function.name);
709760c2415Smrg 	  if (gfc_is_proc_ptr_comp (p))
710760c2415Smrg 	    show_ref (p->ref);
711760c2415Smrg 	  fputc ('[', dumpfile);
712760c2415Smrg 	  fputc ('[', dumpfile);
713760c2415Smrg 	  show_actual_arglist (p->value.function.actual);
714760c2415Smrg 	  fputc (']', dumpfile);
715760c2415Smrg 	  fputc (']', dumpfile);
716760c2415Smrg 	}
717760c2415Smrg 
718760c2415Smrg       break;
719760c2415Smrg 
720760c2415Smrg     case EXPR_COMPCALL:
721760c2415Smrg       show_compcall (p);
722760c2415Smrg       break;
723760c2415Smrg 
724760c2415Smrg     default:
725760c2415Smrg       gfc_internal_error ("show_expr(): Don't know how to show expr");
726760c2415Smrg     }
727760c2415Smrg }
728760c2415Smrg 
729760c2415Smrg /* Show symbol attributes.  The flavor and intent are followed by
730760c2415Smrg    whatever single bit attributes are present.  */
731760c2415Smrg 
732760c2415Smrg static void
show_attr(symbol_attribute * attr,const char * module)733760c2415Smrg show_attr (symbol_attribute *attr, const char * module)
734760c2415Smrg {
735760c2415Smrg   if (attr->flavor != FL_UNKNOWN)
736760c2415Smrg     {
737760c2415Smrg       if (attr->flavor == FL_DERIVED && attr->pdt_template)
738*0bfacb9bSmrg 	fputs (" (PDT-TEMPLATE", dumpfile);
739760c2415Smrg       else
740760c2415Smrg     fprintf (dumpfile, "(%s ", gfc_code2string (flavors, attr->flavor));
741760c2415Smrg     }
742760c2415Smrg   if (attr->access != ACCESS_UNKNOWN)
743760c2415Smrg     fprintf (dumpfile, "%s ", gfc_code2string (access_types, attr->access));
744760c2415Smrg   if (attr->proc != PROC_UNKNOWN)
745760c2415Smrg     fprintf (dumpfile, "%s ", gfc_code2string (procedures, attr->proc));
746760c2415Smrg   if (attr->save != SAVE_NONE)
747760c2415Smrg     fprintf (dumpfile, "%s", gfc_code2string (save_status, attr->save));
748760c2415Smrg 
749760c2415Smrg   if (attr->artificial)
750760c2415Smrg     fputs (" ARTIFICIAL", dumpfile);
751760c2415Smrg   if (attr->allocatable)
752760c2415Smrg     fputs (" ALLOCATABLE", dumpfile);
753760c2415Smrg   if (attr->asynchronous)
754760c2415Smrg     fputs (" ASYNCHRONOUS", dumpfile);
755760c2415Smrg   if (attr->codimension)
756760c2415Smrg     fputs (" CODIMENSION", dumpfile);
757760c2415Smrg   if (attr->dimension)
758760c2415Smrg     fputs (" DIMENSION", dumpfile);
759760c2415Smrg   if (attr->contiguous)
760760c2415Smrg     fputs (" CONTIGUOUS", dumpfile);
761760c2415Smrg   if (attr->external)
762760c2415Smrg     fputs (" EXTERNAL", dumpfile);
763760c2415Smrg   if (attr->intrinsic)
764760c2415Smrg     fputs (" INTRINSIC", dumpfile);
765760c2415Smrg   if (attr->optional)
766760c2415Smrg     fputs (" OPTIONAL", dumpfile);
767760c2415Smrg   if (attr->pdt_kind)
768760c2415Smrg     fputs (" KIND", dumpfile);
769760c2415Smrg   if (attr->pdt_len)
770760c2415Smrg     fputs (" LEN", dumpfile);
771760c2415Smrg   if (attr->pointer)
772760c2415Smrg     fputs (" POINTER", dumpfile);
773*0bfacb9bSmrg   if (attr->subref_array_pointer)
774*0bfacb9bSmrg     fputs (" SUBREF-ARRAY-POINTER", dumpfile);
775*0bfacb9bSmrg   if (attr->cray_pointer)
776*0bfacb9bSmrg     fputs (" CRAY-POINTER", dumpfile);
777*0bfacb9bSmrg   if (attr->cray_pointee)
778*0bfacb9bSmrg     fputs (" CRAY-POINTEE", dumpfile);
779760c2415Smrg   if (attr->is_protected)
780760c2415Smrg     fputs (" PROTECTED", dumpfile);
781760c2415Smrg   if (attr->value)
782760c2415Smrg     fputs (" VALUE", dumpfile);
783760c2415Smrg   if (attr->volatile_)
784760c2415Smrg     fputs (" VOLATILE", dumpfile);
785760c2415Smrg   if (attr->threadprivate)
786760c2415Smrg     fputs (" THREADPRIVATE", dumpfile);
787760c2415Smrg   if (attr->target)
788760c2415Smrg     fputs (" TARGET", dumpfile);
789760c2415Smrg   if (attr->dummy)
790760c2415Smrg     {
791760c2415Smrg       fputs (" DUMMY", dumpfile);
792760c2415Smrg       if (attr->intent != INTENT_UNKNOWN)
793760c2415Smrg 	fprintf (dumpfile, "(%s)", gfc_intent_string (attr->intent));
794760c2415Smrg     }
795760c2415Smrg 
796760c2415Smrg   if (attr->result)
797760c2415Smrg     fputs (" RESULT", dumpfile);
798760c2415Smrg   if (attr->entry)
799760c2415Smrg     fputs (" ENTRY", dumpfile);
800*0bfacb9bSmrg   if (attr->entry_master)
801*0bfacb9bSmrg     fputs (" ENTRY-MASTER", dumpfile);
802*0bfacb9bSmrg   if (attr->mixed_entry_master)
803*0bfacb9bSmrg     fputs (" MIXED-ENTRY-MASTER", dumpfile);
804760c2415Smrg   if (attr->is_bind_c)
805760c2415Smrg     fputs (" BIND(C)", dumpfile);
806760c2415Smrg 
807760c2415Smrg   if (attr->data)
808760c2415Smrg     fputs (" DATA", dumpfile);
809760c2415Smrg   if (attr->use_assoc)
810760c2415Smrg     {
811760c2415Smrg       fputs (" USE-ASSOC", dumpfile);
812760c2415Smrg       if (module != NULL)
813760c2415Smrg 	fprintf (dumpfile, "(%s)", module);
814760c2415Smrg     }
815760c2415Smrg 
816760c2415Smrg   if (attr->in_namelist)
817760c2415Smrg     fputs (" IN-NAMELIST", dumpfile);
818760c2415Smrg   if (attr->in_common)
819760c2415Smrg     fputs (" IN-COMMON", dumpfile);
820760c2415Smrg 
821760c2415Smrg   if (attr->abstract)
822760c2415Smrg     fputs (" ABSTRACT", dumpfile);
823760c2415Smrg   if (attr->function)
824760c2415Smrg     fputs (" FUNCTION", dumpfile);
825760c2415Smrg   if (attr->subroutine)
826760c2415Smrg     fputs (" SUBROUTINE", dumpfile);
827760c2415Smrg   if (attr->implicit_type)
828760c2415Smrg     fputs (" IMPLICIT-TYPE", dumpfile);
829760c2415Smrg 
830760c2415Smrg   if (attr->sequence)
831760c2415Smrg     fputs (" SEQUENCE", dumpfile);
832*0bfacb9bSmrg   if (attr->alloc_comp)
833*0bfacb9bSmrg     fputs (" ALLOC-COMP", dumpfile);
834*0bfacb9bSmrg   if (attr->pointer_comp)
835*0bfacb9bSmrg     fputs (" POINTER-COMP", dumpfile);
836*0bfacb9bSmrg   if (attr->proc_pointer_comp)
837*0bfacb9bSmrg     fputs (" PROC-POINTER-COMP", dumpfile);
838*0bfacb9bSmrg   if (attr->private_comp)
839*0bfacb9bSmrg     fputs (" PRIVATE-COMP", dumpfile);
840*0bfacb9bSmrg   if (attr->zero_comp)
841*0bfacb9bSmrg     fputs (" ZERO-COMP", dumpfile);
842*0bfacb9bSmrg   if (attr->coarray_comp)
843*0bfacb9bSmrg     fputs (" COARRAY-COMP", dumpfile);
844*0bfacb9bSmrg   if (attr->lock_comp)
845*0bfacb9bSmrg     fputs (" LOCK-COMP", dumpfile);
846*0bfacb9bSmrg   if (attr->event_comp)
847*0bfacb9bSmrg     fputs (" EVENT-COMP", dumpfile);
848*0bfacb9bSmrg   if (attr->defined_assign_comp)
849*0bfacb9bSmrg     fputs (" DEFINED-ASSIGNED-COMP", dumpfile);
850*0bfacb9bSmrg   if (attr->unlimited_polymorphic)
851*0bfacb9bSmrg     fputs (" UNLIMITED-POLYMORPHIC", dumpfile);
852*0bfacb9bSmrg   if (attr->has_dtio_procs)
853*0bfacb9bSmrg     fputs (" HAS-DTIO-PROCS", dumpfile);
854*0bfacb9bSmrg   if (attr->caf_token)
855*0bfacb9bSmrg     fputs (" CAF-TOKEN", dumpfile);
856*0bfacb9bSmrg   if (attr->select_type_temporary)
857*0bfacb9bSmrg     fputs (" SELECT-TYPE-TEMPORARY", dumpfile);
858*0bfacb9bSmrg   if (attr->associate_var)
859*0bfacb9bSmrg     fputs (" ASSOCIATE-VAR", dumpfile);
860*0bfacb9bSmrg   if (attr->pdt_kind)
861*0bfacb9bSmrg     fputs (" PDT-KIND", dumpfile);
862*0bfacb9bSmrg   if (attr->pdt_len)
863*0bfacb9bSmrg     fputs (" PDT-LEN", dumpfile);
864*0bfacb9bSmrg   if (attr->pdt_type)
865*0bfacb9bSmrg     fputs (" PDT-TYPE", dumpfile);
866*0bfacb9bSmrg   if (attr->pdt_array)
867*0bfacb9bSmrg     fputs (" PDT-ARRAY", dumpfile);
868*0bfacb9bSmrg   if (attr->pdt_string)
869*0bfacb9bSmrg     fputs (" PDT-STRING", dumpfile);
870*0bfacb9bSmrg   if (attr->omp_udr_artificial_var)
871*0bfacb9bSmrg     fputs (" OMP-UDT-ARTIFICIAL-VAR", dumpfile);
872*0bfacb9bSmrg   if (attr->omp_declare_target)
873*0bfacb9bSmrg     fputs (" OMP-DECLARE-TARGET", dumpfile);
874*0bfacb9bSmrg   if (attr->omp_declare_target_link)
875*0bfacb9bSmrg     fputs (" OMP-DECLARE-TARGET-LINK", dumpfile);
876760c2415Smrg   if (attr->elemental)
877760c2415Smrg     fputs (" ELEMENTAL", dumpfile);
878760c2415Smrg   if (attr->pure)
879760c2415Smrg     fputs (" PURE", dumpfile);
880760c2415Smrg   if (attr->implicit_pure)
881*0bfacb9bSmrg     fputs (" IMPLICIT-PURE", dumpfile);
882760c2415Smrg   if (attr->recursive)
883760c2415Smrg     fputs (" RECURSIVE", dumpfile);
884*0bfacb9bSmrg   if (attr->unmaskable)
885*0bfacb9bSmrg     fputs (" UNMASKABKE", dumpfile);
886*0bfacb9bSmrg   if (attr->masked)
887*0bfacb9bSmrg     fputs (" MASKED", dumpfile);
888*0bfacb9bSmrg   if (attr->contained)
889*0bfacb9bSmrg     fputs (" CONTAINED", dumpfile);
890*0bfacb9bSmrg   if (attr->mod_proc)
891*0bfacb9bSmrg     fputs (" MOD-PROC", dumpfile);
892*0bfacb9bSmrg   if (attr->module_procedure)
893*0bfacb9bSmrg     fputs (" MODULE-PROCEDURE", dumpfile);
894*0bfacb9bSmrg   if (attr->public_used)
895*0bfacb9bSmrg     fputs (" PUBLIC_USED", dumpfile);
896*0bfacb9bSmrg   if (attr->array_outer_dependency)
897*0bfacb9bSmrg     fputs (" ARRAY-OUTER-DEPENDENCY", dumpfile);
898*0bfacb9bSmrg   if (attr->noreturn)
899*0bfacb9bSmrg     fputs (" NORETURN", dumpfile);
900*0bfacb9bSmrg   if (attr->always_explicit)
901*0bfacb9bSmrg     fputs (" ALWAYS-EXPLICIT", dumpfile);
902*0bfacb9bSmrg   if (attr->is_main_program)
903*0bfacb9bSmrg     fputs (" IS-MAIN-PROGRAM", dumpfile);
904760c2415Smrg 
905*0bfacb9bSmrg   /* FIXME: Still missing are oacc_routine_lop and ext_attr.  */
906760c2415Smrg   fputc (')', dumpfile);
907760c2415Smrg }
908760c2415Smrg 
909760c2415Smrg 
910760c2415Smrg /* Show components of a derived type.  */
911760c2415Smrg 
912760c2415Smrg static void
show_components(gfc_symbol * sym)913760c2415Smrg show_components (gfc_symbol *sym)
914760c2415Smrg {
915760c2415Smrg   gfc_component *c;
916760c2415Smrg 
917760c2415Smrg   for (c = sym->components; c; c = c->next)
918760c2415Smrg     {
919760c2415Smrg       show_indent ();
920760c2415Smrg       fprintf (dumpfile, "(%s ", c->name);
921760c2415Smrg       show_typespec (&c->ts);
922760c2415Smrg       if (c->kind_expr)
923760c2415Smrg 	{
924760c2415Smrg 	  fputs (" kind_expr: ", dumpfile);
925760c2415Smrg 	  show_expr (c->kind_expr);
926760c2415Smrg 	}
927760c2415Smrg       if (c->param_list)
928760c2415Smrg 	{
929760c2415Smrg 	  fputs ("PDT parameters", dumpfile);
930760c2415Smrg 	  show_actual_arglist (c->param_list);
931760c2415Smrg 	}
932760c2415Smrg 
933760c2415Smrg       if (c->attr.allocatable)
934760c2415Smrg 	fputs (" ALLOCATABLE", dumpfile);
935760c2415Smrg       if (c->attr.pdt_kind)
936760c2415Smrg 	fputs (" KIND", dumpfile);
937760c2415Smrg       if (c->attr.pdt_len)
938760c2415Smrg 	fputs (" LEN", dumpfile);
939760c2415Smrg       if (c->attr.pointer)
940760c2415Smrg 	fputs (" POINTER", dumpfile);
941760c2415Smrg       if (c->attr.proc_pointer)
942760c2415Smrg 	fputs (" PPC", dumpfile);
943760c2415Smrg       if (c->attr.dimension)
944760c2415Smrg 	fputs (" DIMENSION", dumpfile);
945760c2415Smrg       fputc (' ', dumpfile);
946760c2415Smrg       show_array_spec (c->as);
947760c2415Smrg       if (c->attr.access)
948760c2415Smrg 	fprintf (dumpfile, " %s", gfc_code2string (access_types, c->attr.access));
949760c2415Smrg       fputc (')', dumpfile);
950760c2415Smrg       if (c->next != NULL)
951760c2415Smrg 	fputc (' ', dumpfile);
952760c2415Smrg     }
953760c2415Smrg }
954760c2415Smrg 
955760c2415Smrg 
956760c2415Smrg /* Show the f2k_derived namespace with procedure bindings.  */
957760c2415Smrg 
958760c2415Smrg static void
show_typebound_proc(gfc_typebound_proc * tb,const char * name)959760c2415Smrg show_typebound_proc (gfc_typebound_proc* tb, const char* name)
960760c2415Smrg {
961760c2415Smrg   show_indent ();
962760c2415Smrg 
963760c2415Smrg   if (tb->is_generic)
964760c2415Smrg     fputs ("GENERIC", dumpfile);
965760c2415Smrg   else
966760c2415Smrg     {
967760c2415Smrg       fputs ("PROCEDURE, ", dumpfile);
968760c2415Smrg       if (tb->nopass)
969760c2415Smrg 	fputs ("NOPASS", dumpfile);
970760c2415Smrg       else
971760c2415Smrg 	{
972760c2415Smrg 	  if (tb->pass_arg)
973760c2415Smrg 	    fprintf (dumpfile, "PASS(%s)", tb->pass_arg);
974760c2415Smrg 	  else
975760c2415Smrg 	    fputs ("PASS", dumpfile);
976760c2415Smrg 	}
977760c2415Smrg       if (tb->non_overridable)
978760c2415Smrg 	fputs (", NON_OVERRIDABLE", dumpfile);
979760c2415Smrg     }
980760c2415Smrg 
981760c2415Smrg   if (tb->access == ACCESS_PUBLIC)
982760c2415Smrg     fputs (", PUBLIC", dumpfile);
983760c2415Smrg   else
984760c2415Smrg     fputs (", PRIVATE", dumpfile);
985760c2415Smrg 
986760c2415Smrg   fprintf (dumpfile, " :: %s => ", name);
987760c2415Smrg 
988760c2415Smrg   if (tb->is_generic)
989760c2415Smrg     {
990760c2415Smrg       gfc_tbp_generic* g;
991760c2415Smrg       for (g = tb->u.generic; g; g = g->next)
992760c2415Smrg 	{
993760c2415Smrg 	  fputs (g->specific_st->name, dumpfile);
994760c2415Smrg 	  if (g->next)
995760c2415Smrg 	    fputs (", ", dumpfile);
996760c2415Smrg 	}
997760c2415Smrg     }
998760c2415Smrg   else
999760c2415Smrg     fputs (tb->u.specific->n.sym->name, dumpfile);
1000760c2415Smrg }
1001760c2415Smrg 
1002760c2415Smrg static void
show_typebound_symtree(gfc_symtree * st)1003760c2415Smrg show_typebound_symtree (gfc_symtree* st)
1004760c2415Smrg {
1005760c2415Smrg   gcc_assert (st->n.tb);
1006760c2415Smrg   show_typebound_proc (st->n.tb, st->name);
1007760c2415Smrg }
1008760c2415Smrg 
1009760c2415Smrg static void
show_f2k_derived(gfc_namespace * f2k)1010760c2415Smrg show_f2k_derived (gfc_namespace* f2k)
1011760c2415Smrg {
1012760c2415Smrg   gfc_finalizer* f;
1013760c2415Smrg   int op;
1014760c2415Smrg 
1015760c2415Smrg   show_indent ();
1016760c2415Smrg   fputs ("Procedure bindings:", dumpfile);
1017760c2415Smrg   ++show_level;
1018760c2415Smrg 
1019760c2415Smrg   /* Finalizer bindings.  */
1020760c2415Smrg   for (f = f2k->finalizers; f; f = f->next)
1021760c2415Smrg     {
1022760c2415Smrg       show_indent ();
1023760c2415Smrg       fprintf (dumpfile, "FINAL %s", f->proc_tree->n.sym->name);
1024760c2415Smrg     }
1025760c2415Smrg 
1026760c2415Smrg   /* Type-bound procedures.  */
1027760c2415Smrg   gfc_traverse_symtree (f2k->tb_sym_root, &show_typebound_symtree);
1028760c2415Smrg 
1029760c2415Smrg   --show_level;
1030760c2415Smrg 
1031760c2415Smrg   show_indent ();
1032760c2415Smrg   fputs ("Operator bindings:", dumpfile);
1033760c2415Smrg   ++show_level;
1034760c2415Smrg 
1035760c2415Smrg   /* User-defined operators.  */
1036760c2415Smrg   gfc_traverse_symtree (f2k->tb_uop_root, &show_typebound_symtree);
1037760c2415Smrg 
1038760c2415Smrg   /* Intrinsic operators.  */
1039760c2415Smrg   for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; ++op)
1040760c2415Smrg     if (f2k->tb_op[op])
1041760c2415Smrg       show_typebound_proc (f2k->tb_op[op],
1042760c2415Smrg 			   gfc_op2string ((gfc_intrinsic_op) op));
1043760c2415Smrg 
1044760c2415Smrg   --show_level;
1045760c2415Smrg }
1046760c2415Smrg 
1047760c2415Smrg 
1048760c2415Smrg /* Show a symbol.  If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
1049760c2415Smrg    show the interface.  Information needed to reconstruct the list of
1050760c2415Smrg    specific interfaces associated with a generic symbol is done within
1051760c2415Smrg    that symbol.  */
1052760c2415Smrg 
1053760c2415Smrg static void
show_symbol(gfc_symbol * sym)1054760c2415Smrg show_symbol (gfc_symbol *sym)
1055760c2415Smrg {
1056760c2415Smrg   gfc_formal_arglist *formal;
1057760c2415Smrg   gfc_interface *intr;
1058760c2415Smrg   int i,len;
1059760c2415Smrg 
1060760c2415Smrg   if (sym == NULL)
1061760c2415Smrg     return;
1062760c2415Smrg 
1063760c2415Smrg   fprintf (dumpfile, "|| symbol: '%s' ", sym->name);
1064760c2415Smrg   len = strlen (sym->name);
1065760c2415Smrg   for (i=len; i<12; i++)
1066760c2415Smrg     fputc(' ', dumpfile);
1067760c2415Smrg 
1068760c2415Smrg   if (sym->binding_label)
1069760c2415Smrg       fprintf (dumpfile,"|| binding_label: '%s' ", sym->binding_label);
1070760c2415Smrg 
1071760c2415Smrg   ++show_level;
1072760c2415Smrg 
1073760c2415Smrg   show_indent ();
1074760c2415Smrg   fputs ("type spec : ", dumpfile);
1075760c2415Smrg   show_typespec (&sym->ts);
1076760c2415Smrg 
1077760c2415Smrg   show_indent ();
1078760c2415Smrg   fputs ("attributes: ", dumpfile);
1079760c2415Smrg   show_attr (&sym->attr, sym->module);
1080760c2415Smrg 
1081760c2415Smrg   if (sym->value)
1082760c2415Smrg     {
1083760c2415Smrg       show_indent ();
1084760c2415Smrg       fputs ("value: ", dumpfile);
1085760c2415Smrg       show_expr (sym->value);
1086760c2415Smrg     }
1087760c2415Smrg 
1088*0bfacb9bSmrg   if (sym->ts.type != BT_CLASS && sym->as)
1089760c2415Smrg     {
1090760c2415Smrg       show_indent ();
1091760c2415Smrg       fputs ("Array spec:", dumpfile);
1092760c2415Smrg       show_array_spec (sym->as);
1093760c2415Smrg     }
1094*0bfacb9bSmrg   else if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as)
1095*0bfacb9bSmrg     {
1096*0bfacb9bSmrg       show_indent ();
1097*0bfacb9bSmrg       fputs ("Array spec:", dumpfile);
1098*0bfacb9bSmrg       show_array_spec (CLASS_DATA (sym)->as);
1099*0bfacb9bSmrg     }
1100760c2415Smrg 
1101760c2415Smrg   if (sym->generic)
1102760c2415Smrg     {
1103760c2415Smrg       show_indent ();
1104760c2415Smrg       fputs ("Generic interfaces:", dumpfile);
1105760c2415Smrg       for (intr = sym->generic; intr; intr = intr->next)
1106760c2415Smrg 	fprintf (dumpfile, " %s", intr->sym->name);
1107760c2415Smrg     }
1108760c2415Smrg 
1109760c2415Smrg   if (sym->result)
1110760c2415Smrg     {
1111760c2415Smrg       show_indent ();
1112760c2415Smrg       fprintf (dumpfile, "result: %s", sym->result->name);
1113760c2415Smrg     }
1114760c2415Smrg 
1115760c2415Smrg   if (sym->components)
1116760c2415Smrg     {
1117760c2415Smrg       show_indent ();
1118760c2415Smrg       fputs ("components: ", dumpfile);
1119760c2415Smrg       show_components (sym);
1120760c2415Smrg     }
1121760c2415Smrg 
1122760c2415Smrg   if (sym->f2k_derived)
1123760c2415Smrg     {
1124760c2415Smrg       show_indent ();
1125760c2415Smrg       if (sym->hash_value)
1126760c2415Smrg 	fprintf (dumpfile, "hash: %d", sym->hash_value);
1127760c2415Smrg       show_f2k_derived (sym->f2k_derived);
1128760c2415Smrg     }
1129760c2415Smrg 
1130760c2415Smrg   if (sym->formal)
1131760c2415Smrg     {
1132760c2415Smrg       show_indent ();
1133760c2415Smrg       fputs ("Formal arglist:", dumpfile);
1134760c2415Smrg 
1135760c2415Smrg       for (formal = sym->formal; formal; formal = formal->next)
1136760c2415Smrg 	{
1137760c2415Smrg 	  if (formal->sym != NULL)
1138760c2415Smrg 	    fprintf (dumpfile, " %s", formal->sym->name);
1139760c2415Smrg 	  else
1140760c2415Smrg 	    fputs (" [Alt Return]", dumpfile);
1141760c2415Smrg 	}
1142760c2415Smrg     }
1143760c2415Smrg 
1144760c2415Smrg   if (sym->formal_ns && (sym->formal_ns->proc_name != sym)
1145760c2415Smrg       && sym->attr.proc != PROC_ST_FUNCTION
1146760c2415Smrg       && !sym->attr.entry)
1147760c2415Smrg     {
1148760c2415Smrg       show_indent ();
1149760c2415Smrg       fputs ("Formal namespace", dumpfile);
1150760c2415Smrg       show_namespace (sym->formal_ns);
1151760c2415Smrg     }
1152760c2415Smrg 
1153760c2415Smrg   if (sym->attr.flavor == FL_VARIABLE
1154760c2415Smrg       && sym->param_list)
1155760c2415Smrg     {
1156760c2415Smrg       show_indent ();
1157760c2415Smrg       fputs ("PDT parameters", dumpfile);
1158760c2415Smrg       show_actual_arglist (sym->param_list);
1159760c2415Smrg     }
1160760c2415Smrg 
1161760c2415Smrg   if (sym->attr.flavor == FL_NAMELIST)
1162760c2415Smrg     {
1163760c2415Smrg       gfc_namelist *nl;
1164760c2415Smrg       show_indent ();
1165760c2415Smrg       fputs ("variables : ", dumpfile);
1166760c2415Smrg       for (nl = sym->namelist; nl; nl = nl->next)
1167760c2415Smrg 	fprintf (dumpfile, " %s",nl->sym->name);
1168760c2415Smrg     }
1169760c2415Smrg 
1170760c2415Smrg   --show_level;
1171760c2415Smrg }
1172760c2415Smrg 
1173760c2415Smrg 
1174760c2415Smrg /* Show a user-defined operator.  Just prints an operator
1175760c2415Smrg    and the name of the associated subroutine, really.  */
1176760c2415Smrg 
1177760c2415Smrg static void
show_uop(gfc_user_op * uop)1178760c2415Smrg show_uop (gfc_user_op *uop)
1179760c2415Smrg {
1180760c2415Smrg   gfc_interface *intr;
1181760c2415Smrg 
1182760c2415Smrg   show_indent ();
1183760c2415Smrg   fprintf (dumpfile, "%s:", uop->name);
1184760c2415Smrg 
1185760c2415Smrg   for (intr = uop->op; intr; intr = intr->next)
1186760c2415Smrg     fprintf (dumpfile, " %s", intr->sym->name);
1187760c2415Smrg }
1188760c2415Smrg 
1189760c2415Smrg 
1190760c2415Smrg /* Workhorse function for traversing the user operator symtree.  */
1191760c2415Smrg 
1192760c2415Smrg static void
traverse_uop(gfc_symtree * st,void (* func)(gfc_user_op *))1193760c2415Smrg traverse_uop (gfc_symtree *st, void (*func) (gfc_user_op *))
1194760c2415Smrg {
1195760c2415Smrg   if (st == NULL)
1196760c2415Smrg     return;
1197760c2415Smrg 
1198760c2415Smrg   (*func) (st->n.uop);
1199760c2415Smrg 
1200760c2415Smrg   traverse_uop (st->left, func);
1201760c2415Smrg   traverse_uop (st->right, func);
1202760c2415Smrg }
1203760c2415Smrg 
1204760c2415Smrg 
1205760c2415Smrg /* Traverse the tree of user operator nodes.  */
1206760c2415Smrg 
1207760c2415Smrg void
gfc_traverse_user_op(gfc_namespace * ns,void (* func)(gfc_user_op *))1208760c2415Smrg gfc_traverse_user_op (gfc_namespace *ns, void (*func) (gfc_user_op *))
1209760c2415Smrg {
1210760c2415Smrg   traverse_uop (ns->uop_root, func);
1211760c2415Smrg }
1212760c2415Smrg 
1213760c2415Smrg 
1214760c2415Smrg /* Function to display a common block.  */
1215760c2415Smrg 
1216760c2415Smrg static void
show_common(gfc_symtree * st)1217760c2415Smrg show_common (gfc_symtree *st)
1218760c2415Smrg {
1219760c2415Smrg   gfc_symbol *s;
1220760c2415Smrg 
1221760c2415Smrg   show_indent ();
1222760c2415Smrg   fprintf (dumpfile, "common: /%s/ ", st->name);
1223760c2415Smrg 
1224760c2415Smrg   s = st->n.common->head;
1225760c2415Smrg   while (s)
1226760c2415Smrg     {
1227760c2415Smrg       fprintf (dumpfile, "%s", s->name);
1228760c2415Smrg       s = s->common_next;
1229760c2415Smrg       if (s)
1230760c2415Smrg 	fputs (", ", dumpfile);
1231760c2415Smrg     }
1232760c2415Smrg   fputc ('\n', dumpfile);
1233760c2415Smrg }
1234760c2415Smrg 
1235760c2415Smrg 
1236760c2415Smrg /* Worker function to display the symbol tree.  */
1237760c2415Smrg 
1238760c2415Smrg static void
show_symtree(gfc_symtree * st)1239760c2415Smrg show_symtree (gfc_symtree *st)
1240760c2415Smrg {
1241760c2415Smrg   int len, i;
1242760c2415Smrg 
1243760c2415Smrg   show_indent ();
1244760c2415Smrg 
1245760c2415Smrg   len = strlen(st->name);
1246760c2415Smrg   fprintf (dumpfile, "symtree: '%s'", st->name);
1247760c2415Smrg 
1248760c2415Smrg   for (i=len; i<12; i++)
1249760c2415Smrg     fputc(' ', dumpfile);
1250760c2415Smrg 
1251760c2415Smrg   if (st->ambiguous)
1252760c2415Smrg     fputs( " Ambiguous", dumpfile);
1253760c2415Smrg 
1254760c2415Smrg   if (st->n.sym->ns != gfc_current_ns)
1255760c2415Smrg     fprintf (dumpfile, "|| symbol: '%s' from namespace '%s'", st->n.sym->name,
1256760c2415Smrg 	     st->n.sym->ns->proc_name->name);
1257760c2415Smrg   else
1258760c2415Smrg     show_symbol (st->n.sym);
1259760c2415Smrg }
1260760c2415Smrg 
1261760c2415Smrg 
1262760c2415Smrg /******************* Show gfc_code structures **************/
1263760c2415Smrg 
1264760c2415Smrg 
1265760c2415Smrg /* Show a list of code structures.  Mutually recursive with
1266760c2415Smrg    show_code_node().  */
1267760c2415Smrg 
1268760c2415Smrg static void
show_code(int level,gfc_code * c)1269760c2415Smrg show_code (int level, gfc_code *c)
1270760c2415Smrg {
1271760c2415Smrg   for (; c; c = c->next)
1272760c2415Smrg     show_code_node (level, c);
1273760c2415Smrg }
1274760c2415Smrg 
1275760c2415Smrg static void
show_omp_namelist(int list_type,gfc_omp_namelist * n)1276760c2415Smrg show_omp_namelist (int list_type, gfc_omp_namelist *n)
1277760c2415Smrg {
1278760c2415Smrg   for (; n; n = n->next)
1279760c2415Smrg     {
1280760c2415Smrg       if (list_type == OMP_LIST_REDUCTION)
1281760c2415Smrg 	switch (n->u.reduction_op)
1282760c2415Smrg 	  {
1283760c2415Smrg 	  case OMP_REDUCTION_PLUS:
1284760c2415Smrg 	  case OMP_REDUCTION_TIMES:
1285760c2415Smrg 	  case OMP_REDUCTION_MINUS:
1286760c2415Smrg 	  case OMP_REDUCTION_AND:
1287760c2415Smrg 	  case OMP_REDUCTION_OR:
1288760c2415Smrg 	  case OMP_REDUCTION_EQV:
1289760c2415Smrg 	  case OMP_REDUCTION_NEQV:
1290760c2415Smrg 	    fprintf (dumpfile, "%s:",
1291760c2415Smrg 		     gfc_op2string ((gfc_intrinsic_op) n->u.reduction_op));
1292760c2415Smrg 	    break;
1293760c2415Smrg 	  case OMP_REDUCTION_MAX: fputs ("max:", dumpfile); break;
1294760c2415Smrg 	  case OMP_REDUCTION_MIN: fputs ("min:", dumpfile); break;
1295760c2415Smrg 	  case OMP_REDUCTION_IAND: fputs ("iand:", dumpfile); break;
1296760c2415Smrg 	  case OMP_REDUCTION_IOR: fputs ("ior:", dumpfile); break;
1297760c2415Smrg 	  case OMP_REDUCTION_IEOR: fputs ("ieor:", dumpfile); break;
1298760c2415Smrg 	  case OMP_REDUCTION_USER:
1299760c2415Smrg 	    if (n->udr)
1300760c2415Smrg 	      fprintf (dumpfile, "%s:", n->udr->udr->name);
1301760c2415Smrg 	    break;
1302760c2415Smrg 	  default: break;
1303760c2415Smrg 	  }
1304760c2415Smrg       else if (list_type == OMP_LIST_DEPEND)
1305760c2415Smrg 	switch (n->u.depend_op)
1306760c2415Smrg 	  {
1307760c2415Smrg 	  case OMP_DEPEND_IN: fputs ("in:", dumpfile); break;
1308760c2415Smrg 	  case OMP_DEPEND_OUT: fputs ("out:", dumpfile); break;
1309760c2415Smrg 	  case OMP_DEPEND_INOUT: fputs ("inout:", dumpfile); break;
1310760c2415Smrg 	  case OMP_DEPEND_SINK_FIRST:
1311760c2415Smrg 	    fputs ("sink:", dumpfile);
1312760c2415Smrg 	    while (1)
1313760c2415Smrg 	      {
1314760c2415Smrg 		fprintf (dumpfile, "%s", n->sym->name);
1315760c2415Smrg 		if (n->expr)
1316760c2415Smrg 		  {
1317760c2415Smrg 		    fputc ('+', dumpfile);
1318760c2415Smrg 		    show_expr (n->expr);
1319760c2415Smrg 		  }
1320760c2415Smrg 		if (n->next == NULL)
1321760c2415Smrg 		  break;
1322760c2415Smrg 		else if (n->next->u.depend_op != OMP_DEPEND_SINK)
1323760c2415Smrg 		  {
1324760c2415Smrg 		    fputs (") DEPEND(", dumpfile);
1325760c2415Smrg 		    break;
1326760c2415Smrg 		  }
1327760c2415Smrg 		fputc (',', dumpfile);
1328760c2415Smrg 		n = n->next;
1329760c2415Smrg 	      }
1330760c2415Smrg 	    continue;
1331760c2415Smrg 	  default: break;
1332760c2415Smrg 	  }
1333760c2415Smrg       else if (list_type == OMP_LIST_MAP)
1334760c2415Smrg 	switch (n->u.map_op)
1335760c2415Smrg 	  {
1336760c2415Smrg 	  case OMP_MAP_ALLOC: fputs ("alloc:", dumpfile); break;
1337760c2415Smrg 	  case OMP_MAP_TO: fputs ("to:", dumpfile); break;
1338760c2415Smrg 	  case OMP_MAP_FROM: fputs ("from:", dumpfile); break;
1339760c2415Smrg 	  case OMP_MAP_TOFROM: fputs ("tofrom:", dumpfile); break;
1340760c2415Smrg 	  default: break;
1341760c2415Smrg 	  }
1342760c2415Smrg       else if (list_type == OMP_LIST_LINEAR)
1343760c2415Smrg 	switch (n->u.linear_op)
1344760c2415Smrg 	  {
1345760c2415Smrg 	  case OMP_LINEAR_REF: fputs ("ref(", dumpfile); break;
1346760c2415Smrg 	  case OMP_LINEAR_VAL: fputs ("val(", dumpfile); break;
1347760c2415Smrg 	  case OMP_LINEAR_UVAL: fputs ("uval(", dumpfile); break;
1348760c2415Smrg 	  default: break;
1349760c2415Smrg 	  }
1350760c2415Smrg       fprintf (dumpfile, "%s", n->sym->name);
1351760c2415Smrg       if (list_type == OMP_LIST_LINEAR && n->u.linear_op != OMP_LINEAR_DEFAULT)
1352760c2415Smrg 	fputc (')', dumpfile);
1353760c2415Smrg       if (n->expr)
1354760c2415Smrg 	{
1355760c2415Smrg 	  fputc (':', dumpfile);
1356760c2415Smrg 	  show_expr (n->expr);
1357760c2415Smrg 	}
1358760c2415Smrg       if (n->next)
1359760c2415Smrg 	fputc (',', dumpfile);
1360760c2415Smrg     }
1361760c2415Smrg }
1362760c2415Smrg 
1363760c2415Smrg 
1364760c2415Smrg /* Show OpenMP or OpenACC clauses.  */
1365760c2415Smrg 
1366760c2415Smrg static void
show_omp_clauses(gfc_omp_clauses * omp_clauses)1367760c2415Smrg show_omp_clauses (gfc_omp_clauses *omp_clauses)
1368760c2415Smrg {
1369760c2415Smrg   int list_type, i;
1370760c2415Smrg 
1371760c2415Smrg   switch (omp_clauses->cancel)
1372760c2415Smrg     {
1373760c2415Smrg     case OMP_CANCEL_UNKNOWN:
1374760c2415Smrg       break;
1375760c2415Smrg     case OMP_CANCEL_PARALLEL:
1376760c2415Smrg       fputs (" PARALLEL", dumpfile);
1377760c2415Smrg       break;
1378760c2415Smrg     case OMP_CANCEL_SECTIONS:
1379760c2415Smrg       fputs (" SECTIONS", dumpfile);
1380760c2415Smrg       break;
1381760c2415Smrg     case OMP_CANCEL_DO:
1382760c2415Smrg       fputs (" DO", dumpfile);
1383760c2415Smrg       break;
1384760c2415Smrg     case OMP_CANCEL_TASKGROUP:
1385760c2415Smrg       fputs (" TASKGROUP", dumpfile);
1386760c2415Smrg       break;
1387760c2415Smrg     }
1388760c2415Smrg   if (omp_clauses->if_expr)
1389760c2415Smrg     {
1390760c2415Smrg       fputs (" IF(", dumpfile);
1391760c2415Smrg       show_expr (omp_clauses->if_expr);
1392760c2415Smrg       fputc (')', dumpfile);
1393760c2415Smrg     }
1394760c2415Smrg   if (omp_clauses->final_expr)
1395760c2415Smrg     {
1396760c2415Smrg       fputs (" FINAL(", dumpfile);
1397760c2415Smrg       show_expr (omp_clauses->final_expr);
1398760c2415Smrg       fputc (')', dumpfile);
1399760c2415Smrg     }
1400760c2415Smrg   if (omp_clauses->num_threads)
1401760c2415Smrg     {
1402760c2415Smrg       fputs (" NUM_THREADS(", dumpfile);
1403760c2415Smrg       show_expr (omp_clauses->num_threads);
1404760c2415Smrg       fputc (')', dumpfile);
1405760c2415Smrg     }
1406760c2415Smrg   if (omp_clauses->async)
1407760c2415Smrg     {
1408760c2415Smrg       fputs (" ASYNC", dumpfile);
1409760c2415Smrg       if (omp_clauses->async_expr)
1410760c2415Smrg 	{
1411760c2415Smrg 	  fputc ('(', dumpfile);
1412760c2415Smrg 	  show_expr (omp_clauses->async_expr);
1413760c2415Smrg 	  fputc (')', dumpfile);
1414760c2415Smrg 	}
1415760c2415Smrg     }
1416760c2415Smrg   if (omp_clauses->num_gangs_expr)
1417760c2415Smrg     {
1418760c2415Smrg       fputs (" NUM_GANGS(", dumpfile);
1419760c2415Smrg       show_expr (omp_clauses->num_gangs_expr);
1420760c2415Smrg       fputc (')', dumpfile);
1421760c2415Smrg     }
1422760c2415Smrg   if (omp_clauses->num_workers_expr)
1423760c2415Smrg     {
1424760c2415Smrg       fputs (" NUM_WORKERS(", dumpfile);
1425760c2415Smrg       show_expr (omp_clauses->num_workers_expr);
1426760c2415Smrg       fputc (')', dumpfile);
1427760c2415Smrg     }
1428760c2415Smrg   if (omp_clauses->vector_length_expr)
1429760c2415Smrg     {
1430760c2415Smrg       fputs (" VECTOR_LENGTH(", dumpfile);
1431760c2415Smrg       show_expr (omp_clauses->vector_length_expr);
1432760c2415Smrg       fputc (')', dumpfile);
1433760c2415Smrg     }
1434760c2415Smrg   if (omp_clauses->gang)
1435760c2415Smrg     {
1436760c2415Smrg       fputs (" GANG", dumpfile);
1437760c2415Smrg       if (omp_clauses->gang_num_expr || omp_clauses->gang_static_expr)
1438760c2415Smrg 	{
1439760c2415Smrg 	  fputc ('(', dumpfile);
1440760c2415Smrg 	  if (omp_clauses->gang_num_expr)
1441760c2415Smrg 	    {
1442760c2415Smrg 	      fprintf (dumpfile, "num:");
1443760c2415Smrg 	      show_expr (omp_clauses->gang_num_expr);
1444760c2415Smrg 	    }
1445760c2415Smrg 	  if (omp_clauses->gang_num_expr && omp_clauses->gang_static)
1446760c2415Smrg 	    fputc (',', dumpfile);
1447760c2415Smrg 	  if (omp_clauses->gang_static)
1448760c2415Smrg 	    {
1449760c2415Smrg 	      fprintf (dumpfile, "static:");
1450760c2415Smrg 	      if (omp_clauses->gang_static_expr)
1451760c2415Smrg 		show_expr (omp_clauses->gang_static_expr);
1452760c2415Smrg 	      else
1453760c2415Smrg 		fputc ('*', dumpfile);
1454760c2415Smrg 	    }
1455760c2415Smrg 	  fputc (')', dumpfile);
1456760c2415Smrg 	}
1457760c2415Smrg     }
1458760c2415Smrg   if (omp_clauses->worker)
1459760c2415Smrg     {
1460760c2415Smrg       fputs (" WORKER", dumpfile);
1461760c2415Smrg       if (omp_clauses->worker_expr)
1462760c2415Smrg 	{
1463760c2415Smrg 	  fputc ('(', dumpfile);
1464760c2415Smrg 	  show_expr (omp_clauses->worker_expr);
1465760c2415Smrg 	  fputc (')', dumpfile);
1466760c2415Smrg 	}
1467760c2415Smrg     }
1468760c2415Smrg   if (omp_clauses->vector)
1469760c2415Smrg     {
1470760c2415Smrg       fputs (" VECTOR", dumpfile);
1471760c2415Smrg       if (omp_clauses->vector_expr)
1472760c2415Smrg 	{
1473760c2415Smrg 	  fputc ('(', dumpfile);
1474760c2415Smrg 	  show_expr (omp_clauses->vector_expr);
1475760c2415Smrg 	  fputc (')', dumpfile);
1476760c2415Smrg 	}
1477760c2415Smrg     }
1478760c2415Smrg   if (omp_clauses->sched_kind != OMP_SCHED_NONE)
1479760c2415Smrg     {
1480760c2415Smrg       const char *type;
1481760c2415Smrg       switch (omp_clauses->sched_kind)
1482760c2415Smrg 	{
1483760c2415Smrg 	case OMP_SCHED_STATIC: type = "STATIC"; break;
1484760c2415Smrg 	case OMP_SCHED_DYNAMIC: type = "DYNAMIC"; break;
1485760c2415Smrg 	case OMP_SCHED_GUIDED: type = "GUIDED"; break;
1486760c2415Smrg 	case OMP_SCHED_RUNTIME: type = "RUNTIME"; break;
1487760c2415Smrg 	case OMP_SCHED_AUTO: type = "AUTO"; break;
1488760c2415Smrg 	default:
1489760c2415Smrg 	  gcc_unreachable ();
1490760c2415Smrg 	}
1491760c2415Smrg       fputs (" SCHEDULE (", dumpfile);
1492760c2415Smrg       if (omp_clauses->sched_simd)
1493760c2415Smrg 	{
1494760c2415Smrg 	  if (omp_clauses->sched_monotonic
1495760c2415Smrg 	      || omp_clauses->sched_nonmonotonic)
1496760c2415Smrg 	    fputs ("SIMD, ", dumpfile);
1497760c2415Smrg 	  else
1498760c2415Smrg 	    fputs ("SIMD: ", dumpfile);
1499760c2415Smrg 	}
1500760c2415Smrg       if (omp_clauses->sched_monotonic)
1501760c2415Smrg 	fputs ("MONOTONIC: ", dumpfile);
1502760c2415Smrg       else if (omp_clauses->sched_nonmonotonic)
1503760c2415Smrg 	fputs ("NONMONOTONIC: ", dumpfile);
1504760c2415Smrg       fputs (type, dumpfile);
1505760c2415Smrg       if (omp_clauses->chunk_size)
1506760c2415Smrg 	{
1507760c2415Smrg 	  fputc (',', dumpfile);
1508760c2415Smrg 	  show_expr (omp_clauses->chunk_size);
1509760c2415Smrg 	}
1510760c2415Smrg       fputc (')', dumpfile);
1511760c2415Smrg     }
1512760c2415Smrg   if (omp_clauses->default_sharing != OMP_DEFAULT_UNKNOWN)
1513760c2415Smrg     {
1514760c2415Smrg       const char *type;
1515760c2415Smrg       switch (omp_clauses->default_sharing)
1516760c2415Smrg 	{
1517760c2415Smrg 	case OMP_DEFAULT_NONE: type = "NONE"; break;
1518760c2415Smrg 	case OMP_DEFAULT_PRIVATE: type = "PRIVATE"; break;
1519760c2415Smrg 	case OMP_DEFAULT_SHARED: type = "SHARED"; break;
1520760c2415Smrg 	case OMP_DEFAULT_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break;
1521760c2415Smrg 	case OMP_DEFAULT_PRESENT: type = "PRESENT"; break;
1522760c2415Smrg 	default:
1523760c2415Smrg 	  gcc_unreachable ();
1524760c2415Smrg 	}
1525760c2415Smrg       fprintf (dumpfile, " DEFAULT(%s)", type);
1526760c2415Smrg     }
1527760c2415Smrg   if (omp_clauses->tile_list)
1528760c2415Smrg     {
1529760c2415Smrg       gfc_expr_list *list;
1530760c2415Smrg       fputs (" TILE(", dumpfile);
1531760c2415Smrg       for (list = omp_clauses->tile_list; list; list = list->next)
1532760c2415Smrg 	{
1533760c2415Smrg 	  show_expr (list->expr);
1534760c2415Smrg 	  if (list->next)
1535760c2415Smrg 	    fputs (", ", dumpfile);
1536760c2415Smrg 	}
1537760c2415Smrg       fputc (')', dumpfile);
1538760c2415Smrg     }
1539760c2415Smrg   if (omp_clauses->wait_list)
1540760c2415Smrg     {
1541760c2415Smrg       gfc_expr_list *list;
1542760c2415Smrg       fputs (" WAIT(", dumpfile);
1543760c2415Smrg       for (list = omp_clauses->wait_list; list; list = list->next)
1544760c2415Smrg 	{
1545760c2415Smrg 	  show_expr (list->expr);
1546760c2415Smrg 	  if (list->next)
1547760c2415Smrg 	    fputs (", ", dumpfile);
1548760c2415Smrg 	}
1549760c2415Smrg       fputc (')', dumpfile);
1550760c2415Smrg     }
1551760c2415Smrg   if (omp_clauses->seq)
1552760c2415Smrg     fputs (" SEQ", dumpfile);
1553760c2415Smrg   if (omp_clauses->independent)
1554760c2415Smrg     fputs (" INDEPENDENT", dumpfile);
1555760c2415Smrg   if (omp_clauses->ordered)
1556760c2415Smrg     {
1557760c2415Smrg       if (omp_clauses->orderedc)
1558760c2415Smrg 	fprintf (dumpfile, " ORDERED(%d)", omp_clauses->orderedc);
1559760c2415Smrg       else
1560760c2415Smrg 	fputs (" ORDERED", dumpfile);
1561760c2415Smrg     }
1562760c2415Smrg   if (omp_clauses->untied)
1563760c2415Smrg     fputs (" UNTIED", dumpfile);
1564760c2415Smrg   if (omp_clauses->mergeable)
1565760c2415Smrg     fputs (" MERGEABLE", dumpfile);
1566760c2415Smrg   if (omp_clauses->collapse)
1567760c2415Smrg     fprintf (dumpfile, " COLLAPSE(%d)", omp_clauses->collapse);
1568760c2415Smrg   for (list_type = 0; list_type < OMP_LIST_NUM; list_type++)
1569760c2415Smrg     if (omp_clauses->lists[list_type] != NULL
1570760c2415Smrg 	&& list_type != OMP_LIST_COPYPRIVATE)
1571760c2415Smrg       {
1572760c2415Smrg 	const char *type = NULL;
1573760c2415Smrg 	switch (list_type)
1574760c2415Smrg 	  {
1575760c2415Smrg 	  case OMP_LIST_PRIVATE: type = "PRIVATE"; break;
1576760c2415Smrg 	  case OMP_LIST_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break;
1577760c2415Smrg 	  case OMP_LIST_LASTPRIVATE: type = "LASTPRIVATE"; break;
1578760c2415Smrg 	  case OMP_LIST_COPYPRIVATE: type = "COPYPRIVATE"; break;
1579760c2415Smrg 	  case OMP_LIST_SHARED: type = "SHARED"; break;
1580760c2415Smrg 	  case OMP_LIST_COPYIN: type = "COPYIN"; break;
1581760c2415Smrg 	  case OMP_LIST_UNIFORM: type = "UNIFORM"; break;
1582760c2415Smrg 	  case OMP_LIST_ALIGNED: type = "ALIGNED"; break;
1583760c2415Smrg 	  case OMP_LIST_LINEAR: type = "LINEAR"; break;
1584760c2415Smrg 	  case OMP_LIST_DEPEND: type = "DEPEND"; break;
1585760c2415Smrg 	  case OMP_LIST_MAP: type = "MAP"; break;
1586760c2415Smrg 	  case OMP_LIST_TO: type = "TO"; break;
1587760c2415Smrg 	  case OMP_LIST_FROM: type = "FROM"; break;
1588760c2415Smrg 	  case OMP_LIST_REDUCTION: type = "REDUCTION"; break;
1589760c2415Smrg 	  case OMP_LIST_DEVICE_RESIDENT: type = "DEVICE_RESIDENT"; break;
1590760c2415Smrg 	  case OMP_LIST_LINK: type = "LINK"; break;
1591760c2415Smrg 	  case OMP_LIST_USE_DEVICE: type = "USE_DEVICE"; break;
1592760c2415Smrg 	  case OMP_LIST_CACHE: type = "CACHE"; break;
1593760c2415Smrg 	  case OMP_LIST_IS_DEVICE_PTR: type = "IS_DEVICE_PTR"; break;
1594760c2415Smrg 	  case OMP_LIST_USE_DEVICE_PTR: type = "USE_DEVICE_PTR"; break;
1595*0bfacb9bSmrg 	  case OMP_LIST_USE_DEVICE_ADDR: type = "USE_DEVICE_ADDR"; break;
1596760c2415Smrg 	  default:
1597760c2415Smrg 	    gcc_unreachable ();
1598760c2415Smrg 	  }
1599760c2415Smrg 	fprintf (dumpfile, " %s(", type);
1600760c2415Smrg 	show_omp_namelist (list_type, omp_clauses->lists[list_type]);
1601760c2415Smrg 	fputc (')', dumpfile);
1602760c2415Smrg       }
1603760c2415Smrg   if (omp_clauses->safelen_expr)
1604760c2415Smrg     {
1605760c2415Smrg       fputs (" SAFELEN(", dumpfile);
1606760c2415Smrg       show_expr (omp_clauses->safelen_expr);
1607760c2415Smrg       fputc (')', dumpfile);
1608760c2415Smrg     }
1609760c2415Smrg   if (omp_clauses->simdlen_expr)
1610760c2415Smrg     {
1611760c2415Smrg       fputs (" SIMDLEN(", dumpfile);
1612760c2415Smrg       show_expr (omp_clauses->simdlen_expr);
1613760c2415Smrg       fputc (')', dumpfile);
1614760c2415Smrg     }
1615760c2415Smrg   if (omp_clauses->inbranch)
1616760c2415Smrg     fputs (" INBRANCH", dumpfile);
1617760c2415Smrg   if (omp_clauses->notinbranch)
1618760c2415Smrg     fputs (" NOTINBRANCH", dumpfile);
1619760c2415Smrg   if (omp_clauses->proc_bind != OMP_PROC_BIND_UNKNOWN)
1620760c2415Smrg     {
1621760c2415Smrg       const char *type;
1622760c2415Smrg       switch (omp_clauses->proc_bind)
1623760c2415Smrg 	{
1624760c2415Smrg 	case OMP_PROC_BIND_MASTER: type = "MASTER"; break;
1625760c2415Smrg 	case OMP_PROC_BIND_SPREAD: type = "SPREAD"; break;
1626760c2415Smrg 	case OMP_PROC_BIND_CLOSE: type = "CLOSE"; break;
1627760c2415Smrg 	default:
1628760c2415Smrg 	  gcc_unreachable ();
1629760c2415Smrg 	}
1630760c2415Smrg       fprintf (dumpfile, " PROC_BIND(%s)", type);
1631760c2415Smrg     }
1632760c2415Smrg   if (omp_clauses->num_teams)
1633760c2415Smrg     {
1634760c2415Smrg       fputs (" NUM_TEAMS(", dumpfile);
1635760c2415Smrg       show_expr (omp_clauses->num_teams);
1636760c2415Smrg       fputc (')', dumpfile);
1637760c2415Smrg     }
1638760c2415Smrg   if (omp_clauses->device)
1639760c2415Smrg     {
1640760c2415Smrg       fputs (" DEVICE(", dumpfile);
1641760c2415Smrg       show_expr (omp_clauses->device);
1642760c2415Smrg       fputc (')', dumpfile);
1643760c2415Smrg     }
1644760c2415Smrg   if (omp_clauses->thread_limit)
1645760c2415Smrg     {
1646760c2415Smrg       fputs (" THREAD_LIMIT(", dumpfile);
1647760c2415Smrg       show_expr (omp_clauses->thread_limit);
1648760c2415Smrg       fputc (')', dumpfile);
1649760c2415Smrg     }
1650760c2415Smrg   if (omp_clauses->dist_sched_kind != OMP_SCHED_NONE)
1651760c2415Smrg     {
1652760c2415Smrg       fprintf (dumpfile, " DIST_SCHEDULE (STATIC");
1653760c2415Smrg       if (omp_clauses->dist_chunk_size)
1654760c2415Smrg 	{
1655760c2415Smrg 	  fputc (',', dumpfile);
1656760c2415Smrg 	  show_expr (omp_clauses->dist_chunk_size);
1657760c2415Smrg 	}
1658760c2415Smrg       fputc (')', dumpfile);
1659760c2415Smrg     }
1660760c2415Smrg   if (omp_clauses->defaultmap)
1661760c2415Smrg     fputs (" DEFALTMAP (TOFROM: SCALAR)", dumpfile);
1662760c2415Smrg   if (omp_clauses->nogroup)
1663760c2415Smrg     fputs (" NOGROUP", dumpfile);
1664760c2415Smrg   if (omp_clauses->simd)
1665760c2415Smrg     fputs (" SIMD", dumpfile);
1666760c2415Smrg   if (omp_clauses->threads)
1667760c2415Smrg     fputs (" THREADS", dumpfile);
1668760c2415Smrg   if (omp_clauses->grainsize)
1669760c2415Smrg     {
1670760c2415Smrg       fputs (" GRAINSIZE(", dumpfile);
1671760c2415Smrg       show_expr (omp_clauses->grainsize);
1672760c2415Smrg       fputc (')', dumpfile);
1673760c2415Smrg     }
1674760c2415Smrg   if (omp_clauses->hint)
1675760c2415Smrg     {
1676760c2415Smrg       fputs (" HINT(", dumpfile);
1677760c2415Smrg       show_expr (omp_clauses->hint);
1678760c2415Smrg       fputc (')', dumpfile);
1679760c2415Smrg     }
1680760c2415Smrg   if (omp_clauses->num_tasks)
1681760c2415Smrg     {
1682760c2415Smrg       fputs (" NUM_TASKS(", dumpfile);
1683760c2415Smrg       show_expr (omp_clauses->num_tasks);
1684760c2415Smrg       fputc (')', dumpfile);
1685760c2415Smrg     }
1686760c2415Smrg   if (omp_clauses->priority)
1687760c2415Smrg     {
1688760c2415Smrg       fputs (" PRIORITY(", dumpfile);
1689760c2415Smrg       show_expr (omp_clauses->priority);
1690760c2415Smrg       fputc (')', dumpfile);
1691760c2415Smrg     }
1692760c2415Smrg   for (i = 0; i < OMP_IF_LAST; i++)
1693760c2415Smrg     if (omp_clauses->if_exprs[i])
1694760c2415Smrg       {
1695760c2415Smrg 	static const char *ifs[] = {
1696760c2415Smrg 	  "PARALLEL",
1697760c2415Smrg 	  "TASK",
1698760c2415Smrg 	  "TASKLOOP",
1699760c2415Smrg 	  "TARGET",
1700760c2415Smrg 	  "TARGET DATA",
1701760c2415Smrg 	  "TARGET UPDATE",
1702760c2415Smrg 	  "TARGET ENTER DATA",
1703760c2415Smrg 	  "TARGET EXIT DATA"
1704760c2415Smrg 	};
1705760c2415Smrg       fputs (" IF(", dumpfile);
1706760c2415Smrg       fputs (ifs[i], dumpfile);
1707760c2415Smrg       fputs (": ", dumpfile);
1708760c2415Smrg       show_expr (omp_clauses->if_exprs[i]);
1709760c2415Smrg       fputc (')', dumpfile);
1710760c2415Smrg     }
1711760c2415Smrg   if (omp_clauses->depend_source)
1712760c2415Smrg     fputs (" DEPEND(source)", dumpfile);
1713760c2415Smrg }
1714760c2415Smrg 
1715760c2415Smrg /* Show a single OpenMP or OpenACC directive node and everything underneath it
1716760c2415Smrg    if necessary.  */
1717760c2415Smrg 
1718760c2415Smrg static void
show_omp_node(int level,gfc_code * c)1719760c2415Smrg show_omp_node (int level, gfc_code *c)
1720760c2415Smrg {
1721760c2415Smrg   gfc_omp_clauses *omp_clauses = NULL;
1722760c2415Smrg   const char *name = NULL;
1723760c2415Smrg   bool is_oacc = false;
1724760c2415Smrg 
1725760c2415Smrg   switch (c->op)
1726760c2415Smrg     {
1727760c2415Smrg     case EXEC_OACC_PARALLEL_LOOP:
1728760c2415Smrg       name = "PARALLEL LOOP"; is_oacc = true; break;
1729760c2415Smrg     case EXEC_OACC_PARALLEL: name = "PARALLEL"; is_oacc = true; break;
1730760c2415Smrg     case EXEC_OACC_KERNELS_LOOP: name = "KERNELS LOOP"; is_oacc = true; break;
1731760c2415Smrg     case EXEC_OACC_KERNELS: name = "KERNELS"; is_oacc = true; break;
1732*0bfacb9bSmrg     case EXEC_OACC_SERIAL_LOOP: name = "SERIAL LOOP"; is_oacc = true; break;
1733*0bfacb9bSmrg     case EXEC_OACC_SERIAL: name = "SERIAL"; is_oacc = true; break;
1734760c2415Smrg     case EXEC_OACC_DATA: name = "DATA"; is_oacc = true; break;
1735760c2415Smrg     case EXEC_OACC_HOST_DATA: name = "HOST_DATA"; is_oacc = true; break;
1736760c2415Smrg     case EXEC_OACC_LOOP: name = "LOOP"; is_oacc = true; break;
1737760c2415Smrg     case EXEC_OACC_UPDATE: name = "UPDATE"; is_oacc = true; break;
1738760c2415Smrg     case EXEC_OACC_WAIT: name = "WAIT"; is_oacc = true; break;
1739760c2415Smrg     case EXEC_OACC_CACHE: name = "CACHE"; is_oacc = true; break;
1740760c2415Smrg     case EXEC_OACC_ENTER_DATA: name = "ENTER DATA"; is_oacc = true; break;
1741760c2415Smrg     case EXEC_OACC_EXIT_DATA: name = "EXIT DATA"; is_oacc = true; break;
1742760c2415Smrg     case EXEC_OMP_ATOMIC: name = "ATOMIC"; break;
1743760c2415Smrg     case EXEC_OMP_BARRIER: name = "BARRIER"; break;
1744760c2415Smrg     case EXEC_OMP_CANCEL: name = "CANCEL"; break;
1745760c2415Smrg     case EXEC_OMP_CANCELLATION_POINT: name = "CANCELLATION POINT"; break;
1746760c2415Smrg     case EXEC_OMP_CRITICAL: name = "CRITICAL"; break;
1747760c2415Smrg     case EXEC_OMP_DISTRIBUTE: name = "DISTRIBUTE"; break;
1748760c2415Smrg     case EXEC_OMP_DISTRIBUTE_PARALLEL_DO:
1749760c2415Smrg       name = "DISTRIBUTE PARALLEL DO"; break;
1750760c2415Smrg     case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
1751760c2415Smrg       name = "DISTRIBUTE PARALLEL DO SIMD"; break;
1752760c2415Smrg     case EXEC_OMP_DISTRIBUTE_SIMD: name = "DISTRIBUTE SIMD"; break;
1753760c2415Smrg     case EXEC_OMP_DO: name = "DO"; break;
1754760c2415Smrg     case EXEC_OMP_DO_SIMD: name = "DO SIMD"; break;
1755760c2415Smrg     case EXEC_OMP_FLUSH: name = "FLUSH"; break;
1756760c2415Smrg     case EXEC_OMP_MASTER: name = "MASTER"; break;
1757760c2415Smrg     case EXEC_OMP_ORDERED: name = "ORDERED"; break;
1758760c2415Smrg     case EXEC_OMP_PARALLEL: name = "PARALLEL"; break;
1759760c2415Smrg     case EXEC_OMP_PARALLEL_DO: name = "PARALLEL DO"; break;
1760760c2415Smrg     case EXEC_OMP_PARALLEL_DO_SIMD: name = "PARALLEL DO SIMD"; break;
1761760c2415Smrg     case EXEC_OMP_PARALLEL_SECTIONS: name = "PARALLEL SECTIONS"; break;
1762760c2415Smrg     case EXEC_OMP_PARALLEL_WORKSHARE: name = "PARALLEL WORKSHARE"; break;
1763760c2415Smrg     case EXEC_OMP_SECTIONS: name = "SECTIONS"; break;
1764760c2415Smrg     case EXEC_OMP_SIMD: name = "SIMD"; break;
1765760c2415Smrg     case EXEC_OMP_SINGLE: name = "SINGLE"; break;
1766760c2415Smrg     case EXEC_OMP_TARGET: name = "TARGET"; break;
1767760c2415Smrg     case EXEC_OMP_TARGET_DATA: name = "TARGET DATA"; break;
1768760c2415Smrg     case EXEC_OMP_TARGET_ENTER_DATA: name = "TARGET ENTER DATA"; break;
1769760c2415Smrg     case EXEC_OMP_TARGET_EXIT_DATA: name = "TARGET EXIT DATA"; break;
1770760c2415Smrg     case EXEC_OMP_TARGET_PARALLEL: name = "TARGET PARALLEL"; break;
1771760c2415Smrg     case EXEC_OMP_TARGET_PARALLEL_DO: name = "TARGET PARALLEL DO"; break;
1772760c2415Smrg     case EXEC_OMP_TARGET_PARALLEL_DO_SIMD:
1773760c2415Smrg       name = "TARGET_PARALLEL_DO_SIMD"; break;
1774760c2415Smrg     case EXEC_OMP_TARGET_SIMD: name = "TARGET SIMD"; break;
1775760c2415Smrg     case EXEC_OMP_TARGET_TEAMS: name = "TARGET TEAMS"; break;
1776760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE:
1777760c2415Smrg       name = "TARGET TEAMS DISTRIBUTE"; break;
1778760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
1779760c2415Smrg       name = "TARGET TEAMS DISTRIBUTE PARALLEL DO"; break;
1780760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
1781760c2415Smrg       name = "TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
1782760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
1783760c2415Smrg       name = "TARGET TEAMS DISTRIBUTE SIMD"; break;
1784760c2415Smrg     case EXEC_OMP_TARGET_UPDATE: name = "TARGET UPDATE"; break;
1785760c2415Smrg     case EXEC_OMP_TASK: name = "TASK"; break;
1786760c2415Smrg     case EXEC_OMP_TASKGROUP: name = "TASKGROUP"; break;
1787760c2415Smrg     case EXEC_OMP_TASKLOOP: name = "TASKLOOP"; break;
1788760c2415Smrg     case EXEC_OMP_TASKLOOP_SIMD: name = "TASKLOOP SIMD"; break;
1789760c2415Smrg     case EXEC_OMP_TASKWAIT: name = "TASKWAIT"; break;
1790760c2415Smrg     case EXEC_OMP_TASKYIELD: name = "TASKYIELD"; break;
1791760c2415Smrg     case EXEC_OMP_TEAMS: name = "TEAMS"; break;
1792760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE: name = "TEAMS DISTRIBUTE"; break;
1793760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
1794760c2415Smrg       name = "TEAMS DISTRIBUTE PARALLEL DO"; break;
1795760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
1796760c2415Smrg       name = "TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
1797760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD: name = "TEAMS DISTRIBUTE SIMD"; break;
1798760c2415Smrg     case EXEC_OMP_WORKSHARE: name = "WORKSHARE"; break;
1799760c2415Smrg     default:
1800760c2415Smrg       gcc_unreachable ();
1801760c2415Smrg     }
1802760c2415Smrg   fprintf (dumpfile, "!$%s %s", is_oacc ? "ACC" : "OMP", name);
1803760c2415Smrg   switch (c->op)
1804760c2415Smrg     {
1805760c2415Smrg     case EXEC_OACC_PARALLEL_LOOP:
1806760c2415Smrg     case EXEC_OACC_PARALLEL:
1807760c2415Smrg     case EXEC_OACC_KERNELS_LOOP:
1808760c2415Smrg     case EXEC_OACC_KERNELS:
1809*0bfacb9bSmrg     case EXEC_OACC_SERIAL_LOOP:
1810*0bfacb9bSmrg     case EXEC_OACC_SERIAL:
1811760c2415Smrg     case EXEC_OACC_DATA:
1812760c2415Smrg     case EXEC_OACC_HOST_DATA:
1813760c2415Smrg     case EXEC_OACC_LOOP:
1814760c2415Smrg     case EXEC_OACC_UPDATE:
1815760c2415Smrg     case EXEC_OACC_WAIT:
1816760c2415Smrg     case EXEC_OACC_CACHE:
1817760c2415Smrg     case EXEC_OACC_ENTER_DATA:
1818760c2415Smrg     case EXEC_OACC_EXIT_DATA:
1819760c2415Smrg     case EXEC_OMP_CANCEL:
1820760c2415Smrg     case EXEC_OMP_CANCELLATION_POINT:
1821760c2415Smrg     case EXEC_OMP_DISTRIBUTE:
1822760c2415Smrg     case EXEC_OMP_DISTRIBUTE_PARALLEL_DO:
1823760c2415Smrg     case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
1824760c2415Smrg     case EXEC_OMP_DISTRIBUTE_SIMD:
1825760c2415Smrg     case EXEC_OMP_DO:
1826760c2415Smrg     case EXEC_OMP_DO_SIMD:
1827760c2415Smrg     case EXEC_OMP_ORDERED:
1828760c2415Smrg     case EXEC_OMP_PARALLEL:
1829760c2415Smrg     case EXEC_OMP_PARALLEL_DO:
1830760c2415Smrg     case EXEC_OMP_PARALLEL_DO_SIMD:
1831760c2415Smrg     case EXEC_OMP_PARALLEL_SECTIONS:
1832760c2415Smrg     case EXEC_OMP_PARALLEL_WORKSHARE:
1833760c2415Smrg     case EXEC_OMP_SECTIONS:
1834760c2415Smrg     case EXEC_OMP_SIMD:
1835760c2415Smrg     case EXEC_OMP_SINGLE:
1836760c2415Smrg     case EXEC_OMP_TARGET:
1837760c2415Smrg     case EXEC_OMP_TARGET_DATA:
1838760c2415Smrg     case EXEC_OMP_TARGET_ENTER_DATA:
1839760c2415Smrg     case EXEC_OMP_TARGET_EXIT_DATA:
1840760c2415Smrg     case EXEC_OMP_TARGET_PARALLEL:
1841760c2415Smrg     case EXEC_OMP_TARGET_PARALLEL_DO:
1842760c2415Smrg     case EXEC_OMP_TARGET_PARALLEL_DO_SIMD:
1843760c2415Smrg     case EXEC_OMP_TARGET_SIMD:
1844760c2415Smrg     case EXEC_OMP_TARGET_TEAMS:
1845760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE:
1846760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
1847760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
1848760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
1849760c2415Smrg     case EXEC_OMP_TARGET_UPDATE:
1850760c2415Smrg     case EXEC_OMP_TASK:
1851760c2415Smrg     case EXEC_OMP_TASKLOOP:
1852760c2415Smrg     case EXEC_OMP_TASKLOOP_SIMD:
1853760c2415Smrg     case EXEC_OMP_TEAMS:
1854760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE:
1855760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
1856760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
1857760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD:
1858760c2415Smrg     case EXEC_OMP_WORKSHARE:
1859760c2415Smrg       omp_clauses = c->ext.omp_clauses;
1860760c2415Smrg       break;
1861760c2415Smrg     case EXEC_OMP_CRITICAL:
1862760c2415Smrg       omp_clauses = c->ext.omp_clauses;
1863760c2415Smrg       if (omp_clauses)
1864760c2415Smrg 	fprintf (dumpfile, " (%s)", c->ext.omp_clauses->critical_name);
1865760c2415Smrg       break;
1866760c2415Smrg     case EXEC_OMP_FLUSH:
1867760c2415Smrg       if (c->ext.omp_namelist)
1868760c2415Smrg 	{
1869760c2415Smrg 	  fputs (" (", dumpfile);
1870760c2415Smrg 	  show_omp_namelist (OMP_LIST_NUM, c->ext.omp_namelist);
1871760c2415Smrg 	  fputc (')', dumpfile);
1872760c2415Smrg 	}
1873760c2415Smrg       return;
1874760c2415Smrg     case EXEC_OMP_BARRIER:
1875760c2415Smrg     case EXEC_OMP_TASKWAIT:
1876760c2415Smrg     case EXEC_OMP_TASKYIELD:
1877760c2415Smrg       return;
1878760c2415Smrg     default:
1879760c2415Smrg       break;
1880760c2415Smrg     }
1881760c2415Smrg   if (omp_clauses)
1882760c2415Smrg     show_omp_clauses (omp_clauses);
1883760c2415Smrg   fputc ('\n', dumpfile);
1884760c2415Smrg 
1885760c2415Smrg   /* OpenMP and OpenACC executable directives don't have associated blocks.  */
1886760c2415Smrg   if (c->op == EXEC_OACC_CACHE || c->op == EXEC_OACC_UPDATE
1887760c2415Smrg       || c->op == EXEC_OACC_ENTER_DATA || c->op == EXEC_OACC_EXIT_DATA
1888760c2415Smrg       || c->op == EXEC_OMP_TARGET_UPDATE || c->op == EXEC_OMP_TARGET_ENTER_DATA
1889760c2415Smrg       || c->op == EXEC_OMP_TARGET_EXIT_DATA
1890760c2415Smrg       || (c->op == EXEC_OMP_ORDERED && c->block == NULL))
1891760c2415Smrg     return;
1892760c2415Smrg   if (c->op == EXEC_OMP_SECTIONS || c->op == EXEC_OMP_PARALLEL_SECTIONS)
1893760c2415Smrg     {
1894760c2415Smrg       gfc_code *d = c->block;
1895760c2415Smrg       while (d != NULL)
1896760c2415Smrg 	{
1897760c2415Smrg 	  show_code (level + 1, d->next);
1898760c2415Smrg 	  if (d->block == NULL)
1899760c2415Smrg 	    break;
1900760c2415Smrg 	  code_indent (level, 0);
1901760c2415Smrg 	  fputs ("!$OMP SECTION\n", dumpfile);
1902760c2415Smrg 	  d = d->block;
1903760c2415Smrg 	}
1904760c2415Smrg     }
1905760c2415Smrg   else
1906760c2415Smrg     show_code (level + 1, c->block->next);
1907760c2415Smrg   if (c->op == EXEC_OMP_ATOMIC)
1908760c2415Smrg     return;
1909760c2415Smrg   fputc ('\n', dumpfile);
1910760c2415Smrg   code_indent (level, 0);
1911760c2415Smrg   fprintf (dumpfile, "!$%s END %s", is_oacc ? "ACC" : "OMP", name);
1912760c2415Smrg   if (omp_clauses != NULL)
1913760c2415Smrg     {
1914760c2415Smrg       if (omp_clauses->lists[OMP_LIST_COPYPRIVATE])
1915760c2415Smrg 	{
1916760c2415Smrg 	  fputs (" COPYPRIVATE(", dumpfile);
1917760c2415Smrg 	  show_omp_namelist (OMP_LIST_COPYPRIVATE,
1918760c2415Smrg 			     omp_clauses->lists[OMP_LIST_COPYPRIVATE]);
1919760c2415Smrg 	  fputc (')', dumpfile);
1920760c2415Smrg 	}
1921760c2415Smrg       else if (omp_clauses->nowait)
1922760c2415Smrg 	fputs (" NOWAIT", dumpfile);
1923760c2415Smrg     }
1924760c2415Smrg   else if (c->op == EXEC_OMP_CRITICAL && c->ext.omp_clauses)
1925760c2415Smrg     fprintf (dumpfile, " (%s)", c->ext.omp_clauses->critical_name);
1926760c2415Smrg }
1927760c2415Smrg 
1928760c2415Smrg 
1929760c2415Smrg /* Show a single code node and everything underneath it if necessary.  */
1930760c2415Smrg 
1931760c2415Smrg static void
show_code_node(int level,gfc_code * c)1932760c2415Smrg show_code_node (int level, gfc_code *c)
1933760c2415Smrg {
1934760c2415Smrg   gfc_forall_iterator *fa;
1935760c2415Smrg   gfc_open *open;
1936760c2415Smrg   gfc_case *cp;
1937760c2415Smrg   gfc_alloc *a;
1938760c2415Smrg   gfc_code *d;
1939760c2415Smrg   gfc_close *close;
1940760c2415Smrg   gfc_filepos *fp;
1941760c2415Smrg   gfc_inquire *i;
1942760c2415Smrg   gfc_dt *dt;
1943760c2415Smrg   gfc_namespace *ns;
1944760c2415Smrg 
1945760c2415Smrg   if (c->here)
1946760c2415Smrg     {
1947760c2415Smrg       fputc ('\n', dumpfile);
1948760c2415Smrg       code_indent (level, c->here);
1949760c2415Smrg     }
1950760c2415Smrg   else
1951760c2415Smrg     show_indent ();
1952760c2415Smrg 
1953760c2415Smrg   switch (c->op)
1954760c2415Smrg     {
1955760c2415Smrg     case EXEC_END_PROCEDURE:
1956760c2415Smrg       break;
1957760c2415Smrg 
1958760c2415Smrg     case EXEC_NOP:
1959760c2415Smrg       fputs ("NOP", dumpfile);
1960760c2415Smrg       break;
1961760c2415Smrg 
1962760c2415Smrg     case EXEC_CONTINUE:
1963760c2415Smrg       fputs ("CONTINUE", dumpfile);
1964760c2415Smrg       break;
1965760c2415Smrg 
1966760c2415Smrg     case EXEC_ENTRY:
1967760c2415Smrg       fprintf (dumpfile, "ENTRY %s", c->ext.entry->sym->name);
1968760c2415Smrg       break;
1969760c2415Smrg 
1970760c2415Smrg     case EXEC_INIT_ASSIGN:
1971760c2415Smrg     case EXEC_ASSIGN:
1972760c2415Smrg       fputs ("ASSIGN ", dumpfile);
1973760c2415Smrg       show_expr (c->expr1);
1974760c2415Smrg       fputc (' ', dumpfile);
1975760c2415Smrg       show_expr (c->expr2);
1976760c2415Smrg       break;
1977760c2415Smrg 
1978760c2415Smrg     case EXEC_LABEL_ASSIGN:
1979760c2415Smrg       fputs ("LABEL ASSIGN ", dumpfile);
1980760c2415Smrg       show_expr (c->expr1);
1981760c2415Smrg       fprintf (dumpfile, " %d", c->label1->value);
1982760c2415Smrg       break;
1983760c2415Smrg 
1984760c2415Smrg     case EXEC_POINTER_ASSIGN:
1985760c2415Smrg       fputs ("POINTER ASSIGN ", dumpfile);
1986760c2415Smrg       show_expr (c->expr1);
1987760c2415Smrg       fputc (' ', dumpfile);
1988760c2415Smrg       show_expr (c->expr2);
1989760c2415Smrg       break;
1990760c2415Smrg 
1991760c2415Smrg     case EXEC_GOTO:
1992760c2415Smrg       fputs ("GOTO ", dumpfile);
1993760c2415Smrg       if (c->label1)
1994760c2415Smrg 	fprintf (dumpfile, "%d", c->label1->value);
1995760c2415Smrg       else
1996760c2415Smrg 	{
1997760c2415Smrg 	  show_expr (c->expr1);
1998760c2415Smrg 	  d = c->block;
1999760c2415Smrg 	  if (d != NULL)
2000760c2415Smrg 	    {
2001760c2415Smrg 	      fputs (", (", dumpfile);
2002760c2415Smrg 	      for (; d; d = d ->block)
2003760c2415Smrg 		{
2004760c2415Smrg 		  code_indent (level, d->label1);
2005760c2415Smrg 		  if (d->block != NULL)
2006760c2415Smrg 		    fputc (',', dumpfile);
2007760c2415Smrg 		  else
2008760c2415Smrg 		    fputc (')', dumpfile);
2009760c2415Smrg 		}
2010760c2415Smrg 	    }
2011760c2415Smrg 	}
2012760c2415Smrg       break;
2013760c2415Smrg 
2014760c2415Smrg     case EXEC_CALL:
2015760c2415Smrg     case EXEC_ASSIGN_CALL:
2016760c2415Smrg       if (c->resolved_sym)
2017760c2415Smrg 	fprintf (dumpfile, "CALL %s ", c->resolved_sym->name);
2018760c2415Smrg       else if (c->symtree)
2019760c2415Smrg 	fprintf (dumpfile, "CALL %s ", c->symtree->name);
2020760c2415Smrg       else
2021760c2415Smrg 	fputs ("CALL ?? ", dumpfile);
2022760c2415Smrg 
2023760c2415Smrg       show_actual_arglist (c->ext.actual);
2024760c2415Smrg       break;
2025760c2415Smrg 
2026760c2415Smrg     case EXEC_COMPCALL:
2027760c2415Smrg       fputs ("CALL ", dumpfile);
2028760c2415Smrg       show_compcall (c->expr1);
2029760c2415Smrg       break;
2030760c2415Smrg 
2031760c2415Smrg     case EXEC_CALL_PPC:
2032760c2415Smrg       fputs ("CALL ", dumpfile);
2033760c2415Smrg       show_expr (c->expr1);
2034760c2415Smrg       show_actual_arglist (c->ext.actual);
2035760c2415Smrg       break;
2036760c2415Smrg 
2037760c2415Smrg     case EXEC_RETURN:
2038760c2415Smrg       fputs ("RETURN ", dumpfile);
2039760c2415Smrg       if (c->expr1)
2040760c2415Smrg 	show_expr (c->expr1);
2041760c2415Smrg       break;
2042760c2415Smrg 
2043760c2415Smrg     case EXEC_PAUSE:
2044760c2415Smrg       fputs ("PAUSE ", dumpfile);
2045760c2415Smrg 
2046760c2415Smrg       if (c->expr1 != NULL)
2047760c2415Smrg 	show_expr (c->expr1);
2048760c2415Smrg       else
2049760c2415Smrg 	fprintf (dumpfile, "%d", c->ext.stop_code);
2050760c2415Smrg 
2051760c2415Smrg       break;
2052760c2415Smrg 
2053760c2415Smrg     case EXEC_ERROR_STOP:
2054760c2415Smrg       fputs ("ERROR ", dumpfile);
2055760c2415Smrg       /* Fall through.  */
2056760c2415Smrg 
2057760c2415Smrg     case EXEC_STOP:
2058760c2415Smrg       fputs ("STOP ", dumpfile);
2059760c2415Smrg 
2060760c2415Smrg       if (c->expr1 != NULL)
2061760c2415Smrg 	show_expr (c->expr1);
2062760c2415Smrg       else
2063760c2415Smrg 	fprintf (dumpfile, "%d", c->ext.stop_code);
2064760c2415Smrg 
2065760c2415Smrg       break;
2066760c2415Smrg 
2067760c2415Smrg     case EXEC_FAIL_IMAGE:
2068760c2415Smrg       fputs ("FAIL IMAGE ", dumpfile);
2069760c2415Smrg       break;
2070760c2415Smrg 
2071760c2415Smrg     case EXEC_CHANGE_TEAM:
2072760c2415Smrg       fputs ("CHANGE TEAM", dumpfile);
2073760c2415Smrg       break;
2074760c2415Smrg 
2075760c2415Smrg     case EXEC_END_TEAM:
2076760c2415Smrg       fputs ("END TEAM", dumpfile);
2077760c2415Smrg       break;
2078760c2415Smrg 
2079760c2415Smrg     case EXEC_FORM_TEAM:
2080760c2415Smrg       fputs ("FORM TEAM", dumpfile);
2081760c2415Smrg       break;
2082760c2415Smrg 
2083760c2415Smrg     case EXEC_SYNC_TEAM:
2084760c2415Smrg       fputs ("SYNC TEAM", dumpfile);
2085760c2415Smrg       break;
2086760c2415Smrg 
2087760c2415Smrg     case EXEC_SYNC_ALL:
2088760c2415Smrg       fputs ("SYNC ALL ", dumpfile);
2089760c2415Smrg       if (c->expr2 != NULL)
2090760c2415Smrg 	{
2091760c2415Smrg 	  fputs (" stat=", dumpfile);
2092760c2415Smrg 	  show_expr (c->expr2);
2093760c2415Smrg 	}
2094760c2415Smrg       if (c->expr3 != NULL)
2095760c2415Smrg 	{
2096760c2415Smrg 	  fputs (" errmsg=", dumpfile);
2097760c2415Smrg 	  show_expr (c->expr3);
2098760c2415Smrg 	}
2099760c2415Smrg       break;
2100760c2415Smrg 
2101760c2415Smrg     case EXEC_SYNC_MEMORY:
2102760c2415Smrg       fputs ("SYNC MEMORY ", dumpfile);
2103760c2415Smrg       if (c->expr2 != NULL)
2104760c2415Smrg  	{
2105760c2415Smrg 	  fputs (" stat=", dumpfile);
2106760c2415Smrg 	  show_expr (c->expr2);
2107760c2415Smrg 	}
2108760c2415Smrg       if (c->expr3 != NULL)
2109760c2415Smrg 	{
2110760c2415Smrg 	  fputs (" errmsg=", dumpfile);
2111760c2415Smrg 	  show_expr (c->expr3);
2112760c2415Smrg 	}
2113760c2415Smrg       break;
2114760c2415Smrg 
2115760c2415Smrg     case EXEC_SYNC_IMAGES:
2116760c2415Smrg       fputs ("SYNC IMAGES  image-set=", dumpfile);
2117760c2415Smrg       if (c->expr1 != NULL)
2118760c2415Smrg 	show_expr (c->expr1);
2119760c2415Smrg       else
2120760c2415Smrg 	fputs ("* ", dumpfile);
2121760c2415Smrg       if (c->expr2 != NULL)
2122760c2415Smrg 	{
2123760c2415Smrg 	  fputs (" stat=", dumpfile);
2124760c2415Smrg 	  show_expr (c->expr2);
2125760c2415Smrg 	}
2126760c2415Smrg       if (c->expr3 != NULL)
2127760c2415Smrg 	{
2128760c2415Smrg 	  fputs (" errmsg=", dumpfile);
2129760c2415Smrg 	  show_expr (c->expr3);
2130760c2415Smrg 	}
2131760c2415Smrg       break;
2132760c2415Smrg 
2133760c2415Smrg     case EXEC_EVENT_POST:
2134760c2415Smrg     case EXEC_EVENT_WAIT:
2135760c2415Smrg       if (c->op == EXEC_EVENT_POST)
2136760c2415Smrg 	fputs ("EVENT POST ", dumpfile);
2137760c2415Smrg       else
2138760c2415Smrg 	fputs ("EVENT WAIT ", dumpfile);
2139760c2415Smrg 
2140760c2415Smrg       fputs ("event-variable=", dumpfile);
2141760c2415Smrg       if (c->expr1 != NULL)
2142760c2415Smrg 	show_expr (c->expr1);
2143760c2415Smrg       if (c->expr4 != NULL)
2144760c2415Smrg 	{
2145760c2415Smrg 	  fputs (" until_count=", dumpfile);
2146760c2415Smrg 	  show_expr (c->expr4);
2147760c2415Smrg 	}
2148760c2415Smrg       if (c->expr2 != NULL)
2149760c2415Smrg 	{
2150760c2415Smrg 	  fputs (" stat=", dumpfile);
2151760c2415Smrg 	  show_expr (c->expr2);
2152760c2415Smrg 	}
2153760c2415Smrg       if (c->expr3 != NULL)
2154760c2415Smrg 	{
2155760c2415Smrg 	  fputs (" errmsg=", dumpfile);
2156760c2415Smrg 	  show_expr (c->expr3);
2157760c2415Smrg 	}
2158760c2415Smrg       break;
2159760c2415Smrg 
2160760c2415Smrg     case EXEC_LOCK:
2161760c2415Smrg     case EXEC_UNLOCK:
2162760c2415Smrg       if (c->op == EXEC_LOCK)
2163760c2415Smrg 	fputs ("LOCK ", dumpfile);
2164760c2415Smrg       else
2165760c2415Smrg 	fputs ("UNLOCK ", dumpfile);
2166760c2415Smrg 
2167760c2415Smrg       fputs ("lock-variable=", dumpfile);
2168760c2415Smrg       if (c->expr1 != NULL)
2169760c2415Smrg 	show_expr (c->expr1);
2170760c2415Smrg       if (c->expr4 != NULL)
2171760c2415Smrg 	{
2172760c2415Smrg 	  fputs (" acquired_lock=", dumpfile);
2173760c2415Smrg 	  show_expr (c->expr4);
2174760c2415Smrg 	}
2175760c2415Smrg       if (c->expr2 != NULL)
2176760c2415Smrg 	{
2177760c2415Smrg 	  fputs (" stat=", dumpfile);
2178760c2415Smrg 	  show_expr (c->expr2);
2179760c2415Smrg 	}
2180760c2415Smrg       if (c->expr3 != NULL)
2181760c2415Smrg 	{
2182760c2415Smrg 	  fputs (" errmsg=", dumpfile);
2183760c2415Smrg 	  show_expr (c->expr3);
2184760c2415Smrg 	}
2185760c2415Smrg       break;
2186760c2415Smrg 
2187760c2415Smrg     case EXEC_ARITHMETIC_IF:
2188760c2415Smrg       fputs ("IF ", dumpfile);
2189760c2415Smrg       show_expr (c->expr1);
2190760c2415Smrg       fprintf (dumpfile, " %d, %d, %d",
2191760c2415Smrg 		  c->label1->value, c->label2->value, c->label3->value);
2192760c2415Smrg       break;
2193760c2415Smrg 
2194760c2415Smrg     case EXEC_IF:
2195760c2415Smrg       d = c->block;
2196760c2415Smrg       fputs ("IF ", dumpfile);
2197760c2415Smrg       show_expr (d->expr1);
2198760c2415Smrg 
2199760c2415Smrg       ++show_level;
2200760c2415Smrg       show_code (level + 1, d->next);
2201760c2415Smrg       --show_level;
2202760c2415Smrg 
2203760c2415Smrg       d = d->block;
2204760c2415Smrg       for (; d; d = d->block)
2205760c2415Smrg 	{
2206760c2415Smrg 	  fputs("\n", dumpfile);
2207760c2415Smrg 	  code_indent (level, 0);
2208760c2415Smrg 	  if (d->expr1 == NULL)
2209760c2415Smrg 	    fputs ("ELSE", dumpfile);
2210760c2415Smrg 	  else
2211760c2415Smrg 	    {
2212760c2415Smrg 	      fputs ("ELSE IF ", dumpfile);
2213760c2415Smrg 	      show_expr (d->expr1);
2214760c2415Smrg 	    }
2215760c2415Smrg 
2216760c2415Smrg 	  ++show_level;
2217760c2415Smrg 	  show_code (level + 1, d->next);
2218760c2415Smrg 	  --show_level;
2219760c2415Smrg 	}
2220760c2415Smrg 
2221760c2415Smrg       if (c->label1)
2222760c2415Smrg 	code_indent (level, c->label1);
2223760c2415Smrg       else
2224760c2415Smrg 	show_indent ();
2225760c2415Smrg 
2226760c2415Smrg       fputs ("ENDIF", dumpfile);
2227760c2415Smrg       break;
2228760c2415Smrg 
2229760c2415Smrg     case EXEC_BLOCK:
2230760c2415Smrg       {
2231760c2415Smrg 	const char* blocktype;
2232760c2415Smrg 	gfc_namespace *saved_ns;
2233760c2415Smrg 	gfc_association_list *alist;
2234760c2415Smrg 
2235760c2415Smrg 	if (c->ext.block.assoc)
2236760c2415Smrg 	  blocktype = "ASSOCIATE";
2237760c2415Smrg 	else
2238760c2415Smrg 	  blocktype = "BLOCK";
2239760c2415Smrg 	show_indent ();
2240760c2415Smrg 	fprintf (dumpfile, "%s ", blocktype);
2241760c2415Smrg 	for (alist = c->ext.block.assoc; alist; alist = alist->next)
2242760c2415Smrg 	  {
2243760c2415Smrg 	    fprintf (dumpfile, " %s = ", alist->name);
2244760c2415Smrg 	    show_expr (alist->target);
2245760c2415Smrg 	  }
2246760c2415Smrg 
2247760c2415Smrg 	++show_level;
2248760c2415Smrg 	ns = c->ext.block.ns;
2249760c2415Smrg 	saved_ns = gfc_current_ns;
2250760c2415Smrg 	gfc_current_ns = ns;
2251760c2415Smrg 	gfc_traverse_symtree (ns->sym_root, show_symtree);
2252760c2415Smrg 	gfc_current_ns = saved_ns;
2253760c2415Smrg 	show_code (show_level, ns->code);
2254760c2415Smrg 	--show_level;
2255760c2415Smrg 	show_indent ();
2256760c2415Smrg 	fprintf (dumpfile, "END %s ", blocktype);
2257760c2415Smrg 	break;
2258760c2415Smrg       }
2259760c2415Smrg 
2260760c2415Smrg     case EXEC_END_BLOCK:
2261760c2415Smrg       /* Only come here when there is a label on an
2262760c2415Smrg 	 END ASSOCIATE construct.  */
2263760c2415Smrg       break;
2264760c2415Smrg 
2265760c2415Smrg     case EXEC_SELECT:
2266760c2415Smrg     case EXEC_SELECT_TYPE:
2267*0bfacb9bSmrg     case EXEC_SELECT_RANK:
2268760c2415Smrg       d = c->block;
2269*0bfacb9bSmrg       fputc ('\n', dumpfile);
2270*0bfacb9bSmrg       code_indent (level, 0);
2271*0bfacb9bSmrg       if (c->op == EXEC_SELECT_RANK)
2272*0bfacb9bSmrg 	fputs ("SELECT RANK ", dumpfile);
2273*0bfacb9bSmrg       else if (c->op == EXEC_SELECT_TYPE)
2274760c2415Smrg 	fputs ("SELECT TYPE ", dumpfile);
2275760c2415Smrg       else
2276760c2415Smrg 	fputs ("SELECT CASE ", dumpfile);
2277760c2415Smrg       show_expr (c->expr1);
2278760c2415Smrg 
2279760c2415Smrg       for (; d; d = d->block)
2280760c2415Smrg 	{
2281*0bfacb9bSmrg 	  fputc ('\n', dumpfile);
2282760c2415Smrg 	  code_indent (level, 0);
2283760c2415Smrg 	  fputs ("CASE ", dumpfile);
2284760c2415Smrg 	  for (cp = d->ext.block.case_list; cp; cp = cp->next)
2285760c2415Smrg 	    {
2286760c2415Smrg 	      fputc ('(', dumpfile);
2287760c2415Smrg 	      show_expr (cp->low);
2288760c2415Smrg 	      fputc (' ', dumpfile);
2289760c2415Smrg 	      show_expr (cp->high);
2290760c2415Smrg 	      fputc (')', dumpfile);
2291760c2415Smrg 	      fputc (' ', dumpfile);
2292760c2415Smrg 	    }
2293760c2415Smrg 
2294760c2415Smrg 	  show_code (level + 1, d->next);
2295*0bfacb9bSmrg 	  fputc ('\n', dumpfile);
2296760c2415Smrg 	}
2297760c2415Smrg 
2298760c2415Smrg       code_indent (level, c->label1);
2299760c2415Smrg       fputs ("END SELECT", dumpfile);
2300760c2415Smrg       break;
2301760c2415Smrg 
2302760c2415Smrg     case EXEC_WHERE:
2303760c2415Smrg       fputs ("WHERE ", dumpfile);
2304760c2415Smrg 
2305760c2415Smrg       d = c->block;
2306760c2415Smrg       show_expr (d->expr1);
2307760c2415Smrg       fputc ('\n', dumpfile);
2308760c2415Smrg 
2309760c2415Smrg       show_code (level + 1, d->next);
2310760c2415Smrg 
2311760c2415Smrg       for (d = d->block; d; d = d->block)
2312760c2415Smrg 	{
2313760c2415Smrg 	  code_indent (level, 0);
2314760c2415Smrg 	  fputs ("ELSE WHERE ", dumpfile);
2315760c2415Smrg 	  show_expr (d->expr1);
2316760c2415Smrg 	  fputc ('\n', dumpfile);
2317760c2415Smrg 	  show_code (level + 1, d->next);
2318760c2415Smrg 	}
2319760c2415Smrg 
2320760c2415Smrg       code_indent (level, 0);
2321760c2415Smrg       fputs ("END WHERE", dumpfile);
2322760c2415Smrg       break;
2323760c2415Smrg 
2324760c2415Smrg 
2325760c2415Smrg     case EXEC_FORALL:
2326760c2415Smrg       fputs ("FORALL ", dumpfile);
2327760c2415Smrg       for (fa = c->ext.forall_iterator; fa; fa = fa->next)
2328760c2415Smrg 	{
2329760c2415Smrg 	  show_expr (fa->var);
2330760c2415Smrg 	  fputc (' ', dumpfile);
2331760c2415Smrg 	  show_expr (fa->start);
2332760c2415Smrg 	  fputc (':', dumpfile);
2333760c2415Smrg 	  show_expr (fa->end);
2334760c2415Smrg 	  fputc (':', dumpfile);
2335760c2415Smrg 	  show_expr (fa->stride);
2336760c2415Smrg 
2337760c2415Smrg 	  if (fa->next != NULL)
2338760c2415Smrg 	    fputc (',', dumpfile);
2339760c2415Smrg 	}
2340760c2415Smrg 
2341760c2415Smrg       if (c->expr1 != NULL)
2342760c2415Smrg 	{
2343760c2415Smrg 	  fputc (',', dumpfile);
2344760c2415Smrg 	  show_expr (c->expr1);
2345760c2415Smrg 	}
2346760c2415Smrg       fputc ('\n', dumpfile);
2347760c2415Smrg 
2348760c2415Smrg       show_code (level + 1, c->block->next);
2349760c2415Smrg 
2350760c2415Smrg       code_indent (level, 0);
2351760c2415Smrg       fputs ("END FORALL", dumpfile);
2352760c2415Smrg       break;
2353760c2415Smrg 
2354760c2415Smrg     case EXEC_CRITICAL:
2355760c2415Smrg       fputs ("CRITICAL\n", dumpfile);
2356760c2415Smrg       show_code (level + 1, c->block->next);
2357760c2415Smrg       code_indent (level, 0);
2358760c2415Smrg       fputs ("END CRITICAL", dumpfile);
2359760c2415Smrg       break;
2360760c2415Smrg 
2361760c2415Smrg     case EXEC_DO:
2362760c2415Smrg       fputs ("DO ", dumpfile);
2363760c2415Smrg       if (c->label1)
2364760c2415Smrg 	fprintf (dumpfile, " %-5d ", c->label1->value);
2365760c2415Smrg 
2366760c2415Smrg       show_expr (c->ext.iterator->var);
2367760c2415Smrg       fputc ('=', dumpfile);
2368760c2415Smrg       show_expr (c->ext.iterator->start);
2369760c2415Smrg       fputc (' ', dumpfile);
2370760c2415Smrg       show_expr (c->ext.iterator->end);
2371760c2415Smrg       fputc (' ', dumpfile);
2372760c2415Smrg       show_expr (c->ext.iterator->step);
2373760c2415Smrg 
2374760c2415Smrg       ++show_level;
2375760c2415Smrg       show_code (level + 1, c->block->next);
2376760c2415Smrg       --show_level;
2377760c2415Smrg 
2378760c2415Smrg       if (c->label1)
2379760c2415Smrg 	break;
2380760c2415Smrg 
2381760c2415Smrg       show_indent ();
2382760c2415Smrg       fputs ("END DO", dumpfile);
2383760c2415Smrg       break;
2384760c2415Smrg 
2385760c2415Smrg     case EXEC_DO_CONCURRENT:
2386760c2415Smrg       fputs ("DO CONCURRENT ", dumpfile);
2387760c2415Smrg       for (fa = c->ext.forall_iterator; fa; fa = fa->next)
2388760c2415Smrg         {
2389760c2415Smrg           show_expr (fa->var);
2390760c2415Smrg           fputc (' ', dumpfile);
2391760c2415Smrg           show_expr (fa->start);
2392760c2415Smrg           fputc (':', dumpfile);
2393760c2415Smrg           show_expr (fa->end);
2394760c2415Smrg           fputc (':', dumpfile);
2395760c2415Smrg           show_expr (fa->stride);
2396760c2415Smrg 
2397760c2415Smrg           if (fa->next != NULL)
2398760c2415Smrg             fputc (',', dumpfile);
2399760c2415Smrg         }
2400760c2415Smrg       show_expr (c->expr1);
2401760c2415Smrg       ++show_level;
2402760c2415Smrg 
2403760c2415Smrg       show_code (level + 1, c->block->next);
2404760c2415Smrg       --show_level;
2405760c2415Smrg       code_indent (level, c->label1);
2406760c2415Smrg       show_indent ();
2407760c2415Smrg       fputs ("END DO", dumpfile);
2408760c2415Smrg       break;
2409760c2415Smrg 
2410760c2415Smrg     case EXEC_DO_WHILE:
2411760c2415Smrg       fputs ("DO WHILE ", dumpfile);
2412760c2415Smrg       show_expr (c->expr1);
2413760c2415Smrg       fputc ('\n', dumpfile);
2414760c2415Smrg 
2415760c2415Smrg       show_code (level + 1, c->block->next);
2416760c2415Smrg 
2417760c2415Smrg       code_indent (level, c->label1);
2418760c2415Smrg       fputs ("END DO", dumpfile);
2419760c2415Smrg       break;
2420760c2415Smrg 
2421760c2415Smrg     case EXEC_CYCLE:
2422760c2415Smrg       fputs ("CYCLE", dumpfile);
2423760c2415Smrg       if (c->symtree)
2424760c2415Smrg 	fprintf (dumpfile, " %s", c->symtree->n.sym->name);
2425760c2415Smrg       break;
2426760c2415Smrg 
2427760c2415Smrg     case EXEC_EXIT:
2428760c2415Smrg       fputs ("EXIT", dumpfile);
2429760c2415Smrg       if (c->symtree)
2430760c2415Smrg 	fprintf (dumpfile, " %s", c->symtree->n.sym->name);
2431760c2415Smrg       break;
2432760c2415Smrg 
2433760c2415Smrg     case EXEC_ALLOCATE:
2434760c2415Smrg       fputs ("ALLOCATE ", dumpfile);
2435760c2415Smrg       if (c->expr1)
2436760c2415Smrg 	{
2437760c2415Smrg 	  fputs (" STAT=", dumpfile);
2438760c2415Smrg 	  show_expr (c->expr1);
2439760c2415Smrg 	}
2440760c2415Smrg 
2441760c2415Smrg       if (c->expr2)
2442760c2415Smrg 	{
2443760c2415Smrg 	  fputs (" ERRMSG=", dumpfile);
2444760c2415Smrg 	  show_expr (c->expr2);
2445760c2415Smrg 	}
2446760c2415Smrg 
2447760c2415Smrg       if (c->expr3)
2448760c2415Smrg 	{
2449760c2415Smrg 	  if (c->expr3->mold)
2450760c2415Smrg 	    fputs (" MOLD=", dumpfile);
2451760c2415Smrg 	  else
2452760c2415Smrg 	    fputs (" SOURCE=", dumpfile);
2453760c2415Smrg 	  show_expr (c->expr3);
2454760c2415Smrg 	}
2455760c2415Smrg 
2456760c2415Smrg       for (a = c->ext.alloc.list; a; a = a->next)
2457760c2415Smrg 	{
2458760c2415Smrg 	  fputc (' ', dumpfile);
2459760c2415Smrg 	  show_expr (a->expr);
2460760c2415Smrg 	}
2461760c2415Smrg 
2462760c2415Smrg       break;
2463760c2415Smrg 
2464760c2415Smrg     case EXEC_DEALLOCATE:
2465760c2415Smrg       fputs ("DEALLOCATE ", dumpfile);
2466760c2415Smrg       if (c->expr1)
2467760c2415Smrg 	{
2468760c2415Smrg 	  fputs (" STAT=", dumpfile);
2469760c2415Smrg 	  show_expr (c->expr1);
2470760c2415Smrg 	}
2471760c2415Smrg 
2472760c2415Smrg       if (c->expr2)
2473760c2415Smrg 	{
2474760c2415Smrg 	  fputs (" ERRMSG=", dumpfile);
2475760c2415Smrg 	  show_expr (c->expr2);
2476760c2415Smrg 	}
2477760c2415Smrg 
2478760c2415Smrg       for (a = c->ext.alloc.list; a; a = a->next)
2479760c2415Smrg 	{
2480760c2415Smrg 	  fputc (' ', dumpfile);
2481760c2415Smrg 	  show_expr (a->expr);
2482760c2415Smrg 	}
2483760c2415Smrg 
2484760c2415Smrg       break;
2485760c2415Smrg 
2486760c2415Smrg     case EXEC_OPEN:
2487760c2415Smrg       fputs ("OPEN", dumpfile);
2488760c2415Smrg       open = c->ext.open;
2489760c2415Smrg 
2490760c2415Smrg       if (open->unit)
2491760c2415Smrg 	{
2492760c2415Smrg 	  fputs (" UNIT=", dumpfile);
2493760c2415Smrg 	  show_expr (open->unit);
2494760c2415Smrg 	}
2495760c2415Smrg       if (open->iomsg)
2496760c2415Smrg 	{
2497760c2415Smrg 	  fputs (" IOMSG=", dumpfile);
2498760c2415Smrg 	  show_expr (open->iomsg);
2499760c2415Smrg 	}
2500760c2415Smrg       if (open->iostat)
2501760c2415Smrg 	{
2502760c2415Smrg 	  fputs (" IOSTAT=", dumpfile);
2503760c2415Smrg 	  show_expr (open->iostat);
2504760c2415Smrg 	}
2505760c2415Smrg       if (open->file)
2506760c2415Smrg 	{
2507760c2415Smrg 	  fputs (" FILE=", dumpfile);
2508760c2415Smrg 	  show_expr (open->file);
2509760c2415Smrg 	}
2510760c2415Smrg       if (open->status)
2511760c2415Smrg 	{
2512760c2415Smrg 	  fputs (" STATUS=", dumpfile);
2513760c2415Smrg 	  show_expr (open->status);
2514760c2415Smrg 	}
2515760c2415Smrg       if (open->access)
2516760c2415Smrg 	{
2517760c2415Smrg 	  fputs (" ACCESS=", dumpfile);
2518760c2415Smrg 	  show_expr (open->access);
2519760c2415Smrg 	}
2520760c2415Smrg       if (open->form)
2521760c2415Smrg 	{
2522760c2415Smrg 	  fputs (" FORM=", dumpfile);
2523760c2415Smrg 	  show_expr (open->form);
2524760c2415Smrg 	}
2525760c2415Smrg       if (open->recl)
2526760c2415Smrg 	{
2527760c2415Smrg 	  fputs (" RECL=", dumpfile);
2528760c2415Smrg 	  show_expr (open->recl);
2529760c2415Smrg 	}
2530760c2415Smrg       if (open->blank)
2531760c2415Smrg 	{
2532760c2415Smrg 	  fputs (" BLANK=", dumpfile);
2533760c2415Smrg 	  show_expr (open->blank);
2534760c2415Smrg 	}
2535760c2415Smrg       if (open->position)
2536760c2415Smrg 	{
2537760c2415Smrg 	  fputs (" POSITION=", dumpfile);
2538760c2415Smrg 	  show_expr (open->position);
2539760c2415Smrg 	}
2540760c2415Smrg       if (open->action)
2541760c2415Smrg 	{
2542760c2415Smrg 	  fputs (" ACTION=", dumpfile);
2543760c2415Smrg 	  show_expr (open->action);
2544760c2415Smrg 	}
2545760c2415Smrg       if (open->delim)
2546760c2415Smrg 	{
2547760c2415Smrg 	  fputs (" DELIM=", dumpfile);
2548760c2415Smrg 	  show_expr (open->delim);
2549760c2415Smrg 	}
2550760c2415Smrg       if (open->pad)
2551760c2415Smrg 	{
2552760c2415Smrg 	  fputs (" PAD=", dumpfile);
2553760c2415Smrg 	  show_expr (open->pad);
2554760c2415Smrg 	}
2555760c2415Smrg       if (open->decimal)
2556760c2415Smrg 	{
2557760c2415Smrg 	  fputs (" DECIMAL=", dumpfile);
2558760c2415Smrg 	  show_expr (open->decimal);
2559760c2415Smrg 	}
2560760c2415Smrg       if (open->encoding)
2561760c2415Smrg 	{
2562760c2415Smrg 	  fputs (" ENCODING=", dumpfile);
2563760c2415Smrg 	  show_expr (open->encoding);
2564760c2415Smrg 	}
2565760c2415Smrg       if (open->round)
2566760c2415Smrg 	{
2567760c2415Smrg 	  fputs (" ROUND=", dumpfile);
2568760c2415Smrg 	  show_expr (open->round);
2569760c2415Smrg 	}
2570760c2415Smrg       if (open->sign)
2571760c2415Smrg 	{
2572760c2415Smrg 	  fputs (" SIGN=", dumpfile);
2573760c2415Smrg 	  show_expr (open->sign);
2574760c2415Smrg 	}
2575760c2415Smrg       if (open->convert)
2576760c2415Smrg 	{
2577760c2415Smrg 	  fputs (" CONVERT=", dumpfile);
2578760c2415Smrg 	  show_expr (open->convert);
2579760c2415Smrg 	}
2580760c2415Smrg       if (open->asynchronous)
2581760c2415Smrg 	{
2582760c2415Smrg 	  fputs (" ASYNCHRONOUS=", dumpfile);
2583760c2415Smrg 	  show_expr (open->asynchronous);
2584760c2415Smrg 	}
2585760c2415Smrg       if (open->err != NULL)
2586760c2415Smrg 	fprintf (dumpfile, " ERR=%d", open->err->value);
2587760c2415Smrg 
2588760c2415Smrg       break;
2589760c2415Smrg 
2590760c2415Smrg     case EXEC_CLOSE:
2591760c2415Smrg       fputs ("CLOSE", dumpfile);
2592760c2415Smrg       close = c->ext.close;
2593760c2415Smrg 
2594760c2415Smrg       if (close->unit)
2595760c2415Smrg 	{
2596760c2415Smrg 	  fputs (" UNIT=", dumpfile);
2597760c2415Smrg 	  show_expr (close->unit);
2598760c2415Smrg 	}
2599760c2415Smrg       if (close->iomsg)
2600760c2415Smrg 	{
2601760c2415Smrg 	  fputs (" IOMSG=", dumpfile);
2602760c2415Smrg 	  show_expr (close->iomsg);
2603760c2415Smrg 	}
2604760c2415Smrg       if (close->iostat)
2605760c2415Smrg 	{
2606760c2415Smrg 	  fputs (" IOSTAT=", dumpfile);
2607760c2415Smrg 	  show_expr (close->iostat);
2608760c2415Smrg 	}
2609760c2415Smrg       if (close->status)
2610760c2415Smrg 	{
2611760c2415Smrg 	  fputs (" STATUS=", dumpfile);
2612760c2415Smrg 	  show_expr (close->status);
2613760c2415Smrg 	}
2614760c2415Smrg       if (close->err != NULL)
2615760c2415Smrg 	fprintf (dumpfile, " ERR=%d", close->err->value);
2616760c2415Smrg       break;
2617760c2415Smrg 
2618760c2415Smrg     case EXEC_BACKSPACE:
2619760c2415Smrg       fputs ("BACKSPACE", dumpfile);
2620760c2415Smrg       goto show_filepos;
2621760c2415Smrg 
2622760c2415Smrg     case EXEC_ENDFILE:
2623760c2415Smrg       fputs ("ENDFILE", dumpfile);
2624760c2415Smrg       goto show_filepos;
2625760c2415Smrg 
2626760c2415Smrg     case EXEC_REWIND:
2627760c2415Smrg       fputs ("REWIND", dumpfile);
2628760c2415Smrg       goto show_filepos;
2629760c2415Smrg 
2630760c2415Smrg     case EXEC_FLUSH:
2631760c2415Smrg       fputs ("FLUSH", dumpfile);
2632760c2415Smrg 
2633760c2415Smrg     show_filepos:
2634760c2415Smrg       fp = c->ext.filepos;
2635760c2415Smrg 
2636760c2415Smrg       if (fp->unit)
2637760c2415Smrg 	{
2638760c2415Smrg 	  fputs (" UNIT=", dumpfile);
2639760c2415Smrg 	  show_expr (fp->unit);
2640760c2415Smrg 	}
2641760c2415Smrg       if (fp->iomsg)
2642760c2415Smrg 	{
2643760c2415Smrg 	  fputs (" IOMSG=", dumpfile);
2644760c2415Smrg 	  show_expr (fp->iomsg);
2645760c2415Smrg 	}
2646760c2415Smrg       if (fp->iostat)
2647760c2415Smrg 	{
2648760c2415Smrg 	  fputs (" IOSTAT=", dumpfile);
2649760c2415Smrg 	  show_expr (fp->iostat);
2650760c2415Smrg 	}
2651760c2415Smrg       if (fp->err != NULL)
2652760c2415Smrg 	fprintf (dumpfile, " ERR=%d", fp->err->value);
2653760c2415Smrg       break;
2654760c2415Smrg 
2655760c2415Smrg     case EXEC_INQUIRE:
2656760c2415Smrg       fputs ("INQUIRE", dumpfile);
2657760c2415Smrg       i = c->ext.inquire;
2658760c2415Smrg 
2659760c2415Smrg       if (i->unit)
2660760c2415Smrg 	{
2661760c2415Smrg 	  fputs (" UNIT=", dumpfile);
2662760c2415Smrg 	  show_expr (i->unit);
2663760c2415Smrg 	}
2664760c2415Smrg       if (i->file)
2665760c2415Smrg 	{
2666760c2415Smrg 	  fputs (" FILE=", dumpfile);
2667760c2415Smrg 	  show_expr (i->file);
2668760c2415Smrg 	}
2669760c2415Smrg 
2670760c2415Smrg       if (i->iomsg)
2671760c2415Smrg 	{
2672760c2415Smrg 	  fputs (" IOMSG=", dumpfile);
2673760c2415Smrg 	  show_expr (i->iomsg);
2674760c2415Smrg 	}
2675760c2415Smrg       if (i->iostat)
2676760c2415Smrg 	{
2677760c2415Smrg 	  fputs (" IOSTAT=", dumpfile);
2678760c2415Smrg 	  show_expr (i->iostat);
2679760c2415Smrg 	}
2680760c2415Smrg       if (i->exist)
2681760c2415Smrg 	{
2682760c2415Smrg 	  fputs (" EXIST=", dumpfile);
2683760c2415Smrg 	  show_expr (i->exist);
2684760c2415Smrg 	}
2685760c2415Smrg       if (i->opened)
2686760c2415Smrg 	{
2687760c2415Smrg 	  fputs (" OPENED=", dumpfile);
2688760c2415Smrg 	  show_expr (i->opened);
2689760c2415Smrg 	}
2690760c2415Smrg       if (i->number)
2691760c2415Smrg 	{
2692760c2415Smrg 	  fputs (" NUMBER=", dumpfile);
2693760c2415Smrg 	  show_expr (i->number);
2694760c2415Smrg 	}
2695760c2415Smrg       if (i->named)
2696760c2415Smrg 	{
2697760c2415Smrg 	  fputs (" NAMED=", dumpfile);
2698760c2415Smrg 	  show_expr (i->named);
2699760c2415Smrg 	}
2700760c2415Smrg       if (i->name)
2701760c2415Smrg 	{
2702760c2415Smrg 	  fputs (" NAME=", dumpfile);
2703760c2415Smrg 	  show_expr (i->name);
2704760c2415Smrg 	}
2705760c2415Smrg       if (i->access)
2706760c2415Smrg 	{
2707760c2415Smrg 	  fputs (" ACCESS=", dumpfile);
2708760c2415Smrg 	  show_expr (i->access);
2709760c2415Smrg 	}
2710760c2415Smrg       if (i->sequential)
2711760c2415Smrg 	{
2712760c2415Smrg 	  fputs (" SEQUENTIAL=", dumpfile);
2713760c2415Smrg 	  show_expr (i->sequential);
2714760c2415Smrg 	}
2715760c2415Smrg 
2716760c2415Smrg       if (i->direct)
2717760c2415Smrg 	{
2718760c2415Smrg 	  fputs (" DIRECT=", dumpfile);
2719760c2415Smrg 	  show_expr (i->direct);
2720760c2415Smrg 	}
2721760c2415Smrg       if (i->form)
2722760c2415Smrg 	{
2723760c2415Smrg 	  fputs (" FORM=", dumpfile);
2724760c2415Smrg 	  show_expr (i->form);
2725760c2415Smrg 	}
2726760c2415Smrg       if (i->formatted)
2727760c2415Smrg 	{
2728760c2415Smrg 	  fputs (" FORMATTED", dumpfile);
2729760c2415Smrg 	  show_expr (i->formatted);
2730760c2415Smrg 	}
2731760c2415Smrg       if (i->unformatted)
2732760c2415Smrg 	{
2733760c2415Smrg 	  fputs (" UNFORMATTED=", dumpfile);
2734760c2415Smrg 	  show_expr (i->unformatted);
2735760c2415Smrg 	}
2736760c2415Smrg       if (i->recl)
2737760c2415Smrg 	{
2738760c2415Smrg 	  fputs (" RECL=", dumpfile);
2739760c2415Smrg 	  show_expr (i->recl);
2740760c2415Smrg 	}
2741760c2415Smrg       if (i->nextrec)
2742760c2415Smrg 	{
2743760c2415Smrg 	  fputs (" NEXTREC=", dumpfile);
2744760c2415Smrg 	  show_expr (i->nextrec);
2745760c2415Smrg 	}
2746760c2415Smrg       if (i->blank)
2747760c2415Smrg 	{
2748760c2415Smrg 	  fputs (" BLANK=", dumpfile);
2749760c2415Smrg 	  show_expr (i->blank);
2750760c2415Smrg 	}
2751760c2415Smrg       if (i->position)
2752760c2415Smrg 	{
2753760c2415Smrg 	  fputs (" POSITION=", dumpfile);
2754760c2415Smrg 	  show_expr (i->position);
2755760c2415Smrg 	}
2756760c2415Smrg       if (i->action)
2757760c2415Smrg 	{
2758760c2415Smrg 	  fputs (" ACTION=", dumpfile);
2759760c2415Smrg 	  show_expr (i->action);
2760760c2415Smrg 	}
2761760c2415Smrg       if (i->read)
2762760c2415Smrg 	{
2763760c2415Smrg 	  fputs (" READ=", dumpfile);
2764760c2415Smrg 	  show_expr (i->read);
2765760c2415Smrg 	}
2766760c2415Smrg       if (i->write)
2767760c2415Smrg 	{
2768760c2415Smrg 	  fputs (" WRITE=", dumpfile);
2769760c2415Smrg 	  show_expr (i->write);
2770760c2415Smrg 	}
2771760c2415Smrg       if (i->readwrite)
2772760c2415Smrg 	{
2773760c2415Smrg 	  fputs (" READWRITE=", dumpfile);
2774760c2415Smrg 	  show_expr (i->readwrite);
2775760c2415Smrg 	}
2776760c2415Smrg       if (i->delim)
2777760c2415Smrg 	{
2778760c2415Smrg 	  fputs (" DELIM=", dumpfile);
2779760c2415Smrg 	  show_expr (i->delim);
2780760c2415Smrg 	}
2781760c2415Smrg       if (i->pad)
2782760c2415Smrg 	{
2783760c2415Smrg 	  fputs (" PAD=", dumpfile);
2784760c2415Smrg 	  show_expr (i->pad);
2785760c2415Smrg 	}
2786760c2415Smrg       if (i->convert)
2787760c2415Smrg 	{
2788760c2415Smrg 	  fputs (" CONVERT=", dumpfile);
2789760c2415Smrg 	  show_expr (i->convert);
2790760c2415Smrg 	}
2791760c2415Smrg       if (i->asynchronous)
2792760c2415Smrg 	{
2793760c2415Smrg 	  fputs (" ASYNCHRONOUS=", dumpfile);
2794760c2415Smrg 	  show_expr (i->asynchronous);
2795760c2415Smrg 	}
2796760c2415Smrg       if (i->decimal)
2797760c2415Smrg 	{
2798760c2415Smrg 	  fputs (" DECIMAL=", dumpfile);
2799760c2415Smrg 	  show_expr (i->decimal);
2800760c2415Smrg 	}
2801760c2415Smrg       if (i->encoding)
2802760c2415Smrg 	{
2803760c2415Smrg 	  fputs (" ENCODING=", dumpfile);
2804760c2415Smrg 	  show_expr (i->encoding);
2805760c2415Smrg 	}
2806760c2415Smrg       if (i->pending)
2807760c2415Smrg 	{
2808760c2415Smrg 	  fputs (" PENDING=", dumpfile);
2809760c2415Smrg 	  show_expr (i->pending);
2810760c2415Smrg 	}
2811760c2415Smrg       if (i->round)
2812760c2415Smrg 	{
2813760c2415Smrg 	  fputs (" ROUND=", dumpfile);
2814760c2415Smrg 	  show_expr (i->round);
2815760c2415Smrg 	}
2816760c2415Smrg       if (i->sign)
2817760c2415Smrg 	{
2818760c2415Smrg 	  fputs (" SIGN=", dumpfile);
2819760c2415Smrg 	  show_expr (i->sign);
2820760c2415Smrg 	}
2821760c2415Smrg       if (i->size)
2822760c2415Smrg 	{
2823760c2415Smrg 	  fputs (" SIZE=", dumpfile);
2824760c2415Smrg 	  show_expr (i->size);
2825760c2415Smrg 	}
2826760c2415Smrg       if (i->id)
2827760c2415Smrg 	{
2828760c2415Smrg 	  fputs (" ID=", dumpfile);
2829760c2415Smrg 	  show_expr (i->id);
2830760c2415Smrg 	}
2831760c2415Smrg 
2832760c2415Smrg       if (i->err != NULL)
2833760c2415Smrg 	fprintf (dumpfile, " ERR=%d", i->err->value);
2834760c2415Smrg       break;
2835760c2415Smrg 
2836760c2415Smrg     case EXEC_IOLENGTH:
2837760c2415Smrg       fputs ("IOLENGTH ", dumpfile);
2838760c2415Smrg       show_expr (c->expr1);
2839760c2415Smrg       goto show_dt_code;
2840760c2415Smrg       break;
2841760c2415Smrg 
2842760c2415Smrg     case EXEC_READ:
2843760c2415Smrg       fputs ("READ", dumpfile);
2844760c2415Smrg       goto show_dt;
2845760c2415Smrg 
2846760c2415Smrg     case EXEC_WRITE:
2847760c2415Smrg       fputs ("WRITE", dumpfile);
2848760c2415Smrg 
2849760c2415Smrg     show_dt:
2850760c2415Smrg       dt = c->ext.dt;
2851760c2415Smrg       if (dt->io_unit)
2852760c2415Smrg 	{
2853760c2415Smrg 	  fputs (" UNIT=", dumpfile);
2854760c2415Smrg 	  show_expr (dt->io_unit);
2855760c2415Smrg 	}
2856760c2415Smrg 
2857760c2415Smrg       if (dt->format_expr)
2858760c2415Smrg 	{
2859760c2415Smrg 	  fputs (" FMT=", dumpfile);
2860760c2415Smrg 	  show_expr (dt->format_expr);
2861760c2415Smrg 	}
2862760c2415Smrg 
2863760c2415Smrg       if (dt->format_label != NULL)
2864760c2415Smrg 	fprintf (dumpfile, " FMT=%d", dt->format_label->value);
2865760c2415Smrg       if (dt->namelist)
2866760c2415Smrg 	fprintf (dumpfile, " NML=%s", dt->namelist->name);
2867760c2415Smrg 
2868760c2415Smrg       if (dt->iomsg)
2869760c2415Smrg 	{
2870760c2415Smrg 	  fputs (" IOMSG=", dumpfile);
2871760c2415Smrg 	  show_expr (dt->iomsg);
2872760c2415Smrg 	}
2873760c2415Smrg       if (dt->iostat)
2874760c2415Smrg 	{
2875760c2415Smrg 	  fputs (" IOSTAT=", dumpfile);
2876760c2415Smrg 	  show_expr (dt->iostat);
2877760c2415Smrg 	}
2878760c2415Smrg       if (dt->size)
2879760c2415Smrg 	{
2880760c2415Smrg 	  fputs (" SIZE=", dumpfile);
2881760c2415Smrg 	  show_expr (dt->size);
2882760c2415Smrg 	}
2883760c2415Smrg       if (dt->rec)
2884760c2415Smrg 	{
2885760c2415Smrg 	  fputs (" REC=", dumpfile);
2886760c2415Smrg 	  show_expr (dt->rec);
2887760c2415Smrg 	}
2888760c2415Smrg       if (dt->advance)
2889760c2415Smrg 	{
2890760c2415Smrg 	  fputs (" ADVANCE=", dumpfile);
2891760c2415Smrg 	  show_expr (dt->advance);
2892760c2415Smrg 	}
2893760c2415Smrg       if (dt->id)
2894760c2415Smrg 	{
2895760c2415Smrg 	  fputs (" ID=", dumpfile);
2896760c2415Smrg 	  show_expr (dt->id);
2897760c2415Smrg 	}
2898760c2415Smrg       if (dt->pos)
2899760c2415Smrg 	{
2900760c2415Smrg 	  fputs (" POS=", dumpfile);
2901760c2415Smrg 	  show_expr (dt->pos);
2902760c2415Smrg 	}
2903760c2415Smrg       if (dt->asynchronous)
2904760c2415Smrg 	{
2905760c2415Smrg 	  fputs (" ASYNCHRONOUS=", dumpfile);
2906760c2415Smrg 	  show_expr (dt->asynchronous);
2907760c2415Smrg 	}
2908760c2415Smrg       if (dt->blank)
2909760c2415Smrg 	{
2910760c2415Smrg 	  fputs (" BLANK=", dumpfile);
2911760c2415Smrg 	  show_expr (dt->blank);
2912760c2415Smrg 	}
2913760c2415Smrg       if (dt->decimal)
2914760c2415Smrg 	{
2915760c2415Smrg 	  fputs (" DECIMAL=", dumpfile);
2916760c2415Smrg 	  show_expr (dt->decimal);
2917760c2415Smrg 	}
2918760c2415Smrg       if (dt->delim)
2919760c2415Smrg 	{
2920760c2415Smrg 	  fputs (" DELIM=", dumpfile);
2921760c2415Smrg 	  show_expr (dt->delim);
2922760c2415Smrg 	}
2923760c2415Smrg       if (dt->pad)
2924760c2415Smrg 	{
2925760c2415Smrg 	  fputs (" PAD=", dumpfile);
2926760c2415Smrg 	  show_expr (dt->pad);
2927760c2415Smrg 	}
2928760c2415Smrg       if (dt->round)
2929760c2415Smrg 	{
2930760c2415Smrg 	  fputs (" ROUND=", dumpfile);
2931760c2415Smrg 	  show_expr (dt->round);
2932760c2415Smrg 	}
2933760c2415Smrg       if (dt->sign)
2934760c2415Smrg 	{
2935760c2415Smrg 	  fputs (" SIGN=", dumpfile);
2936760c2415Smrg 	  show_expr (dt->sign);
2937760c2415Smrg 	}
2938760c2415Smrg 
2939760c2415Smrg     show_dt_code:
2940760c2415Smrg       for (c = c->block->next; c; c = c->next)
2941760c2415Smrg 	show_code_node (level + (c->next != NULL), c);
2942760c2415Smrg       return;
2943760c2415Smrg 
2944760c2415Smrg     case EXEC_TRANSFER:
2945760c2415Smrg       fputs ("TRANSFER ", dumpfile);
2946760c2415Smrg       show_expr (c->expr1);
2947760c2415Smrg       break;
2948760c2415Smrg 
2949760c2415Smrg     case EXEC_DT_END:
2950760c2415Smrg       fputs ("DT_END", dumpfile);
2951760c2415Smrg       dt = c->ext.dt;
2952760c2415Smrg 
2953760c2415Smrg       if (dt->err != NULL)
2954760c2415Smrg 	fprintf (dumpfile, " ERR=%d", dt->err->value);
2955760c2415Smrg       if (dt->end != NULL)
2956760c2415Smrg 	fprintf (dumpfile, " END=%d", dt->end->value);
2957760c2415Smrg       if (dt->eor != NULL)
2958760c2415Smrg 	fprintf (dumpfile, " EOR=%d", dt->eor->value);
2959760c2415Smrg       break;
2960760c2415Smrg 
2961760c2415Smrg     case EXEC_WAIT:
2962760c2415Smrg       fputs ("WAIT", dumpfile);
2963760c2415Smrg 
2964760c2415Smrg       if (c->ext.wait != NULL)
2965760c2415Smrg 	{
2966760c2415Smrg 	  gfc_wait *wait = c->ext.wait;
2967760c2415Smrg 	  if (wait->unit)
2968760c2415Smrg 	    {
2969760c2415Smrg 	      fputs (" UNIT=", dumpfile);
2970760c2415Smrg 	      show_expr (wait->unit);
2971760c2415Smrg 	    }
2972760c2415Smrg 	  if (wait->iostat)
2973760c2415Smrg 	    {
2974760c2415Smrg 	      fputs (" IOSTAT=", dumpfile);
2975760c2415Smrg 	      show_expr (wait->iostat);
2976760c2415Smrg 	    }
2977760c2415Smrg 	  if (wait->iomsg)
2978760c2415Smrg 	    {
2979760c2415Smrg 	      fputs (" IOMSG=", dumpfile);
2980760c2415Smrg 	      show_expr (wait->iomsg);
2981760c2415Smrg 	    }
2982760c2415Smrg 	  if (wait->id)
2983760c2415Smrg 	    {
2984760c2415Smrg 	      fputs (" ID=", dumpfile);
2985760c2415Smrg 	      show_expr (wait->id);
2986760c2415Smrg 	    }
2987760c2415Smrg 	  if (wait->err)
2988760c2415Smrg 	    fprintf (dumpfile, " ERR=%d", wait->err->value);
2989760c2415Smrg 	  if (wait->end)
2990760c2415Smrg 	    fprintf (dumpfile, " END=%d", wait->end->value);
2991760c2415Smrg 	  if (wait->eor)
2992760c2415Smrg 	    fprintf (dumpfile, " EOR=%d", wait->eor->value);
2993760c2415Smrg 	}
2994760c2415Smrg       break;
2995760c2415Smrg 
2996760c2415Smrg     case EXEC_OACC_PARALLEL_LOOP:
2997760c2415Smrg     case EXEC_OACC_PARALLEL:
2998760c2415Smrg     case EXEC_OACC_KERNELS_LOOP:
2999760c2415Smrg     case EXEC_OACC_KERNELS:
3000*0bfacb9bSmrg     case EXEC_OACC_SERIAL_LOOP:
3001*0bfacb9bSmrg     case EXEC_OACC_SERIAL:
3002760c2415Smrg     case EXEC_OACC_DATA:
3003760c2415Smrg     case EXEC_OACC_HOST_DATA:
3004760c2415Smrg     case EXEC_OACC_LOOP:
3005760c2415Smrg     case EXEC_OACC_UPDATE:
3006760c2415Smrg     case EXEC_OACC_WAIT:
3007760c2415Smrg     case EXEC_OACC_CACHE:
3008760c2415Smrg     case EXEC_OACC_ENTER_DATA:
3009760c2415Smrg     case EXEC_OACC_EXIT_DATA:
3010760c2415Smrg     case EXEC_OMP_ATOMIC:
3011760c2415Smrg     case EXEC_OMP_CANCEL:
3012760c2415Smrg     case EXEC_OMP_CANCELLATION_POINT:
3013760c2415Smrg     case EXEC_OMP_BARRIER:
3014760c2415Smrg     case EXEC_OMP_CRITICAL:
3015760c2415Smrg     case EXEC_OMP_DISTRIBUTE:
3016760c2415Smrg     case EXEC_OMP_DISTRIBUTE_PARALLEL_DO:
3017760c2415Smrg     case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
3018760c2415Smrg     case EXEC_OMP_DISTRIBUTE_SIMD:
3019760c2415Smrg     case EXEC_OMP_DO:
3020760c2415Smrg     case EXEC_OMP_DO_SIMD:
3021760c2415Smrg     case EXEC_OMP_FLUSH:
3022760c2415Smrg     case EXEC_OMP_MASTER:
3023760c2415Smrg     case EXEC_OMP_ORDERED:
3024760c2415Smrg     case EXEC_OMP_PARALLEL:
3025760c2415Smrg     case EXEC_OMP_PARALLEL_DO:
3026760c2415Smrg     case EXEC_OMP_PARALLEL_DO_SIMD:
3027760c2415Smrg     case EXEC_OMP_PARALLEL_SECTIONS:
3028760c2415Smrg     case EXEC_OMP_PARALLEL_WORKSHARE:
3029760c2415Smrg     case EXEC_OMP_SECTIONS:
3030760c2415Smrg     case EXEC_OMP_SIMD:
3031760c2415Smrg     case EXEC_OMP_SINGLE:
3032760c2415Smrg     case EXEC_OMP_TARGET:
3033760c2415Smrg     case EXEC_OMP_TARGET_DATA:
3034760c2415Smrg     case EXEC_OMP_TARGET_ENTER_DATA:
3035760c2415Smrg     case EXEC_OMP_TARGET_EXIT_DATA:
3036760c2415Smrg     case EXEC_OMP_TARGET_PARALLEL:
3037760c2415Smrg     case EXEC_OMP_TARGET_PARALLEL_DO:
3038760c2415Smrg     case EXEC_OMP_TARGET_PARALLEL_DO_SIMD:
3039760c2415Smrg     case EXEC_OMP_TARGET_SIMD:
3040760c2415Smrg     case EXEC_OMP_TARGET_TEAMS:
3041760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE:
3042760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
3043760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
3044760c2415Smrg     case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
3045760c2415Smrg     case EXEC_OMP_TARGET_UPDATE:
3046760c2415Smrg     case EXEC_OMP_TASK:
3047760c2415Smrg     case EXEC_OMP_TASKGROUP:
3048760c2415Smrg     case EXEC_OMP_TASKLOOP:
3049760c2415Smrg     case EXEC_OMP_TASKLOOP_SIMD:
3050760c2415Smrg     case EXEC_OMP_TASKWAIT:
3051760c2415Smrg     case EXEC_OMP_TASKYIELD:
3052760c2415Smrg     case EXEC_OMP_TEAMS:
3053760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE:
3054760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
3055760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
3056760c2415Smrg     case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD:
3057760c2415Smrg     case EXEC_OMP_WORKSHARE:
3058760c2415Smrg       show_omp_node (level, c);
3059760c2415Smrg       break;
3060760c2415Smrg 
3061760c2415Smrg     default:
3062760c2415Smrg       gfc_internal_error ("show_code_node(): Bad statement code");
3063760c2415Smrg     }
3064760c2415Smrg }
3065760c2415Smrg 
3066760c2415Smrg 
3067760c2415Smrg /* Show an equivalence chain.  */
3068760c2415Smrg 
3069760c2415Smrg static void
show_equiv(gfc_equiv * eq)3070760c2415Smrg show_equiv (gfc_equiv *eq)
3071760c2415Smrg {
3072760c2415Smrg   show_indent ();
3073760c2415Smrg   fputs ("Equivalence: ", dumpfile);
3074760c2415Smrg   while (eq)
3075760c2415Smrg     {
3076760c2415Smrg       show_expr (eq->expr);
3077760c2415Smrg       eq = eq->eq;
3078760c2415Smrg       if (eq)
3079760c2415Smrg 	fputs (", ", dumpfile);
3080760c2415Smrg     }
3081760c2415Smrg }
3082760c2415Smrg 
3083760c2415Smrg 
3084760c2415Smrg /* Show a freakin' whole namespace.  */
3085760c2415Smrg 
3086760c2415Smrg static void
show_namespace(gfc_namespace * ns)3087760c2415Smrg show_namespace (gfc_namespace *ns)
3088760c2415Smrg {
3089760c2415Smrg   gfc_interface *intr;
3090760c2415Smrg   gfc_namespace *save;
3091760c2415Smrg   int op;
3092760c2415Smrg   gfc_equiv *eq;
3093760c2415Smrg   int i;
3094760c2415Smrg 
3095760c2415Smrg   gcc_assert (ns);
3096760c2415Smrg   save = gfc_current_ns;
3097760c2415Smrg 
3098760c2415Smrg   show_indent ();
3099760c2415Smrg   fputs ("Namespace:", dumpfile);
3100760c2415Smrg 
3101760c2415Smrg   i = 0;
3102760c2415Smrg   do
3103760c2415Smrg     {
3104760c2415Smrg       int l = i;
3105760c2415Smrg       while (i < GFC_LETTERS - 1
3106760c2415Smrg 	     && gfc_compare_types (&ns->default_type[i+1],
3107760c2415Smrg 				   &ns->default_type[l]))
3108760c2415Smrg 	i++;
3109760c2415Smrg 
3110760c2415Smrg       if (i > l)
3111760c2415Smrg 	fprintf (dumpfile, " %c-%c: ", l+'A', i+'A');
3112760c2415Smrg       else
3113760c2415Smrg 	fprintf (dumpfile, " %c: ", l+'A');
3114760c2415Smrg 
3115760c2415Smrg       show_typespec(&ns->default_type[l]);
3116760c2415Smrg       i++;
3117760c2415Smrg     } while (i < GFC_LETTERS);
3118760c2415Smrg 
3119760c2415Smrg   if (ns->proc_name != NULL)
3120760c2415Smrg     {
3121760c2415Smrg       show_indent ();
3122760c2415Smrg       fprintf (dumpfile, "procedure name = %s", ns->proc_name->name);
3123760c2415Smrg     }
3124760c2415Smrg 
3125760c2415Smrg   ++show_level;
3126760c2415Smrg   gfc_current_ns = ns;
3127760c2415Smrg   gfc_traverse_symtree (ns->common_root, show_common);
3128760c2415Smrg 
3129760c2415Smrg   gfc_traverse_symtree (ns->sym_root, show_symtree);
3130760c2415Smrg 
3131760c2415Smrg   for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; op++)
3132760c2415Smrg     {
3133760c2415Smrg       /* User operator interfaces */
3134760c2415Smrg       intr = ns->op[op];
3135760c2415Smrg       if (intr == NULL)
3136760c2415Smrg 	continue;
3137760c2415Smrg 
3138760c2415Smrg       show_indent ();
3139760c2415Smrg       fprintf (dumpfile, "Operator interfaces for %s:",
3140760c2415Smrg 	       gfc_op2string ((gfc_intrinsic_op) op));
3141760c2415Smrg 
3142760c2415Smrg       for (; intr; intr = intr->next)
3143760c2415Smrg 	fprintf (dumpfile, " %s", intr->sym->name);
3144760c2415Smrg     }
3145760c2415Smrg 
3146760c2415Smrg   if (ns->uop_root != NULL)
3147760c2415Smrg     {
3148760c2415Smrg       show_indent ();
3149760c2415Smrg       fputs ("User operators:\n", dumpfile);
3150760c2415Smrg       gfc_traverse_user_op (ns, show_uop);
3151760c2415Smrg     }
3152760c2415Smrg 
3153760c2415Smrg   for (eq = ns->equiv; eq; eq = eq->next)
3154760c2415Smrg     show_equiv (eq);
3155760c2415Smrg 
3156760c2415Smrg   if (ns->oacc_declare)
3157760c2415Smrg     {
3158760c2415Smrg       struct gfc_oacc_declare *decl;
3159760c2415Smrg       /* Dump !$ACC DECLARE clauses.  */
3160760c2415Smrg       for (decl = ns->oacc_declare; decl; decl = decl->next)
3161760c2415Smrg 	{
3162760c2415Smrg 	  show_indent ();
3163760c2415Smrg 	  fprintf (dumpfile, "!$ACC DECLARE");
3164760c2415Smrg 	  show_omp_clauses (decl->clauses);
3165760c2415Smrg 	}
3166760c2415Smrg     }
3167760c2415Smrg 
3168760c2415Smrg   fputc ('\n', dumpfile);
3169760c2415Smrg   show_indent ();
3170760c2415Smrg   fputs ("code:", dumpfile);
3171760c2415Smrg   show_code (show_level, ns->code);
3172760c2415Smrg   --show_level;
3173760c2415Smrg 
3174760c2415Smrg   for (ns = ns->contained; ns; ns = ns->sibling)
3175760c2415Smrg     {
3176760c2415Smrg       fputs ("\nCONTAINS\n", dumpfile);
3177760c2415Smrg       ++show_level;
3178760c2415Smrg       show_namespace (ns);
3179760c2415Smrg       --show_level;
3180760c2415Smrg     }
3181760c2415Smrg 
3182760c2415Smrg   fputc ('\n', dumpfile);
3183760c2415Smrg   gfc_current_ns = save;
3184760c2415Smrg }
3185760c2415Smrg 
3186760c2415Smrg 
3187760c2415Smrg /* Main function for dumping a parse tree.  */
3188760c2415Smrg 
3189760c2415Smrg void
gfc_dump_parse_tree(gfc_namespace * ns,FILE * file)3190760c2415Smrg gfc_dump_parse_tree (gfc_namespace *ns, FILE *file)
3191760c2415Smrg {
3192760c2415Smrg   dumpfile = file;
3193760c2415Smrg   show_namespace (ns);
3194760c2415Smrg }
3195760c2415Smrg 
3196760c2415Smrg /* This part writes BIND(C) definition for use in external C programs.  */
3197760c2415Smrg 
3198760c2415Smrg static void write_interop_decl (gfc_symbol *);
3199760c2415Smrg static void write_proc (gfc_symbol *, bool);
3200760c2415Smrg 
3201760c2415Smrg void
gfc_dump_c_prototypes(gfc_namespace * ns,FILE * file)3202760c2415Smrg gfc_dump_c_prototypes (gfc_namespace *ns, FILE *file)
3203760c2415Smrg {
3204760c2415Smrg   int error_count;
3205760c2415Smrg   gfc_get_errors (NULL, &error_count);
3206760c2415Smrg   if (error_count != 0)
3207760c2415Smrg     return;
3208760c2415Smrg   dumpfile = file;
3209760c2415Smrg   gfc_traverse_ns (ns, write_interop_decl);
3210760c2415Smrg }
3211760c2415Smrg 
3212760c2415Smrg /* Loop over all global symbols, writing out their declrations.  */
3213760c2415Smrg 
3214760c2415Smrg void
gfc_dump_external_c_prototypes(FILE * file)3215760c2415Smrg gfc_dump_external_c_prototypes (FILE * file)
3216760c2415Smrg {
3217760c2415Smrg   dumpfile = file;
3218760c2415Smrg   fprintf (dumpfile,
3219760c2415Smrg 	   _("/* Prototypes for external procedures generated from %s\n"
3220760c2415Smrg 	     "   by GNU Fortran %s%s.\n\n"
3221760c2415Smrg 	     "   Use of this interface is discouraged, consider using the\n"
3222760c2415Smrg 	     "   BIND(C) feature of standard Fortran instead.  */\n\n"),
3223760c2415Smrg 	   gfc_source_file, pkgversion_string, version_string);
3224760c2415Smrg 
3225760c2415Smrg   for (gfc_current_ns = gfc_global_ns_list; gfc_current_ns;
3226760c2415Smrg        gfc_current_ns = gfc_current_ns->sibling)
3227760c2415Smrg     {
3228760c2415Smrg       gfc_symbol *sym = gfc_current_ns->proc_name;
3229760c2415Smrg 
3230760c2415Smrg       if (sym == NULL || sym->attr.flavor != FL_PROCEDURE
3231760c2415Smrg 	  || sym->attr.is_bind_c)
3232760c2415Smrg 	continue;
3233760c2415Smrg 
3234760c2415Smrg       write_proc (sym, false);
3235760c2415Smrg     }
3236760c2415Smrg   return;
3237760c2415Smrg }
3238760c2415Smrg 
3239760c2415Smrg enum type_return { T_OK=0, T_WARN, T_ERROR };
3240760c2415Smrg 
3241760c2415Smrg /* Return the name of the type for later output.  Both function pointers and
3242760c2415Smrg    void pointers will be mapped to void *.  */
3243760c2415Smrg 
3244760c2415Smrg static enum type_return
get_c_type_name(gfc_typespec * ts,gfc_array_spec * as,const char ** pre,const char ** type_name,bool * asterisk,const char ** post,bool func_ret)3245760c2415Smrg get_c_type_name (gfc_typespec *ts, gfc_array_spec *as, const char **pre,
3246760c2415Smrg 		 const char **type_name, bool *asterisk, const char **post,
3247760c2415Smrg 		 bool func_ret)
3248760c2415Smrg {
3249760c2415Smrg   static char post_buffer[40];
3250760c2415Smrg   enum type_return ret;
3251760c2415Smrg   ret = T_ERROR;
3252760c2415Smrg 
3253760c2415Smrg   *pre = " ";
3254760c2415Smrg   *asterisk = false;
3255760c2415Smrg   *post = "";
3256760c2415Smrg   *type_name = "<error>";
3257760c2415Smrg   if (ts->type == BT_REAL || ts->type == BT_INTEGER || ts->type == BT_COMPLEX)
3258760c2415Smrg     {
3259760c2415Smrg       if (ts->is_c_interop && ts->interop_kind)
3260760c2415Smrg 	ret = T_OK;
3261760c2415Smrg       else
3262*0bfacb9bSmrg 	ret = T_WARN;
3263*0bfacb9bSmrg 
3264760c2415Smrg       for (int i = 0; i < ISOCBINDING_NUMBER; i++)
3265760c2415Smrg 	{
3266760c2415Smrg 	  if (c_interop_kinds_table[i].f90_type == ts->type
3267760c2415Smrg 	      && c_interop_kinds_table[i].value == ts->kind)
3268760c2415Smrg 	    {
3269760c2415Smrg 	      *type_name = c_interop_kinds_table[i].name + 2;
3270760c2415Smrg 	      if (strcmp (*type_name, "signed_char") == 0)
3271760c2415Smrg 		*type_name = "signed char";
3272760c2415Smrg 	      else if (strcmp (*type_name, "size_t") == 0)
3273760c2415Smrg 		*type_name = "ssize_t";
3274760c2415Smrg 	      else if (strcmp (*type_name, "float_complex") == 0)
3275760c2415Smrg 		*type_name = "__GFORTRAN_FLOAT_COMPLEX";
3276760c2415Smrg 	      else if (strcmp (*type_name, "double_complex") == 0)
3277760c2415Smrg 		*type_name = "__GFORTRAN_DOUBLE_COMPLEX";
3278760c2415Smrg 	      else if (strcmp (*type_name, "long_double_complex") == 0)
3279760c2415Smrg 		*type_name = "__GFORTRAN_LONG_DOUBLE_COMPLEX";
3280760c2415Smrg 
3281760c2415Smrg 	      break;
3282760c2415Smrg 	    }
3283760c2415Smrg 	}
3284760c2415Smrg     }
3285760c2415Smrg   else if (ts->type == BT_LOGICAL)
3286760c2415Smrg     {
3287760c2415Smrg       if (ts->is_c_interop && ts->interop_kind)
3288760c2415Smrg 	{
3289760c2415Smrg 	  *type_name = "_Bool";
3290760c2415Smrg 	  ret = T_OK;
3291760c2415Smrg 	}
3292760c2415Smrg       else
3293760c2415Smrg 	{
3294760c2415Smrg 	  /* Let's select an appropriate int, with a warning. */
3295760c2415Smrg 	  for (int i = 0; i < ISOCBINDING_NUMBER; i++)
3296760c2415Smrg 	    {
3297760c2415Smrg 	      if (c_interop_kinds_table[i].f90_type == BT_INTEGER
3298760c2415Smrg 		  && c_interop_kinds_table[i].value == ts->kind)
3299760c2415Smrg 		{
3300760c2415Smrg 		  *type_name = c_interop_kinds_table[i].name + 2;
3301760c2415Smrg 		  ret = T_WARN;
3302760c2415Smrg 		}
3303760c2415Smrg 	    }
3304760c2415Smrg 	}
3305760c2415Smrg     }
3306760c2415Smrg   else if (ts->type == BT_CHARACTER)
3307760c2415Smrg     {
3308760c2415Smrg       if (ts->is_c_interop)
3309760c2415Smrg 	{
3310760c2415Smrg 	  *type_name = "char";
3311760c2415Smrg 	  ret = T_OK;
3312760c2415Smrg 	}
3313760c2415Smrg       else
3314760c2415Smrg 	{
3315760c2415Smrg 	  if (ts->kind == gfc_default_character_kind)
3316760c2415Smrg 	    *type_name = "char";
3317760c2415Smrg 	  else
3318760c2415Smrg 	    /* Let's select an appropriate int. */
3319760c2415Smrg 	    for (int i = 0; i < ISOCBINDING_NUMBER; i++)
3320760c2415Smrg 	      {
3321760c2415Smrg 		if (c_interop_kinds_table[i].f90_type == BT_INTEGER
3322760c2415Smrg 		    && c_interop_kinds_table[i].value == ts->kind)
3323760c2415Smrg 		  {
3324760c2415Smrg 		    *type_name = c_interop_kinds_table[i].name + 2;
3325760c2415Smrg 		    break;
3326760c2415Smrg 		  }
3327760c2415Smrg 	    }
3328760c2415Smrg 	  ret = T_WARN;
3329760c2415Smrg 
3330760c2415Smrg 	}
3331760c2415Smrg     }
3332760c2415Smrg   else if (ts->type == BT_DERIVED)
3333760c2415Smrg     {
3334760c2415Smrg       if (ts->u.derived->from_intmod == INTMOD_ISO_C_BINDING)
3335760c2415Smrg 	{
3336760c2415Smrg 	  if (strcmp (ts->u.derived->name, "c_ptr") == 0)
3337760c2415Smrg 	    *type_name = "void";
3338760c2415Smrg 	  else if (strcmp (ts->u.derived->name, "c_funptr") == 0)
3339760c2415Smrg 	    {
3340760c2415Smrg 	      *type_name = "int ";
3341760c2415Smrg 	      if (func_ret)
3342760c2415Smrg 		{
3343760c2415Smrg 		  *pre = "(";
3344760c2415Smrg 		  *post = "())";
3345760c2415Smrg 		}
3346760c2415Smrg 	      else
3347760c2415Smrg 		{
3348760c2415Smrg 		  *pre = "(";
3349760c2415Smrg 		  *post = ")()";
3350760c2415Smrg 		}
3351760c2415Smrg 	    }
3352760c2415Smrg 	  *asterisk = true;
3353760c2415Smrg 	  ret = T_OK;
3354760c2415Smrg 	}
3355760c2415Smrg       else
3356760c2415Smrg 	*type_name = ts->u.derived->name;
3357760c2415Smrg 
3358760c2415Smrg       ret = T_OK;
3359760c2415Smrg     }
3360760c2415Smrg 
3361760c2415Smrg   if (ret != T_ERROR && as)
3362760c2415Smrg     {
3363760c2415Smrg       mpz_t sz;
3364760c2415Smrg       bool size_ok;
3365760c2415Smrg       size_ok = spec_size (as, &sz);
3366760c2415Smrg       gcc_assert (size_ok == true);
3367760c2415Smrg       gmp_snprintf (post_buffer, sizeof(post_buffer), "[%Zd]", sz);
3368760c2415Smrg       *post = post_buffer;
3369760c2415Smrg       mpz_clear (sz);
3370760c2415Smrg     }
3371760c2415Smrg   return ret;
3372760c2415Smrg }
3373760c2415Smrg 
3374760c2415Smrg /* Write out a declaration.  */
3375760c2415Smrg static void
write_decl(gfc_typespec * ts,gfc_array_spec * as,const char * sym_name,bool func_ret,locus * where,bool bind_c)3376760c2415Smrg write_decl (gfc_typespec *ts, gfc_array_spec *as, const char *sym_name,
3377760c2415Smrg 	    bool func_ret, locus *where, bool bind_c)
3378760c2415Smrg {
3379760c2415Smrg   const char *pre, *type_name, *post;
3380760c2415Smrg   bool asterisk;
3381760c2415Smrg   enum type_return rok;
3382760c2415Smrg 
3383760c2415Smrg   rok = get_c_type_name (ts, as, &pre, &type_name, &asterisk, &post, func_ret);
3384760c2415Smrg   if (rok == T_ERROR)
3385760c2415Smrg     {
3386760c2415Smrg       gfc_error_now ("Cannot convert %qs to interoperable type at %L",
3387760c2415Smrg 		     gfc_typename (ts), where);
3388760c2415Smrg       fprintf (dumpfile, "/* Cannot convert '%s' to interoperable type */",
3389760c2415Smrg 	       gfc_typename (ts));
3390760c2415Smrg       return;
3391760c2415Smrg     }
3392760c2415Smrg   fputs (type_name, dumpfile);
3393760c2415Smrg   fputs (pre, dumpfile);
3394760c2415Smrg   if (asterisk)
3395760c2415Smrg     fputs ("*", dumpfile);
3396760c2415Smrg 
3397760c2415Smrg   fputs (sym_name, dumpfile);
3398760c2415Smrg   fputs (post, dumpfile);
3399760c2415Smrg 
3400760c2415Smrg   if (rok == T_WARN && bind_c)
3401760c2415Smrg     fprintf (dumpfile," /* WARNING: Converting '%s' to interoperable type */",
3402760c2415Smrg 	     gfc_typename (ts));
3403760c2415Smrg }
3404760c2415Smrg 
3405760c2415Smrg /* Write out an interoperable type.  It will be written as a typedef
3406760c2415Smrg    for a struct.  */
3407760c2415Smrg 
3408760c2415Smrg static void
write_type(gfc_symbol * sym)3409760c2415Smrg write_type (gfc_symbol *sym)
3410760c2415Smrg {
3411760c2415Smrg   gfc_component *c;
3412760c2415Smrg 
3413760c2415Smrg   fprintf (dumpfile, "typedef struct %s {\n", sym->name);
3414760c2415Smrg   for (c = sym->components; c; c = c->next)
3415760c2415Smrg     {
3416760c2415Smrg       fputs ("    ", dumpfile);
3417760c2415Smrg       write_decl (&(c->ts), c->as, c->name, false, &sym->declared_at, true);
3418760c2415Smrg       fputs (";\n", dumpfile);
3419760c2415Smrg     }
3420760c2415Smrg 
3421760c2415Smrg   fprintf (dumpfile, "} %s;\n", sym->name);
3422760c2415Smrg }
3423760c2415Smrg 
3424760c2415Smrg /* Write out a variable.  */
3425760c2415Smrg 
3426760c2415Smrg static void
write_variable(gfc_symbol * sym)3427760c2415Smrg write_variable (gfc_symbol *sym)
3428760c2415Smrg {
3429760c2415Smrg   const char *sym_name;
3430760c2415Smrg 
3431760c2415Smrg   gcc_assert (sym->attr.flavor == FL_VARIABLE);
3432760c2415Smrg 
3433760c2415Smrg   if (sym->binding_label)
3434760c2415Smrg     sym_name = sym->binding_label;
3435760c2415Smrg   else
3436760c2415Smrg     sym_name = sym->name;
3437760c2415Smrg 
3438760c2415Smrg   fputs ("extern ", dumpfile);
3439760c2415Smrg   write_decl (&(sym->ts), sym->as, sym_name, false, &sym->declared_at, true);
3440760c2415Smrg   fputs (";\n", dumpfile);
3441760c2415Smrg }
3442760c2415Smrg 
3443760c2415Smrg 
3444760c2415Smrg /* Write out a procedure, including its arguments.  */
3445760c2415Smrg static void
write_proc(gfc_symbol * sym,bool bind_c)3446760c2415Smrg write_proc (gfc_symbol *sym, bool bind_c)
3447760c2415Smrg {
3448760c2415Smrg   const char *pre, *type_name, *post;
3449760c2415Smrg   bool asterisk;
3450760c2415Smrg   enum type_return rok;
3451760c2415Smrg   gfc_formal_arglist *f;
3452760c2415Smrg   const char *sym_name;
3453760c2415Smrg   const char *intent_in;
3454760c2415Smrg   bool external_character;
3455760c2415Smrg 
3456760c2415Smrg   external_character =  sym->ts.type == BT_CHARACTER && !bind_c;
3457760c2415Smrg 
3458760c2415Smrg   if (sym->binding_label)
3459760c2415Smrg     sym_name = sym->binding_label;
3460760c2415Smrg   else
3461760c2415Smrg     sym_name = sym->name;
3462760c2415Smrg 
3463760c2415Smrg   if (sym->ts.type == BT_UNKNOWN || external_character)
3464760c2415Smrg     {
3465760c2415Smrg       fprintf (dumpfile, "void ");
3466760c2415Smrg       fputs (sym_name, dumpfile);
3467760c2415Smrg     }
3468760c2415Smrg   else
3469760c2415Smrg     write_decl (&(sym->ts), sym->as, sym_name, true, &sym->declared_at, bind_c);
3470760c2415Smrg 
3471760c2415Smrg   if (!bind_c)
3472760c2415Smrg     fputs ("_", dumpfile);
3473760c2415Smrg 
3474760c2415Smrg   fputs (" (", dumpfile);
3475760c2415Smrg   if (external_character)
3476760c2415Smrg     {
3477760c2415Smrg       fprintf (dumpfile, "char *result_%s, size_t result_%s_len",
3478760c2415Smrg 	       sym_name, sym_name);
3479760c2415Smrg       if (sym->formal)
3480760c2415Smrg 	fputs (", ", dumpfile);
3481760c2415Smrg     }
3482760c2415Smrg 
3483760c2415Smrg   for (f = sym->formal; f; f = f->next)
3484760c2415Smrg     {
3485760c2415Smrg       gfc_symbol *s;
3486760c2415Smrg       s = f->sym;
3487760c2415Smrg       rok = get_c_type_name (&(s->ts), NULL, &pre, &type_name, &asterisk,
3488760c2415Smrg 			     &post, false);
3489760c2415Smrg       if (rok == T_ERROR)
3490760c2415Smrg 	{
3491760c2415Smrg 	  gfc_error_now ("Cannot convert %qs to interoperable type at %L",
3492760c2415Smrg 			 gfc_typename (&s->ts), &s->declared_at);
3493760c2415Smrg 	  fprintf (dumpfile, "/* Cannot convert '%s' to interoperable type */",
3494760c2415Smrg 		   gfc_typename (&s->ts));
3495760c2415Smrg 	  return;
3496760c2415Smrg 	}
3497760c2415Smrg 
3498760c2415Smrg       if (!s->attr.value)
3499760c2415Smrg 	asterisk = true;
3500760c2415Smrg 
3501760c2415Smrg       if (s->attr.intent == INTENT_IN && !s->attr.value)
3502760c2415Smrg 	intent_in = "const ";
3503760c2415Smrg       else
3504760c2415Smrg 	intent_in = "";
3505760c2415Smrg 
3506760c2415Smrg       fputs (intent_in, dumpfile);
3507760c2415Smrg       fputs (type_name, dumpfile);
3508760c2415Smrg       fputs (pre, dumpfile);
3509760c2415Smrg       if (asterisk)
3510760c2415Smrg 	fputs ("*", dumpfile);
3511760c2415Smrg 
3512760c2415Smrg       fputs (s->name, dumpfile);
3513760c2415Smrg       fputs (post, dumpfile);
3514760c2415Smrg       if (bind_c && rok == T_WARN)
3515760c2415Smrg 	fputs(" /* WARNING: non-interoperable KIND */ ", dumpfile);
3516760c2415Smrg 
3517760c2415Smrg       if (f->next)
3518760c2415Smrg 	fputs(", ", dumpfile);
3519760c2415Smrg     }
3520760c2415Smrg   if (!bind_c)
3521760c2415Smrg     for (f = sym->formal; f; f = f->next)
3522760c2415Smrg       if (f->sym->ts.type == BT_CHARACTER)
3523760c2415Smrg 	fprintf (dumpfile, ", size_t %s_len", f->sym->name);
3524760c2415Smrg 
3525760c2415Smrg   fputs (");\n", dumpfile);
3526760c2415Smrg }
3527760c2415Smrg 
3528760c2415Smrg 
3529760c2415Smrg /* Write a C-interoperable declaration as a C prototype or extern
3530760c2415Smrg    declaration.  */
3531760c2415Smrg 
3532760c2415Smrg static void
write_interop_decl(gfc_symbol * sym)3533760c2415Smrg write_interop_decl (gfc_symbol *sym)
3534760c2415Smrg {
3535760c2415Smrg   /* Only dump bind(c) entities.  */
3536760c2415Smrg   if (!sym->attr.is_bind_c)
3537760c2415Smrg     return;
3538760c2415Smrg 
3539760c2415Smrg   /* Don't dump our iso c module.  */
3540760c2415Smrg   if (sym->from_intmod == INTMOD_ISO_C_BINDING)
3541760c2415Smrg     return;
3542760c2415Smrg 
3543760c2415Smrg   if (sym->attr.flavor == FL_VARIABLE)
3544760c2415Smrg     write_variable (sym);
3545760c2415Smrg   else if (sym->attr.flavor == FL_DERIVED)
3546760c2415Smrg     write_type (sym);
3547760c2415Smrg   else if (sym->attr.flavor == FL_PROCEDURE)
3548760c2415Smrg     write_proc (sym, true);
3549760c2415Smrg }
3550760c2415Smrg 
3551760c2415Smrg /* This section deals with dumping the global symbol tree.  */
3552760c2415Smrg 
3553760c2415Smrg /* Callback function for printing out the contents of the tree.  */
3554760c2415Smrg 
3555760c2415Smrg static void
show_global_symbol(gfc_gsymbol * gsym,void * f_data)3556760c2415Smrg show_global_symbol (gfc_gsymbol *gsym, void *f_data)
3557760c2415Smrg {
3558760c2415Smrg   FILE *out;
3559760c2415Smrg   out = (FILE *) f_data;
3560760c2415Smrg 
3561760c2415Smrg   if (gsym->name)
3562760c2415Smrg     fprintf (out, "name=%s", gsym->name);
3563760c2415Smrg 
3564760c2415Smrg   if (gsym->sym_name)
3565760c2415Smrg     fprintf (out, ", sym_name=%s", gsym->sym_name);
3566760c2415Smrg 
3567760c2415Smrg   if (gsym->mod_name)
3568760c2415Smrg     fprintf (out, ", mod_name=%s", gsym->mod_name);
3569760c2415Smrg 
3570760c2415Smrg   if (gsym->binding_label)
3571760c2415Smrg     fprintf (out, ", binding_label=%s", gsym->binding_label);
3572760c2415Smrg 
3573760c2415Smrg   fputc ('\n', out);
3574760c2415Smrg }
3575760c2415Smrg 
3576760c2415Smrg /* Show all global symbols.  */
3577760c2415Smrg 
3578760c2415Smrg void
gfc_dump_global_symbols(FILE * f)3579760c2415Smrg gfc_dump_global_symbols (FILE *f)
3580760c2415Smrg {
3581760c2415Smrg   gfc_traverse_gsymbol (gfc_gsym_root, show_global_symbol, (void *) f);
3582760c2415Smrg }
3583