Report an error on empty character constants, i.e. ''.
authorChristoph Mallon <christoph.mallon@gmx.de>
Tue, 31 May 2011 11:41:18 +0000 (13:41 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Tue, 31 May 2011 11:41:57 +0000 (13:41 +0200)
lexer.c
parser.c

diff --git a/lexer.c b/lexer.c
index 8e0567e..7ae5256 100644 (file)
--- 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");
+       }
 }
 
 /**
index efb6297..500c1ad 100644 (file)
--- 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");
        }