This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] use correct column info for function definitions
- From: Arnaud Charlet <charlet at adacore dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: joseph at codesourcery dot com, gcc-patches at gcc dot gnu dot org, charlet at act-europe dot fr, tromey at redhat dot com
- Date: Tue, 9 Sep 2008 09:37:34 +0200
- Subject: Re: [patch] use correct column info for function definitions
- References: <20080908213706.GA7429@redhat.com>
> In C, we are are using the opening brace of a function as the column
> location for the function DECL. This is confusing for error messages,
> though rumor has it, for debugging, we need the prologue to point to the
> instruction after the opening brace-- hence the current behavior.
Interesting. So I guess that not setting the DECL_LOCATION in c-parser.c
any more is sufficient to have it set (earlier?) to the proper location ?
I had the following local change to achieve the effect of setting
DECL_LOCATION to the function's name, which I guess is made obsolete
by your change (in c-parser.c), which looks better than mine:
<<
@@ -1296,8 +1296,12 @@ c_parser_declaration_or_fndef (c_parser
while (c_parser_next_token_is_not (parser, CPP_EOF)
&& c_parser_next_token_is_not (parser, CPP_OPEN_BRACE))
c_parser_declaration_or_fndef (parser, false, false, true, false);
- DECL_SOURCE_LOCATION (current_function_decl)
- = c_parser_peek_token (parser)->location;
+ if (declarator->kind == cdk_function)
+ DECL_SOURCE_LOCATION (current_function_decl) = declarator->id_loc;
+ else
+ DECL_SOURCE_LOCATION (current_function_decl)
+ = c_parser_peek_token (parser)->location;
+
store_parm_decls ();
fnbody = c_parser_compound_statement (parser);
if (nested)
>>
Arno