This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] suppress blank line in diagnostic output


This bug seems to have been in the mainline for a while,
so it's surprising it hasn't been fixed before.

Compile a C file with an error in a function, such as:

void foo()
{
  return 0;
}

You get:
/tmp/foo.c: In function `foo':

/tmp/foo.c:3: warning: `return' with a value, in function returning void

Notice this blank line after the "In function".  This is hopefully
not intentional.

The pp_newline is not needed because the following pp_flush
does an fputc of '\n'.  I don't know if pp_needs_newline
in pp_base_flush is needed, but it seems plausible.  Perhaps
someone who know the pretty-printer can comment.

Bootstrapped with no regressions on mainline.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


2003-12-19  Per Bothner  <per@bothner.com>

	* langhooks.c (lhd_print_error_function):  Don't do pp_newline;
	it causes an extra blank line.
	* pretty-print.c (pp_base_flush):  Clear pp_needs_newline.

Index: langhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.c,v
retrieving revision 1.55
diff -u -p -r1.55 langhooks.c
--- langhooks.c	12 Nov 2003 19:52:09 -0000	1.55
+++ langhooks.c	20 Dec 2003 00:09:13 -0000
@@ -545,7 +545,6 @@ lhd_print_error_function (diagnostic_con
 	      (context->printer, "In function `%s':",
 	       (*lang_hooks.decl_printable_name) (current_function_decl, 2));
 	}
-      pp_newline (context->printer);
 
       diagnostic_set_last_function (context);
       pp_flush (context->printer);
Index: pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/pretty-print.c,v
retrieving revision 2.7
diff -u -p -r2.7 pretty-print.c
--- pretty-print.c	13 Dec 2003 04:11:23 -0000	2.7
+++ pretty-print.c	20 Dec 2003 00:09:13 -0000
@@ -343,6 +343,7 @@ pp_base_flush (pretty_printer *pp)
   pp_clear_state (pp);
   fputc ('\n', pp->buffer->stream);
   fflush (pp->buffer->stream);
+  pp_needs_newline (pp) = false;
 }
 
 /* Sets the number of maximum characters per line PRETTY-PRINTER can

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]