public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Remove line 0 hack in cp/decl.c (issue4835047)
@ 2011-08-02  3:16 Gabriel Charette
  2011-08-05 17:40 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Gabriel Charette @ 2011-08-02  3:16 UTC (permalink / raw)
  To: reply, crowl, dnovillo, steven, tromey, gcc-patches

This hack, has described in more details in the email labeled "Line 0 Hack??", was now causing problem when serializing the line_table in pph.

According to the revision history: this was introduced by steven in 2005:
    commit ba821eb102fc1a654c0542fcba73898340a9a02d
    Author: steven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>
    Date:   Sat Jan 1 16:15:23 2005 +0000

	    * emit-rtl.c (add_insn_before): Fix comment typo.
	
	    PR middle-end/17544
	    * c-decl.c (finish_function): If compiling C99, annotate the
	    compiler generated return with the current file name and line 0.
	    * tree-cfg.c (remove_useless_stmts_warn_notreached): Only warn if
	    the source line is greater than 0.

	    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92784 138bc75d-0d04-0410-961f-82ee72b054a4

The function remove_useless_stmts_warn_notreached refered to by steven in his 2005 commit has been removed on 2009-10-08 by matz@suse.de according to ChangeLog-2009.

This patch removes this hack which appears to be no longer necessary.

Tested with a full bootstrap build and regression testing on x64.

Gabriel

2011-08-01  Gabriel Charette  <gchare@google.com>

	* decl.c (finish_function): Remove unecessary line 0 hack.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 2000bd4..9ee3c6d 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13220,22 +13220,13 @@ finish_function (int flags)
     {
       if (DECL_MAIN_P (current_function_decl))
 	{
-	  tree stmt;
-
 	  /* Make it so that `main' always returns 0 by default (or
 	     1 for VMS).  */
 #if VMS_TARGET
-	  stmt = finish_return_stmt (integer_one_node);
+	  finish_return_stmt (integer_one_node);
 #else
-	  stmt = finish_return_stmt (integer_zero_node);
+	  finish_return_stmt (integer_zero_node);
 #endif
-	  /* Hack.  We don't want the middle-end to warn that this
-	     return is unreachable, so put the statement on the
-	     special line 0.  */
-	  {
-	    location_t linezero = linemap_line_start (line_table, 0, 1);
-	    SET_EXPR_LOCATION (stmt, linezero);
-	  }
 	}
 
       if (use_eh_spec_block (current_function_decl))

--
This patch is available for review at http://codereview.appspot.com/4835047

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Remove line 0 hack in cp/decl.c (issue4835047)
  2011-08-02  3:16 Remove line 0 hack in cp/decl.c (issue4835047) Gabriel Charette
@ 2011-08-05 17:40 ` Tom Tromey
  2011-08-05 17:42   ` Diego Novillo
  2011-08-05 18:19   ` Gabriel Charette
  0 siblings, 2 replies; 4+ messages in thread
From: Tom Tromey @ 2011-08-05 17:40 UTC (permalink / raw)
  To: Gabriel Charette; +Cc: reply, crowl, dnovillo, steven, gcc-patches

>>>>> "Gabriel" == Gabriel Charette <gchare@google.com> writes:

Gabriel> This hack, has described in more details in the email labeled
Gabriel> "Line 0 Hack??", was now causing problem when serializing the
Gabriel> line_table in pph.

I think you do have to handle location 0 somehow.
This is UNKNOWN_LOCATION, referred to widely in the sources.

Gabriel> 2011-08-01  Gabriel Charette  <gchare@google.com>
Gabriel> 	* decl.c (finish_function): Remove unecessary line 0 hack.

Now that -Wunreachable-code is gone, I doubt this code is even
theoretically relevant.  So, while I can't approve or reject this patch,
it seems reasonable to me.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Remove line 0 hack in cp/decl.c (issue4835047)
  2011-08-05 17:40 ` Tom Tromey
@ 2011-08-05 17:42   ` Diego Novillo
  2011-08-05 18:19   ` Gabriel Charette
  1 sibling, 0 replies; 4+ messages in thread
From: Diego Novillo @ 2011-08-05 17:42 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Gabriel Charette, reply, crowl, steven, gcc-patches

On Fri, Aug 5, 2011 at 13:37, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Gabriel" == Gabriel Charette <gchare@google.com> writes:
>
> Gabriel> This hack, has described in more details in the email labeled
> Gabriel> "Line 0 Hack??", was now causing problem when serializing the
> Gabriel> line_table in pph.
>
> I think you do have to handle location 0 somehow.
> This is UNKNOWN_LOCATION, referred to widely in the sources.
>
> Gabriel> 2011-08-01  Gabriel Charette  <gchare@google.com>
> Gabriel>        * decl.c (finish_function): Remove unecessary line 0 hack.
>
> Now that -Wunreachable-code is gone, I doubt this code is even
> theoretically relevant.  So, while I can't approve or reject this patch,
> it seems reasonable to me.

In that case, this is OK for trunk.  Thanks Tom.


Diego.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Remove line 0 hack in cp/decl.c (issue4835047)
  2011-08-05 17:40 ` Tom Tromey
  2011-08-05 17:42   ` Diego Novillo
@ 2011-08-05 18:19   ` Gabriel Charette
  1 sibling, 0 replies; 4+ messages in thread
From: Gabriel Charette @ 2011-08-05 18:19 UTC (permalink / raw)
  To: Tom Tromey; +Cc: reply, crowl, dnovillo, steven, gcc-patches

On Fri, Aug 5, 2011 at 10:37 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Gabriel" == Gabriel Charette <gchare@google.com> writes:
>
> Gabriel> This hack, has described in more details in the email labeled
> Gabriel> "Line 0 Hack??", was now causing problem when serializing the
> Gabriel> line_table in pph.
>
> I think you do have to handle location 0 somehow.
> This is UNKNOWN_LOCATION, referred to widely in the sources.
>

I do handle location 0, the problem is that this specific call to
linemap_line_start was made late, after all linemap entries had exited
(LC_LEAVE), and thus this would create a new LC_ENTER in the table and
the parsing would finish with line_table->depth == 1 (instead of 0 as
expected)... This bug never really showed up because at that point no
one is trying to add new entries to the line_table, it only shows up
now that we're trying to serialize the line_table.

> Gabriel> 2011-08-01  Gabriel Charette  <gchare@google.com>
> Gabriel>        * decl.c (finish_function): Remove unecessary line 0 hack.
>
> Now that -Wunreachable-code is gone, I doubt this code is even
> theoretically relevant.  So, while I can't approve or reject this patch,
> it seems reasonable to me.
>

Ok Thanks,
Gabriel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-08-05 18:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-02  3:16 Remove line 0 hack in cp/decl.c (issue4835047) Gabriel Charette
2011-08-05 17:40 ` Tom Tromey
2011-08-05 17:42   ` Diego Novillo
2011-08-05 18:19   ` Gabriel Charette

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).