]> git.saurik.com Git - bison.git/commitdiff
errors: indent "result type clash" error context
authorTheophile Ranquet <ranquet@lrde.epita.fr>
Wed, 26 Sep 2012 09:49:18 +0000 (11:49 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Wed, 26 Sep 2012 10:00:29 +0000 (12:00 +0200)
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 <akim@lrde.epita.fr>
THANKS
src/complain.h
src/reader.c
tests/glr-regression.at

diff --git a/THANKS b/THANKS
index 95acb1e2284c6e7b46597452527c685b67f42890..8af0abbe8c73020d4260b83b8c24375595b489e2 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -102,6 +102,7 @@ Shura                     debil_urod@ngs.ru
 Stefano Lattarini         stefano.lattarini@gmail.com
 Steve Murphy              murf@parsetree.com
 Sum Wu                    sum@geekhouse.org
+Théophile Ranquet         theophile.ranquet@gmail.com
 Thiru Ramakrishnan        thiru.ramakrishnan@gmail.com
 Tim Josling               tej@melbpc.org.au
 Tim Landscheidt           tim@tim-landscheidt.de
@@ -125,6 +126,7 @@ thank them!  Please, help us keeping this list up to date.
 
 Local Variables:
 mode: text
+coding: utf-8
 End:
 
 -----
index b893564573415a045f98bdf2822386c59182e95b..997d577b6ff05ae74bb0d32d12e6846408b25fe5 100644 (file)
@@ -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.
index 7dd0aaa46c7b13d528e31a18746a4501175bd945..86fde7b2e4303b3371b233a48a9da98673e2a27b 100644 (file)
@@ -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;
 }
index 07c9fe259bee75a5bfebde7a58dcaf8a98dea630..8cea46c9c5eb2a28a4385f22888ce40269718d15 100644 (file)
@@ -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