Add partial support for C++ wchar_t.
authorChristoph Mallon <christoph.mallon@gmx.de>
Sat, 6 Dec 2008 15:44:46 +0000 (15:44 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 6 Dec 2008 15:44:46 +0000 (15:44 +0000)
[r24354]

ast2firm.c
mangle.c
parser.c
type.c
type.h

index 6a22c2d..f8f7f5e 100644 (file)
@@ -2842,6 +2842,7 @@ static ir_node *classify_type_to_firm(const classify_type_expression_t *const ex
                                                tc = void_type_class;
                                                goto make_const;
 
+                                       case ATOMIC_TYPE_WCHAR_T:   /* gcc handles this as integer */
                                        case ATOMIC_TYPE_CHAR:      /* gcc handles this as integer */
                                        case ATOMIC_TYPE_SCHAR:     /* gcc handles this as integer */
                                        case ATOMIC_TYPE_UCHAR:     /* gcc handles this as integer */
index f9ebe76..b7d2bec 100644 (file)
--- a/mangle.c
+++ b/mangle.c
@@ -40,6 +40,7 @@ static char get_atomic_type_mangle(atomic_type_kind_t kind)
        switch (kind) {
        case ATOMIC_TYPE_INVALID: break;
        case ATOMIC_TYPE_VOID:        return 'v';
+       case ATOMIC_TYPE_WCHAR_T:     return 'w';
        case ATOMIC_TYPE_BOOL:        return 'b';
        case ATOMIC_TYPE_CHAR:        return 'c';
        case ATOMIC_TYPE_SCHAR:       return 'a';
index 6a25323..bfb4d3d 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -247,6 +247,7 @@ static void semantic_comparison(binary_expression_t *expression);
        case T_union:             \
        case T_unsigned:          \
        case T_void:              \
+       case T_wchar_t:           \
        COMPLEX_SPECIFIERS        \
        IMAGINARY_SPECIFIERS
 
@@ -3259,18 +3260,19 @@ typedef enum specifiers_t {
        SPECIFIER_INT       = 1 << 3,
        SPECIFIER_DOUBLE    = 1 << 4,
        SPECIFIER_CHAR      = 1 << 5,
-       SPECIFIER_SHORT     = 1 << 6,
-       SPECIFIER_LONG_LONG = 1 << 7,
-       SPECIFIER_FLOAT     = 1 << 8,
-       SPECIFIER_BOOL      = 1 << 9,
-       SPECIFIER_VOID      = 1 << 10,
-       SPECIFIER_INT8      = 1 << 11,
-       SPECIFIER_INT16     = 1 << 12,
-       SPECIFIER_INT32     = 1 << 13,
-       SPECIFIER_INT64     = 1 << 14,
-       SPECIFIER_INT128    = 1 << 15,
-       SPECIFIER_COMPLEX   = 1 << 16,
-       SPECIFIER_IMAGINARY = 1 << 17,
+       SPECIFIER_WCHAR_T   = 1 << 6,
+       SPECIFIER_SHORT     = 1 << 7,
+       SPECIFIER_LONG_LONG = 1 << 8,
+       SPECIFIER_FLOAT     = 1 << 9,
+       SPECIFIER_BOOL      = 1 << 10,
+       SPECIFIER_VOID      = 1 << 11,
+       SPECIFIER_INT8      = 1 << 12,
+       SPECIFIER_INT16     = 1 << 13,
+       SPECIFIER_INT32     = 1 << 14,
+       SPECIFIER_INT64     = 1 << 15,
+       SPECIFIER_INT128    = 1 << 16,
+       SPECIFIER_COMPLEX   = 1 << 17,
+       SPECIFIER_IMAGINARY = 1 << 18,
 } specifiers_t;
 
 static type_t *create_builtin_type(symbol_t *const symbol,
@@ -3729,6 +3731,7 @@ wrong_thread_stoarge_class:
                MATCH_SPECIFIER(T_signed,     SPECIFIER_SIGNED,    "signed");
                MATCH_SPECIFIER(T_unsigned,   SPECIFIER_UNSIGNED,  "unsigned");
                MATCH_SPECIFIER(T_void,       SPECIFIER_VOID,      "void");
+               MATCH_SPECIFIER(T_wchar_t,    SPECIFIER_WCHAR_T,   "wchar_t");
 
                case T__forceinline:
                        /* only in microsoft mode */
@@ -3856,6 +3859,9 @@ finish_specifiers:
                case SPECIFIER_VOID:
                        atomic_type = ATOMIC_TYPE_VOID;
                        break;
+               case SPECIFIER_WCHAR_T:
+                       atomic_type = ATOMIC_TYPE_WCHAR_T;
+                       break;
                case SPECIFIER_CHAR:
                        atomic_type = ATOMIC_TYPE_CHAR;
                        break;
diff --git a/type.c b/type.c
index 98693bf..0646884 100644 (file)
--- a/type.c
+++ b/type.c
@@ -52,6 +52,12 @@ static atomic_type_properties_t atomic_type_properties[ATOMIC_TYPE_LAST+1] = {
                .alignment  = 0,
                .flags      = ATOMIC_TYPE_FLAG_NONE
        },
+       [ATOMIC_TYPE_WCHAR_T] = {
+               .size       = (unsigned)-1,
+               .alignment  = (unsigned)-1,
+               /* signed flag will be set when known */
+               .flags      = ATOMIC_TYPE_FLAG_INTEGER | ATOMIC_TYPE_FLAG_ARITHMETIC,
+       },
        [ATOMIC_TYPE_CHAR] = {
                .size       = 1,
                .alignment  = 1,
@@ -177,6 +183,8 @@ void init_types(void)
        /* TODO: make this configurable for platforms which do not use byte sized
         * bools. */
        props[ATOMIC_TYPE_BOOL] = props[ATOMIC_TYPE_UCHAR];
+
+       props[ATOMIC_TYPE_WCHAR_T] = props[wchar_atomic_kind];
 }
 
 void exit_types(void)
@@ -216,6 +224,7 @@ const char *get_atomic_kind_name(atomic_type_kind_t kind)
        switch(kind) {
        case ATOMIC_TYPE_INVALID: break;
        case ATOMIC_TYPE_VOID:        return "void";
+       case ATOMIC_TYPE_WCHAR_T:     return "wchar_t";
        case ATOMIC_TYPE_BOOL:        return c_mode & _CXX ? "bool" : "_Bool";
        case ATOMIC_TYPE_CHAR:        return "char";
        case ATOMIC_TYPE_SCHAR:       return "signed char";
diff --git a/type.h b/type.h
index fc0e183..751d658 100644 (file)
--- a/type.h
+++ b/type.h
@@ -34,6 +34,7 @@ typedef unsigned char il_alignment_t;
 typedef enum atomic_type_kind_t {
        ATOMIC_TYPE_INVALID = 0,
        ATOMIC_TYPE_VOID,
+       ATOMIC_TYPE_WCHAR_T,
        ATOMIC_TYPE_CHAR,
        ATOMIC_TYPE_SCHAR,
        ATOMIC_TYPE_UCHAR,