aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-01-05 13:23:54 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-12 09:24:32 -0500
commit15cfba61d99668e9c14782779766f48834490ead (patch)
tree7cad991ebdef4f266bbd57efccc6ae762af0265c
parentc8b02fc63037f6e6e0147fc65a67a7809ca5744e (diff)
downloadsparse-15cfba61d99668e9c14782779766f48834490ead.tar.gz
massage handling of wide string literals/character constants in tokenizer
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--tokenize.c21
-rw-r--r--validation/wide.c9
2 files changed, 22 insertions, 8 deletions
diff --git a/tokenize.c b/tokenize.c
index 57afebc1..42630212 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -383,6 +383,7 @@ enum {
Exp = 8,
Dot = 16,
ValidSecond = 32,
+ Quote = 64,
};
static const long cclass[257] = {
@@ -409,6 +410,8 @@ static const long cclass[257] = {
['&' + 1] = ValidSecond,
['|' + 1] = ValidSecond,
['#' + 1] = ValidSecond,
+ ['\'' + 1] = Quote,
+ ['"' + 1] = Quote,
};
/*
@@ -904,17 +907,19 @@ static int get_one_identifier(int c, stream_t *stream)
buf[len] = next;
len++;
};
+ if (cclass[next + 1] & Quote) {
+ if (len == 1 && buf[0] == 'L') {
+ if (next == '\'')
+ return get_char_token(nextchar(stream), stream,
+ TOKEN_WIDE_CHAR);
+ else
+ return get_string_token(nextchar(stream), stream,
+ TOKEN_WIDE_STRING);
+ }
+ }
hash = ident_hash_end(hash);
-
ident = create_hashed_ident(buf, len, hash);
- if (ident == &L_ident) {
- if (next == '\'')
- return get_char_token(nextchar(stream), stream, TOKEN_WIDE_CHAR);
- if (next == '\"')
- return get_string_token(nextchar(stream), stream, TOKEN_WIDE_STRING);
- }
-
/* Pass it on.. */
token = stream->token;
token_type(token) = TOKEN_IDENT;
diff --git a/validation/wide.c b/validation/wide.c
new file mode 100644
index 00000000..847a680f
--- /dev/null
+++ b/validation/wide.c
@@ -0,0 +1,9 @@
+static char c = L'\x41';
+static int n = 1/(0x41 - L'\x41');
+/*
+ * check-name: wide character constants
+ *
+ * check-error-start
+wide.c:2:17: warning: division by zero
+ * check-error-end
+ */