From d0dd26a80f3757c59659cd324cd6e5f1059cb95d Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 27 May 2008 12:50:28 +0000 Subject: [PATCH] fix bug with big octal sequences [r19793] --- ast2firm.c | 6 +++++- parsetest/cp_error029.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ast2firm.c b/ast2firm.c index 82914bd..b3b47dd 100644 --- a/ast2firm.c +++ b/ast2firm.c @@ -1038,7 +1038,11 @@ static ir_node *character_constant_to_firm(const const_expression_t *cnst) long long int v = 0; for (size_t i = 0; i < cnst->v.character.size; ++i) { - v = (v << 8) | ((unsigned char)cnst->v.character.begin[i]); + if (char_is_signed) { + v = (v << 8) | ((signed char)cnst->v.character.begin[i]); + } else { + v = (v << 8) | ((unsigned char)cnst->v.character.begin[i]); + } } char buf[128]; size_t len = snprintf(buf, sizeof(buf), "%lld", v); diff --git a/parsetest/cp_error029.c b/parsetest/cp_error029.c index 0c3ead6..a7b6c2b 100644 --- a/parsetest/cp_error029.c +++ b/parsetest/cp_error029.c @@ -1,4 +1,4 @@ -#include +int printf(const char *fmt, ...); int main(void) { -- 2.20.1