Set size and alignment for atomic/complex/imagenary types created from type specifiers.
[cparser] / lexer.c
diff --git a/lexer.c b/lexer.c
index 779f4b3..10e049f 100644 (file)
--- a/lexer.c
+++ b/lexer.c
@@ -43,7 +43,7 @@
 //#define DEBUG_CHARS
 #define MAX_PUTBACK 3
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
 /* No strtold on windows and no replacement yet */
 #define strtold(s, e) strtod(s, e)
 #endif
@@ -96,7 +96,7 @@ static inline void next_real_char(void)
                bufpos = buf + MAX_PUTBACK;
                bufend = buf + MAX_PUTBACK + s;
        }
-       c = *bufpos++;
+       c = (unsigned char)*bufpos++;
 }
 
 /**
@@ -844,11 +844,15 @@ static int parse_escape_sequence(void)
        case EOF:
                parse_error("reached end of file while parsing escape sequence");
                return EOF;
+       /* \E is not documented, but handled, by GCC.  It is acceptable according
+        * to §6.11.4, whereas \e is not. */
+       case 'E':
        case 'e':
                if (c_mode & _GNUC)
-                       return 27;   /* hopefully 27 is ALWAYS the code for ESACAPE */
-               /*fallthrough*/
+                       return 27;   /* hopefully 27 is ALWAYS the code for ESCAPE */
+               /* FALLTHROUGH */
        default:
+               /* §6.4.4.4:8 footnote 64 */
                parse_error("unknown escape sequence");
                return EOF;
        }
@@ -933,9 +937,10 @@ wide_string_t concat_wide_string_string(const wide_string_t *const s1, const str
 
        wchar_rep_t *const concat = obstack_alloc(&symbol_obstack, (len1 + len2 + 1) * sizeof(*concat));
        memcpy(concat, s1->begin, len1 * sizeof(*concat));
-       const char *const src = s2->begin;
+       const char  *const src = s2->begin;
+       wchar_rep_t *const dst = concat + len1;
        for (size_t i = 0; i != len2 + 1; ++i) {
-               concat[i] = src[i];
+               dst[i] = src[i];
        }
        if (warning.traditional) {
                warningf(&lexer_token.source_position,
@@ -1177,7 +1182,7 @@ end_of_char_constant:;
        lexer_token.type           = T_CHARACTER_CONSTANT;
        lexer_token.v.string.begin = string;
        lexer_token.v.string.size  = size;
-       lexer_token.datatype       = type_int;
+       lexer_token.datatype       = c_mode & _CXX && size == 1 ? type_char : type_int;
 }
 
 /**