aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-05-27 01:04:25 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-06-01 15:06:12 +0200
commit573953f358dcb77308532d8e2020bf045213acc6 (patch)
tree953fb9f9c5c135bbeeb6edc0fb6b99d828af8313
parentf88da50b475e3e5efdccfab1375ff6af6ae2b9ec (diff)
downloadsparse-dev-573953f358dcb77308532d8e2020bf045213acc6.tar.gz
give a position to end-of-input
If an error occurs at the end of the input, for example because a missing terminating ';' or '}', the error message is like: builtin:0:0: error: ... IOW, the stream name & position is not displayed because the because the current token is eof_token_entry which has no position. This can be confusing and for sure doesn't point where the error is. Fix this by giving to eof_token_entry the end-of-stream position. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--tokenize.c1
-rw-r--r--validation/check_byte_count-ice.c4
-rw-r--r--validation/error-at-eof.c10
3 files changed, 13 insertions, 2 deletions
diff --git a/tokenize.c b/tokenize.c
index aa4dc184..1118786f 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -444,6 +444,7 @@ static struct token *mark_eof(stream_t *stream)
struct token *end;
end = alloc_token(stream);
+ eof_token_entry.pos = end->pos;
token_type(end) = TOKEN_STREAMEND;
end->pos.newline = 1;
diff --git a/validation/check_byte_count-ice.c b/validation/check_byte_count-ice.c
index 7b85b963..dae40c67 100644
--- a/validation/check_byte_count-ice.c
+++ b/validation/check_byte_count-ice.c
@@ -12,8 +12,8 @@ check_byte_count-ice.c:6:0: warning: Newline in string or character constant
check_byte_count-ice.c:5:23: warning: multi-character character constant
check_byte_count-ice.c:6:1: error: Expected ) in function call
check_byte_count-ice.c:6:1: error: got }
-builtin:0:0: error: Expected } at end of function
-builtin:0:0: error: got end-of-input
+check_byte_count-ice.c:20:0: error: Expected } at end of function
+check_byte_count-ice.c:20:0: error: got end-of-input
check_byte_count-ice.c:5:15: error: not enough arguments for function memset
* check-error-end
*/
diff --git a/validation/error-at-eof.c b/validation/error-at-eof.c
new file mode 100644
index 00000000..7d933651
--- /dev/null
+++ b/validation/error-at-eof.c
@@ -0,0 +1,10 @@
+/*
+ * check-name: error-at-eof
+ *
+ * check-error-start
+error-at-eof.c:11:0: error: Expected ; at end of declaration
+error-at-eof.c:11:0: error: got end-of-input
+ * check-error-end
+ */
+
+int a