Patchwork Fix up lineno of builtin defines (PR debug/60603)

login
register
mail settings
Submitter Jakub Jelinek
Date March 21, 2014, 8:26 p.m.
Message ID <20140321202616.GU1817@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/332741/
State New
Headers show

Comments

Jakub Jelinek - March 21, 2014, 8:26 p.m.
Hi!

While the cpp_force_token_locations/cp_stop_forcing_token_locations
pair forces BUILTINS_LOCATION upon tokens, the change introducing them
removed cb_file_change/linemap_add, which is needed e.g. for proper
line numbers of builtin defines in -g3 .debug_macro/.debug_macinfo.

Fixed by reverting that part of the 2011-08-22 changes, while keeping
the forcing of BUILTINS_LOCATION.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2014-03-21  Jakub Jelinek  <jakub@redhat.com>

	PR debug/60603
c-family/
	* c-opts.c (c_finish_options): Restore cb_file_change call to
	<built-in>.
fortran/
	* cpp.c (gfc_cpp_init): Restore cb_change_file call to
	<built-in>.
testsuite/
	* gcc.dg/debug/dwarf2/dwarf2-macro2.c: New test.


	Jakub
Joseph S. Myers - March 21, 2014, 11:31 p.m.
On Fri, 21 Mar 2014, Jakub Jelinek wrote:

> Hi!
> 
> While the cpp_force_token_locations/cp_stop_forcing_token_locations
> pair forces BUILTINS_LOCATION upon tokens, the change introducing them
> removed cb_file_change/linemap_add, which is needed e.g. for proper
> line numbers of builtin defines in -g3 .debug_macro/.debug_macinfo.
> 
> Fixed by reverting that part of the 2011-08-22 changes, while keeping
> the forcing of BUILTINS_LOCATION.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Patch

--- gcc/c-family/c-opts.c.jj	2014-03-11 12:14:00.000000000 +0100
+++ gcc/c-family/c-opts.c	2014-03-21 11:07:04.287946639 +0100
@@ -1274,17 +1274,18 @@  c_finish_options (void)
     {
       size_t i;
 
-      {
-	/* Make sure all of the builtins about to be declared have
-	  BUILTINS_LOCATION has their source_location.  */
-	source_location builtins_loc = BUILTINS_LOCATION;
-	cpp_force_token_locations (parse_in, &builtins_loc);
+      cb_file_change (parse_in,
+		      linemap_add (line_table, LC_RENAME, 0,
+				   _("<built-in>"), 0));
+      /* Make sure all of the builtins about to be declared have
+	 BUILTINS_LOCATION has their source_location.  */
+      source_location builtins_loc = BUILTINS_LOCATION;
+      cpp_force_token_locations (parse_in, &builtins_loc);
 
-	cpp_init_builtins (parse_in, flag_hosted);
-	c_cpp_builtins (parse_in);
+      cpp_init_builtins (parse_in, flag_hosted);
+      c_cpp_builtins (parse_in);
 
-	cpp_stop_forcing_token_locations (parse_in);
-      }
+      cpp_stop_forcing_token_locations (parse_in);
 
       /* We're about to send user input to cpplib, so make it warn for
 	 things that we previously (when we sent it internal definitions)
--- gcc/fortran/cpp.c.jj	2014-01-09 21:07:24.000000000 +0100
+++ gcc/fortran/cpp.c	2014-03-21 11:10:00.973020640 +0100
@@ -576,6 +576,7 @@  gfc_cpp_init (void)
   if (gfc_option.flag_preprocessed)
     return;
 
+  cpp_change_file (cpp_in, LC_RENAME, _("<built-in>"));
   if (!gfc_cpp_option.no_predefined)
     {
       /* Make sure all of the builtins about to be declared have
--- gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2-macro2.c.jj	2014-03-21 11:19:29.221017868 +0100
+++ gcc/testsuite/gcc.dg/debug/dwarf2/dwarf2-macro2.c	2014-03-21 11:20:49.768580776 +0100
@@ -0,0 +1,7 @@ 
+/* Test to make sure the macro info includes the predefined macros with line number 0.  */
+/* { dg-do compile } */
+/* { dg-options "-g3 -gdwarf -dA -fverbose-asm" } */
+/* { dg-final { scan-assembler "At line number 0" } } */
+
+#define FOO 1
+int i;