From 56e7ead9f9e4e5112bd38bffdbac093fe274992a Mon Sep 17 00:00:00 2001 From: Evgeny Gavrin Date: Wed, 1 Jul 2015 20:52:37 +0300 Subject: [PATCH] Fix build for GCC 4.7. Related issue: #1 JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin e.gavrin@samsung.com --- jerry-core/ecma/base/ecma-helpers-string.cpp | 2 +- jerry-core/lit/lit-strings.cpp | 12 ++++++------ jerry-core/parser/regexp/re-parser.cpp | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/jerry-core/ecma/base/ecma-helpers-string.cpp b/jerry-core/ecma/base/ecma-helpers-string.cpp index 337dc65cc5..8969116c62 100644 --- a/jerry-core/ecma/base/ecma-helpers-string.cpp +++ b/jerry-core/ecma/base/ecma-helpers-string.cpp @@ -1384,7 +1384,7 @@ ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */ else if (container == ECMA_STRING_CONTAINER_UINT32_IN_DESC) { const uint32_t uint32_number = string_p->u.uint32_number; - const int32_t max_uint32_len = 10; + const uint32_t max_uint32_len = 10; const uint32_t nums_with_ascending_length[10] = { 1u, diff --git a/jerry-core/lit/lit-strings.cpp b/jerry-core/lit/lit-strings.cpp index a8191d7770..268957947d 100644 --- a/jerry-core/lit/lit-strings.cpp +++ b/jerry-core/lit/lit-strings.cpp @@ -375,13 +375,13 @@ lit_utf8_string_calc_hash_last_bytes (const lit_utf8_byte_t *utf8_buf_p, /**< ch { JERRY_ASSERT (utf8_buf_p != NULL); - lit_utf8_byte_t byte1 = (utf8_buf_size > 0) ? utf8_buf_p[utf8_buf_size - 1] : 0; - lit_utf8_byte_t byte2 = (utf8_buf_size > 1) ? utf8_buf_p[utf8_buf_size - 2] : 0; + lit_utf8_size_t byte1 = utf8_buf_size > 0 ? utf8_buf_p[utf8_buf_size - 1] : (lit_utf8_size_t) 0; + lit_utf8_size_t byte2 = utf8_buf_size > 1 ? utf8_buf_p[utf8_buf_size - 2] : (lit_utf8_size_t) 0; - uint32_t t1 = (uint32_t) byte1 + (uint32_t) byte2; - uint32_t t2 = t1 * 0x24418b66; - uint32_t t3 = (t2 >> 16) ^ (t2 & 0xffffu); - uint32_t t4 = (t3 >> 8) ^ (t3 & 0xffu); + lit_utf8_size_t t1 = byte1 + byte2; + lit_utf8_size_t t2 = t1 * 0x24418b66; + lit_utf8_size_t t3 = (t2 >> 16) ^ (t2 & 0xffffu); + lit_utf8_size_t t4 = (t3 >> 8) ^ (t3 & 0xffu); return (lit_string_hash_t) t4; } /* lit_utf8_string_calc_hash_last_bytes */ diff --git a/jerry-core/parser/regexp/re-parser.cpp b/jerry-core/parser/regexp/re-parser.cpp index 803812791a..629ce7fe05 100644 --- a/jerry-core/parser/regexp/re-parser.cpp +++ b/jerry-core/parser/regexp/re-parser.cpp @@ -25,7 +25,9 @@ #ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_REGEXP_BUILTIN /* FIXME: change it, when unicode support would be implemented */ -#define RE_LOOKUP(str_p, lookup) (lit_zt_utf8_string_size (str_p) > (lookup) ? str_p[lookup] : '\0') +#define RE_LOOKUP(str_p, lookup) ((lit_zt_utf8_string_size (str_p) > (lookup)) \ + ? (ecma_char_t) str_p[lookup] \ + : (ecma_char_t) '\0') /* FIXME: change it, when unicode support would be implemented */ #define RE_ADVANCE(str_p, advance) do { str_p += advance; } while (0)