This hack, has described in more details in the email labeled "Line 0 Hack??", was ...
13 years, 9 months ago
(2011-08-02 03:15:43 UTC)
#1
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
>>>>> "Gabriel" == Gabriel Charette <gchare@google.com> writes: Gabriel> This hack, has described in more details ...
13 years, 8 months ago
(2011-08-05 17:37:12 UTC)
#2
>>>>> "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
On Fri, Aug 5, 2011 at 13:37, Tom Tromey <tromey@redhat.com> wrote: >>>>>> "Gabriel" == Gabriel ...
13 years, 8 months ago
(2011-08-05 17:39:26 UTC)
#3
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.
On Fri, Aug 5, 2011 at 10:37 AM, Tom Tromey <tromey@redhat.com> wrote: >>>>>> "Gabriel" == ...
13 years, 8 months ago
(2011-08-05 18:18:13 UTC)
#4
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
Issue 4835047: Remove line 0 hack in cp/decl.c
(Closed)
Created 13 years, 9 months ago by Gabriel Charette
Modified 13 years, 8 months ago
Reviewers: Lawrence Crowl, Diego Novillo, steven_gcc.gnu.org, tromey_redhat.com
Base URL:
Comments: 0