re PR c++/53289 (unnecessary repetition of caret diagnostics)
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Wed, 9 May 2012 21:14:15 +0000 (21:14 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Wed, 9 May 2012 21:14:15 +0000 (21:14 +0000)
2012-05-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>

PR c++/53289
gcc/
* diagnostic.h (diagnostic_context): Add last_location.
* diagnostic.c (diagnostic_initialize): Initialize it.
(diagnostic_show_locus): Use it.

From-SVN: r187355

gcc/ChangeLog
gcc/diagnostic.c
gcc/diagnostic.h

index bd8b9b2099265b0c4abeb500dfc6e704285d7cd1..40ff5a153c884c118262737d8d156bfe2e8745db 100644 (file)
        (xop_mulv2div2di3_low): Remove insn_and_split pattern.
        (xop_mulv2div2di3_high): Ditto.
 
+2012-05-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>
+
+       PR c++/53289
+       * diagnostic.h (diagnostic_context): Add last_location.
+       * diagnostic.c (diagnostic_initialize): Initialize it.
+       (diagnostic_show_locus): Use it.
+
 2012-05-09  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        * doc/extend.texi (Function Attributes): Point xref to section
index 1e2712e59b1ca9df87ae52b646a3737b20bed986..4913eed9c67318104881aa7835fe826b69752a05 100644 (file)
@@ -147,6 +147,7 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
   context->option_enabled = NULL;
   context->option_state = NULL;
   context->option_name = NULL;
+  context->last_location = UNKNOWN_LOCATION;
   context->last_module = 0;
   context->x_data = NULL;
   context->lock = 0;
@@ -263,9 +264,11 @@ diagnostic_show_locus (diagnostic_context * context,
 
 
   if (!context->show_caret
-      || diagnostic->location <= BUILTINS_LOCATION)
+      || diagnostic->location <= BUILTINS_LOCATION
+      || diagnostic->location == context->last_location)
     return;
 
+  context->last_location = diagnostic->location;
   s = expand_location_to_spelling_point (diagnostic->location);
   line = location_get_source_line (s);
   if (line == NULL)
index 63eb38529588ff801134ee6574dffc2727728f42..976754ef3f27853c2f551e243994f6b635243bc6 100644 (file)
@@ -172,6 +172,9 @@ struct diagnostic_context
   /* Auxiliary data for client.  */
   void *x_data;
 
+  /* Used to detect that the last caret was printed at the same location.  */
+  location_t last_location;
+
   /* Used to detect when the input file stack has changed since last
      described.  */
   const struct line_map *last_module;