[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/6] errors: indent "result type clash" error context
From: |
Theophile Ranquet |
Subject: |
[PATCH 1/6] errors: indent "result type clash" error context |
Date: |
Wed, 26 Sep 2012 15:45:11 +0200 |
From: Theophile Ranquet <address@hidden>
This used to be the format of the error report:
input.y:6.5-10: result type clash on merge function 'merge': [...]
input.y:2.4-9: previous declaration
In order to distinguish the actual error from the context provided, we
rather this new output:
input.y:6.5-10: result type clash on merge function 'merge': [...]
input.y:2.4-9: previous declaration
Another patch will introduce an "error: " prefix to all non-indented
lines, giving yet better readability to the reports.
* src/complain.h (SUB_INDENT): Move to here.
* src/reader.c (record_merge_function_type): Use complain_at_indent to
output with increased indentation level.
* src/scan-code.l (SUB_INDENT): Remove from here.
* tests/glr-regression.at: Apply this change.
Signed-off-by: Akim Demaille <address@hidden>
---
THANKS | 2 ++
src/complain.h | 3 +++
src/reader.c | 16 ++++++++++------
tests/glr-regression.at | 4 ++--
4 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/THANKS b/THANKS
index 95acb1e..8af0abb 100644
--- a/THANKS
+++ b/THANKS
@@ -102,6 +102,7 @@ Shura address@hidden
Stefano Lattarini address@hidden
Steve Murphy address@hidden
Sum Wu address@hidden
+Théophile Ranquet address@hidden
Thiru Ramakrishnan address@hidden
Tim Josling address@hidden
Tim Landscheidt address@hidden
@@ -125,6 +126,7 @@ thank them! Please, help us keeping this list up to date.
Local Variables:
mode: text
+coding: utf-8
End:
-----
diff --git a/src/complain.h b/src/complain.h
index b893564..997d577 100644
--- a/src/complain.h
+++ b/src/complain.h
@@ -25,6 +25,9 @@
extern "C" {
# endif
+/* Sub-messages indent. */
+#define SUB_INDENT (4)
+
/** Record that a warning is about to be issued, and treat it as an
error if <tt>warnings_flag & warnings_error</tt>. This is exported
only for the sake of Yacc-compatible conflict reports in conflicts.c.
diff --git a/src/reader.c b/src/reader.c
index 7dd0aaa..86fde7b 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -128,12 +128,16 @@ record_merge_function_type (int merger, uniqstr type,
location declaration_loc)
aver (merge_function != NULL && merger_find == merger);
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
{
- complain_at (declaration_loc,
- _("result type clash on merge function %s: <%s> != <%s>"),
- quote (merge_function->name), type, merge_function->type);
- complain_at (merge_function->type_declaration_location,
- _("previous declaration"));
- }
+ unsigned indent = 0;
+ complain_at_indent (declaration_loc, &indent,
+ _("result type clash on merge function %s: "
+ "<%s> != <%s>"),
+ quote (merge_function->name), type,
+ merge_function->type);
+ indent += SUB_INDENT;
+ complain_at_indent (merge_function->type_declaration_location, &indent,
+ _("previous declaration"));
+ }
merge_function->type = uniqstr_new (type);
merge_function->type_declaration_location = declaration_loc;
}
diff --git a/tests/glr-regression.at b/tests/glr-regression.at
index 07c9fe2..8cea46c 100644
--- a/tests/glr-regression.at
+++ b/tests/glr-regression.at
@@ -1651,9 +1651,9 @@ AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
[glr-regr18.y:26.18-24: result type clash on merge function 'merge': <type2>
!= <type1>
-glr-regr18.y:25.18-24: previous declaration
+glr-regr18.y:25.18-24: previous declaration
glr-regr18.y:27.13-19: result type clash on merge function 'merge': <type3> !=
<type2>
-glr-regr18.y:26.18-24: previous declaration
+glr-regr18.y:26.18-24: previous declaration
])
AT_CLEANUP
--
1.7.10
- [PATCH 0/6] {maint} errors: output prefixing, Theophile Ranquet, 2012/09/26
- [PATCH 6/6] warnings: introduce -Wdeprecated in the usage info, Theophile Ranquet, 2012/09/26
- [PATCH 1/6] errors: indent "result type clash" error context,
Theophile Ranquet <=
- [PATCH 3/6] errors: indent "%define var" redefinition context, Theophile Ranquet, 2012/09/26
- [PATCH 4/6] errors: indent "invalid value for %define" context, Theophile Ranquet, 2012/09/26
- [PATCH 5/6] errors: prefix the output with "error: ", Theophile Ranquet, 2012/09/26
- [PATCH 2/6] errors: indent "symbol redeclaration" context, Theophile Ranquet, 2012/09/26
- Re: [PATCH 0/6] {maint} errors: output prefixing, Akim Demaille, 2012/09/26