[PATCH 1/2] give a position to end-of-input

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 tokenize.c                        |  1 +
 validation/check_byte_count-ice.c |  4 ++--
 validation/error-at-eof.c         | 10 ++++++++++
 3 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 validation/error-at-eof.c

diff --git a/tokenize.c b/tokenize.c
index aa4dc1840..1118786f6 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 7b85b9631..dae40c676 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 000000000..7d9336511
--- /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
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux