This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: try_finally_expr wrong source location info
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: Vyacheslav Barinov <v dot barinov at samsung dot com>
- Cc: gcc at gcc dot gnu dot org, Merzlyakov Alexey <alexey dot merzlyakov at samsung dot com>, Ostapenko Maksim <m dot ostapenko at samsung dot com>
- Date: Sat, 10 Jun 2017 00:27:13 +0200
- Subject: Re: try_finally_expr wrong source location info
- Authentication-results: sourceware.org; auth=none
- References: <CGME20170609175524eucas1p281bea1138dfbd7c7b5c0d49dfa78155f@eucas1p2.samsung.com> <877f0lqc53.fsf@samsung.com>
> 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);
}
--
Eric Botcazou