diff mbox series

[Fortran,committed] Fix a crash with a developer's option

Message ID 53cafe9a-ad5c-7c92-4307-c7b1e6fb5cb3@netcologne.de
State New
Headers show
Series [Fortran,committed] Fix a crash with a developer's option | expand

Commit Message

Thomas Koenig June 14, 2020, 3:40 p.m. UTC
Committed as obvious, simple and risk-free after checking
that it still compiles.

It does not fix the PR in question, it it just something that
was noted in one of the comments.

Regards

	Thomas

Avoid crash when global symbol table is empty with -fdump-fortran-global.

This just avoids a crash with -fdump-fortran-global when the
global symbol table is empty.  This is strictly a developer's
option, no user impact.

gcc/fortran/ChangeLog:

2020-06-14  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/42122
	* dump-parse-tree.c (gfc_dump_global_symbols):  If the symroot is
	empty, just output "empty".
diff mbox series

Patch

diff --git a/gcc/fortran/dump-parse-tree.c b/gcc/fortran/dump-parse-tree.c
index f32330685e7..f44648879f5 100644
--- a/gcc/fortran/dump-parse-tree.c
+++ b/gcc/fortran/dump-parse-tree.c
@@ -3595,5 +3595,8 @@  show_global_symbol (gfc_gsymbol *gsym, void *f_data)
 void
 gfc_dump_global_symbols (FILE *f)
 {
-  gfc_traverse_gsymbol (gfc_gsym_root, show_global_symbol, (void *) f);
+  if (gfc_gsym_root == NULL)
+    fprintf (f, "empty\n");
+  else
+    gfc_traverse_gsymbol (gfc_gsym_root, show_global_symbol, (void *) f);
 }