try_finally_expr wrong source location info
Vyacheslav Barinov
v.barinov@samsung.com
Wed Jul 12 12:45:00 GMT 2017
Hello,
I've fixed the location issue by generating new STATEMENT_LIST_END tree for
each compound statement and using it to store the location of closing brace.
I do understand that it's rather an ugly workaround than a solution, but still
it resolves the issue for us and doesn't break GCC testsuite. So I'll send it
here, maybe someone else needs the fix.
Best Regards,
Vyacheslav Barinov
Eric Botcazou <ebotcazou@adacore.com> writes:
>> But then, after lowering on the eh pass (gcc/tree-eh.c:1161), the "finally"
>> location is set up to the `gimple_location (tf->try_finally_expr)' which
>> actually expands to "testcase.cxx:4", a place where the "try" block starts.
>>
>> The dump testcase.cxx.009t.ehopt shows no location info for destructor:
>> std::unique_ptr<char>::~unique_ptr (&lang);
>>
>> And next testcase.cxx.010t.eh dump shows equal location for constructor and
>> destructor:
>> [testcase.cxx:4:38] std::unique_ptr<char>::unique_ptr ([testcase.cxx:4:38]
>> &lang, D.42272); [testcase.cxx:4:38] std::unique_ptr<char>::~unique_ptr
>> (&lang);
>>
>> I performed several experiments trying to get information about gimple_block
>> around the try_finally_expr statement right in `lower_try_finally_onedest',
>> but unsuccessfully. And also, as far as I understand, this issue should be
>> fixed in all the lowering functions, not only this one.
>>
>> Where should I dig in order to fix the issue?
>
> We have been using this patchlet locally for some time:
>
> Index: tree-eh.c
> ===================================================================
> --- tree-eh.c (revision 248944)
> +++ tree-eh.c (working copy)
> @@ -1413,11 +1413,12 @@ lower_try_finally_switch (struct leh_sta
> x = gimple_build_assign (finally_tmp,
> build_int_cst (integer_type_node,
> fallthru_index));
> + gimple_set_location (x, finally_loc);
> gimple_seq_add_stmt (&tf->top_p_seq, x);
>
> tmp = build_int_cst (integer_type_node, fallthru_index);
> last_case = build_case_label (tmp, NULL,
> - create_artificial_label (tf_loc));
> + create_artificial_label (finally_loc));
> case_label_vec.quick_push (last_case);
> last_case_index++;
>
> @@ -1426,7 +1427,7 @@ lower_try_finally_switch (struct leh_sta
>
> tmp = lower_try_finally_fallthru_label (tf);
> x = gimple_build_goto (tmp);
> - gimple_set_location (x, tf_loc);
> + gimple_set_location (x, finally_loc);
> gimple_seq_add_stmt (&switch_body, x);
> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-cleanup-location-for-try_finally_expr.patch
Type: text/x-diff
Size: 21804 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20170712/1cc75c4d/attachment.bin>
More information about the Gcc
mailing list