diff mbox

Fix segfault on anonymous structures with -fdump-ada-spec

Message ID 14868302.GVeWOb1hJN@arcturus.home
State New
Headers show

Commit Message

Eric Botcazou July 29, 2017, 9:54 a.m. UTC
This is a trivial patch to fix a segfault on anonymous structures with the 
special -fdump-ada-spec switch.  It also contains a fixlet for enumeral types.

Bootstrapped/regtested on x86_64-suse-linux, applied on the mainline.


2017-07-29  Eric Botcazou  <ebotcazou@adacore.com>

c-family/
	* c-ada-spec.c (dump_generic_ada_node): Take into account signedness
	for enumeral types.
	(print_ada_declaration): Add missing guard for record types.


2017-07-29  Eric Botcazou  <ebotcazou@adacore.com>

	* c-c++-common/dump-ada-spec-7.c: New test.
diff mbox

Patch

Index: c-family/c-ada-spec.c
===================================================================
--- c-family/c-ada-spec.c	(revision 250609)
+++ c-family/c-ada-spec.c	(working copy)
@@ -2055,7 +2055,10 @@  dump_generic_ada_node (pretty_printer *buffer, tre
 	    }
 	  else
 	    {
-	      pp_string (buffer, "unsigned");
+	      if (TYPE_UNSIGNED (node))
+		pp_string (buffer, "unsigned");
+	      else
+		pp_string (buffer, "int");
 	      for (; value; value = TREE_CHAIN (value))
 		{
 		  pp_semicolon (buffer);
@@ -3097,7 +3100,7 @@  print_ada_declaration (pretty_printer *buffer, tre
 	      if (TYPE_NAME (TREE_TYPE (t)))
 		dump_generic_ada_node
 		  (buffer, TREE_TYPE (t), t, spc, false, true);
-	      else
+	      else if (type)
 		dump_ada_double_name (buffer, type, t);
 	    }
 	  else