From: Christoph Mallon Date: Tue, 31 May 2011 11:41:18 +0000 (+0200) Subject: Report an error on empty character constants, i.e. ''. X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=5834e994bee47cffac93efca7bcc9551c7c3efa6;p=cparser Report an error on empty character constants, i.e. ''. --- diff --git a/lexer.c b/lexer.c index 8e0567e..7ae5256 100644 --- a/lexer.c +++ b/lexer.c @@ -1052,6 +1052,10 @@ end_of_wide_char_constant:; lexer_token.type = T_WIDE_CHARACTER_CONSTANT; lexer_token.literal = identify_string(string, size); + + if (size == 0) { + parse_error("empty character constant"); + } } /** @@ -1118,6 +1122,10 @@ end_of_char_constant:; lexer_token.type = T_CHARACTER_CONSTANT; lexer_token.literal = identify_string(string, size); + + if (size == 0) { + parse_error("empty character constant"); + } } /** diff --git a/parser.c b/parser.c index efb6297..500c1ad 100644 --- a/parser.c +++ b/parser.c @@ -6212,7 +6212,7 @@ static expression_t *parse_character_constant(void) literal->literal.value = token.literal; size_t len = literal->literal.value.size; - if (len != 1) { + if (len > 1) { if (!GNU_MODE && !(c_mode & _C99)) { errorf(HERE, "more than 1 character in character constant"); } else if (warning.multichar) { @@ -6236,7 +6236,7 @@ static expression_t *parse_wide_character_constant(void) literal->literal.value = token.literal; size_t len = wstrlen(&literal->literal.value); - if (len != 1) { + if (len > 1) { warningf(HERE, "multi-character character constant"); }