Adapted cparser to CopyB lowering changes.
[cparser] / types.c
diff --git a/types.c b/types.c
index 98fd054..ab6e423 100644 (file)
--- a/types.c
+++ b/types.c
@@ -1,6 +1,6 @@
 /*
  * This file is part of cparser.
- * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
+ * Copyright (C) 2007-2009 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
@@ -44,7 +44,9 @@ type_t *type_unsigned_long;
 type_t *type_void;
 
 type_t *type_char_ptr;
+type_t *type_char_ptr_restrict;
 type_t *type_const_char_ptr;
+type_t *type_const_char_ptr_restrict;
 type_t *type_int_ptr;
 type_t *type_long_long_ptr;
 type_t *type_long_ptr;
@@ -52,6 +54,10 @@ type_t *type_unsigned_long_ptr;
 type_t *type_short_ptr;
 type_t *type_signed_char_ptr;
 type_t *type_void_ptr;
+type_t *type_const_void;
+type_t *type_const_void_ptr;
+type_t *type_void_ptr_restrict;
+type_t *type_const_void_ptr_restrict;
 
 type_t *type_char_ptr_ptr;
 
@@ -98,8 +104,7 @@ type_t *type_int64_ptr;
 
 void init_basic_types(void)
 {
-       static const type_base_t error = { TYPE_ERROR, 0, TYPE_QUALIFIER_NONE,
-                                          TYPE_MODIFIER_NONE, 0, NULL };
+       static const type_base_t error = { TYPE_ERROR, TYPE_QUALIFIER_NONE, NULL };
 
        type_error_type         = (type_t*)&error;
        type_bool               = make_atomic_type(ATOMIC_TYPE_BOOL,        TYPE_QUALIFIER_NONE);
@@ -118,6 +123,7 @@ void init_basic_types(void)
        type_float              = make_atomic_type(ATOMIC_TYPE_FLOAT,       TYPE_QUALIFIER_NONE);
        type_char               = make_atomic_type(ATOMIC_TYPE_CHAR,        TYPE_QUALIFIER_NONE);
        type_void               = make_atomic_type(ATOMIC_TYPE_VOID,        TYPE_QUALIFIER_NONE);
+       type_const_void         = make_atomic_type(ATOMIC_TYPE_VOID,        TYPE_QUALIFIER_CONST);
 
        /* microsoft types */
        if (c_mode & _MS) {
@@ -144,7 +150,12 @@ void init_basic_types(void)
 
        /* pointer types */
        type_void_ptr           = make_pointer_type(type_void,              TYPE_QUALIFIER_NONE);
+       type_const_void_ptr     = make_pointer_type(type_const_void,        TYPE_QUALIFIER_NONE);
+       type_void_ptr_restrict  = make_pointer_type(type_void,              TYPE_QUALIFIER_RESTRICT);
+       type_const_void_ptr_restrict
+                               = make_pointer_type(type_const_void,        TYPE_QUALIFIER_RESTRICT);
        type_char_ptr           = make_pointer_type(type_char,              TYPE_QUALIFIER_NONE);
+       type_char_ptr_restrict  = make_pointer_type(type_char,              TYPE_QUALIFIER_RESTRICT);
        type_signed_char_ptr    = make_pointer_type(type_signed_char,       TYPE_QUALIFIER_NONE);
        type_short_ptr          = make_pointer_type(type_short,             TYPE_QUALIFIER_NONE);
        type_int_ptr            = make_pointer_type(type_int,               TYPE_QUALIFIER_NONE);
@@ -153,10 +164,12 @@ void init_basic_types(void)
        type_long_long_ptr      = make_pointer_type(type_long_long,         TYPE_QUALIFIER_NONE);
 
        type_char_ptr_ptr       = make_pointer_type(type_char_ptr,          TYPE_QUALIFIER_NONE);
+       type_valist             = type_void_ptr;
 
        /* const character types */
        type_const_char         = make_atomic_type(ATOMIC_TYPE_CHAR,        TYPE_QUALIFIER_CONST);
        type_const_char_ptr     = make_pointer_type(type_const_char,        TYPE_QUALIFIER_NONE);
+       type_const_char_ptr_restrict = make_pointer_type(type_const_char,        TYPE_QUALIFIER_RESTRICT);
 
        /* other types */
        type_intmax_t    = type_long_long;
@@ -165,14 +178,19 @@ void init_basic_types(void)
        type_ptrdiff_t   = type_long;
        type_uintmax_t   = type_unsigned_long_long;
        type_uptrdiff_t  = type_unsigned_long;
-       type_wchar_t     = make_atomic_type(wchar_atomic_kind, TYPE_QUALIFIER_NONE);
        type_wint_t      = type_int;
-       type_const_wchar_t
-               = make_atomic_type(wchar_atomic_kind, TYPE_QUALIFIER_CONST);
 
        type_intmax_t_ptr  = make_pointer_type(type_intmax_t,  TYPE_QUALIFIER_NONE);
        type_ptrdiff_t_ptr = make_pointer_type(type_ptrdiff_t, TYPE_QUALIFIER_NONE);
        type_ssize_t_ptr   = make_pointer_type(type_ssize_t,   TYPE_QUALIFIER_NONE);
+}
+
+void init_wchar_types(type_t *base)
+{
+       assert(base->kind == TYPE_ATOMIC);
+       type_wchar_t = base;
+       type_const_wchar_t
+               = make_atomic_type(base->atomic.akind, TYPE_QUALIFIER_CONST);
        type_wchar_t_ptr   = make_pointer_type(type_wchar_t,   TYPE_QUALIFIER_NONE);
        type_const_wchar_t_ptr
                = make_pointer_type(type_const_wchar_t, TYPE_QUALIFIER_NONE);