On the following testcase we ICE because while DECL_STRUCT_FUNCTION (current_function_decl)->function_start_locus = c_parser_peek_token (parser)->location; and similarly DECL_SOURCE_LOCATION (fndecl) is set from some token's location, the end is set as: /* Store the end of the function, so that we get good line number info for the epilogue. */ cfun->function_end_locus = input_location; and the thing is that input_location is only very rarely set in the C FE (the primary spot that changes it is the cb_line_change/fe_file_change). Which means, e.g. for pretty much all C functions that are on a single line, function_start_locus column is > than function_end_locus column, and the testcase even has smaller line in function_end_locus because cb_line_change isn't performed while parsing multi-line arguments of a function-like macro. Attached are two possible fixes to achieve what the C++ FE does, in particular that cfun->function_end_locus is the locus of the closing } of the function. The first one updates input_location when we see a closing } of a compound statement (though any, not just the function body) and thus input_location in the finish_function call is what we need. The second instead propagates the location_t from the parsing of the outermost compound statement (the function body) to finish_function. The second one is this version. 2020-03-19 Jakub Jelinek <jakub@redhat.com> PR gcov-profile/94029 * c-tree.h (finish_function): Add location_t argument defaulted to input_location. * c-parser.c (c_parser_compound_statement): Add endlocp argument and set it to the locus of closing } if non-NULL. (c_parser_compound_statement_nostart): Return locus of closing }. (c_parser_parse_rtl_body): Likewise. (c_parser_declaration_or_fndef): Propagate locus of closing } to finish_function. * c-decl.c (finish_function): Add end_loc argument, use it instead of input_location to set function_end_locus. * gcc.misc-tests/gcov-pr94029.c: New test.
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
acker1.c | Loading commit data... | |
acker1.exp | Loading commit data... | |
arm-isr.c | Loading commit data... | |
arm-isr.exp | Loading commit data... | |
bprob-1.c | Loading commit data... | |
bprob-2.c | Loading commit data... | |
bprob.exp | Loading commit data... | |
dectest.exp | Loading commit data... | |
dhry.c | Loading commit data... | |
dhry.exp | Loading commit data... | |
dhry.h | Loading commit data... | |
gcov-1.c | Loading commit data... | |
gcov-10.c | Loading commit data... | |
gcov-10b.c | Loading commit data... | |
gcov-11.c | Loading commit data... | |
gcov-12.c | Loading commit data... | |
gcov-13.c | Loading commit data... | |
gcov-14.c | Loading commit data... | |
gcov-15.c | Loading commit data... | |
gcov-16.c | Loading commit data... | |
gcov-17.c | Loading commit data... | |
gcov-18.c | Loading commit data... | |
gcov-1a.c | Loading commit data... | |
gcov-2.c | Loading commit data... | |
gcov-3.c | Loading commit data... | |
gcov-4.c | Loading commit data... | |
gcov-4b.c | Loading commit data... | |
gcov-5b.c | Loading commit data... | |
gcov-6.c | Loading commit data... | |
gcov-7.c | Loading commit data... | |
gcov-8.c | Loading commit data... | |
gcov-9.c | Loading commit data... | |
gcov-pr83813.c | Loading commit data... | |
gcov-pr84758.c | Loading commit data... | |
gcov-pr85217.c | Loading commit data... | |
gcov-pr85332.c | Loading commit data... | |
gcov-pr85338.c | Loading commit data... | |
gcov-pr85350.c | Loading commit data... | |
gcov-pr85372.c | Loading commit data... | |
gcov-pr86536.c | Loading commit data... | |
gcov-pr90574-1.c | Loading commit data... | |
gcov-pr90574-2.c | Loading commit data... | |
gcov-pr94029.c | Loading commit data... | |
gcov.exp | Loading commit data... | |
gcovpart-13b.c | Loading commit data... | |
godump-1.c | Loading commit data... | |
godump.exp | Loading commit data... | |
help.exp | Loading commit data... | |
i386-pf-3dnow-1.c | Loading commit data... | |
i386-pf-athlon-1.c | Loading commit data... | |
i386-pf-none-1.c | Loading commit data... | |
i386-pf-sse-1.c | Loading commit data... | |
i386-prefetch.exp | Loading commit data... | |
linkage-x.c | Loading commit data... | |
linkage-y.c | Loading commit data... | |
linkage.exp | Loading commit data... | |
matrix1.c | Loading commit data... | |
matrix1.exp | Loading commit data... | |
mg-2.c | Loading commit data... | |
mg-2.exp | Loading commit data... | |
mg.c | Loading commit data... | |
mg.exp | Loading commit data... | |
options.exp | Loading commit data... | |
output.exp | Loading commit data... | |
sieve.c | Loading commit data... | |
sieve.exp | Loading commit data... | |
sort2.c | Loading commit data... | |
sort2.exp | Loading commit data... |