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 <ebotca...@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 <ebotca...@adacore.com>
* c-c++-common/dump-ada-spec-7.c: New test.
--
Eric Botcazou
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
/* { dg-do compile } */
/* { dg-options "-fdump-ada-spec" } */
enum E1 {
A1 = -1L,
A2 = 0,
A3 = 1
};
static enum {B1 = -1L, B2, B3} Obj1;
static struct { int i; } Obj2;
/* { dg-final { scan-ada-spec-not "unsigned" } } */
/* { dg-final { cleanup-ada-spec } } */