Author: Armin Rigo <[email protected]>
Branch:
Changeset: r119:cc5e3f72c5b9
Date: 2014-11-29 12:34 +0100
http://bitbucket.org/cffi/creflect/changeset/cc5e3f72c5b9/
Log: tweaks
diff --git a/creflect/src/c_decl_parser.c b/creflect/src/c_decl_parser.c
--- a/creflect/src/c_decl_parser.c
+++ b/creflect/src/c_decl_parser.c
@@ -265,7 +265,7 @@
next_token(tok);
if (tok->kind != TOK_CLOSE_BRACKET) {
if (tok->kind != TOK_INTEGER) {
- parse_error(tok, "expected an integer constant");
+ parse_error(tok, "expected a positive integer constant");
return;
}
@@ -273,6 +273,10 @@
length = strtoull(tok->p, NULL, 10);
else
length = strtoul(tok->p, NULL, 10);
+ if (length == (uintptr_t)-1) {
+ parse_error(tok, "number too large");
+ return;
+ }
next_token(tok);
}
diff --git a/test/test_c_decl_parser.py b/test/test_c_decl_parser.py
--- a/test/test_c_decl_parser.py
+++ b/test/test_c_decl_parser.py
@@ -91,6 +91,7 @@
parse("int a", "int")
parse("int *abc", "PTR int")
parse("int myfunc(int a[])", "FUNC( PTR int -> int )")
+ parse("abcd efgh", "abcd") # 'efgh' is the variable name, ignored
def test_c_decl_error():
parse_error("short short int", "'short' after another 'short' or 'long'",
6)
@@ -111,12 +112,13 @@
parse_error("int(int]", "expected ')'", 7)
parse_error("int(*]", "expected ')'", 5)
parse_error("int(]", "identifier expected", 4)
- parse_error("int[?]", "expected an integer constant", 4)
+ parse_error("int[?]", "expected a positive integer constant", 4)
parse_error("int[24)", "expected ']'", 6)
parse_error("struct", "struct or union name expected", 6)
parse_error("struct 24", "struct or union name expected", 7)
parse_error("int[5](*)", "identifier expected", 7)
parse_error("int a(*)", "identifier expected", 6)
+ parse_error("int[123456789012345678901234567890]", "number too large", 4)
#
parse_error("int" + "[]" * 2500, "type too lengthy", 3337)
parse_error("f" * 1200, "identifier name too long", 0)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit