do not crash when printing implicit union/struct selects
authorMatthias Braun <matze@braunis.de>
Fri, 12 Aug 2011 18:54:07 +0000 (20:54 +0200)
committerMatthias Braun <matze@braunis.de>
Fri, 12 Aug 2011 18:59:20 +0000 (20:59 +0200)
ast.c

diff --git a/ast.c b/ast.c
index 1aa9254..3ee0201 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -590,6 +590,12 @@ static void print_va_copy(const va_copy_expression_t *expression)
 static void print_select(const select_expression_t *expression)
 {
        print_expression_prec(expression->compound, PREC_POSTFIX);
+       /* do not print anything for anonymous struct/union selects
+        * FIXME: if the anonymous select was a '->' this will print '.'
+        */
+       if (expression->compound_entry->base.symbol == NULL)
+               return;
+
        if (is_type_pointer(skip_typeref(expression->compound->base.type))) {
                print_string("->");
        } else {