- more test cases
[cparser] / type.c
diff --git a/type.c b/type.c
index efe7d0e..97f38a8 100644 (file)
--- a/type.c
+++ b/type.c
@@ -1,8 +1,29 @@
+/*
+ * This file is part of cparser.
+ * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
 #include <config.h>
 
 #include <stdio.h>
 #include <assert.h>
+
 #include "type_t.h"
+#include "symbol_t.h"
 #include "type_hash.h"
 #include "adt/error.h"
 
@@ -10,7 +31,7 @@ static struct obstack   _type_obst;
 static FILE            *out;
 struct obstack         *type_obst                 = &_type_obst;
 static int              type_visited              = 0;
-static bool             print_implicit_array_size = true;
+static bool             print_implicit_array_size = false;
 
 static void intern_print_type_pre(const type_t *type, bool top);
 static void intern_print_type_post(const type_t *type, bool top);
@@ -229,7 +250,13 @@ void print_enum_definition(const declaration_t *declaration)
                fprintf(out, "%s", entry->symbol->string);
                if(entry->init.initializer != NULL) {
                        fprintf(out, " = ");
-                       print_expression(entry->init.enum_value);
+
+                       /* skip the implicit cast */
+                       expression_t *expression = entry->init.enum_value;
+                       if(expression->kind == EXPR_UNARY_CAST_IMPLICIT) {
+                               expression = expression->unary.value;
+                       }
+                       print_expression(expression);
                }
                fprintf(out, ",\n");
        }
@@ -934,8 +961,11 @@ type_t *make_atomic_type(atomic_type_kind_t atype, type_qualifiers_t qualifiers)
 
        type->kind            = TYPE_ATOMIC;
        type->base.qualifiers = qualifiers;
+       type->base.alignment  = 0;
        type->atomic.akind    = atype;
 
+       /* TODO: set the aligmnent depending on the atype here */
+
        return identify_new_type(type);
 }
 
@@ -952,6 +982,7 @@ type_t *make_pointer_type(type_t *points_to, type_qualifiers_t qualifiers)
 
        type->kind              = TYPE_POINTER;
        type->base.qualifiers   = qualifiers;
+       type->base.alignment    = 0;
        type->pointer.points_to = points_to;
 
        return identify_new_type(type);
@@ -965,6 +996,7 @@ type_t *make_array_type(type_t *element_type, size_t size,
 
        type->kind                = TYPE_ARRAY;
        type->base.qualifiers     = qualifiers;
+       type->base.alignment      = 0;
        type->array.element_type  = element_type;
        type->array.size          = size;
        type->array.size_constant = true;