aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-typeck.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c/c-typeck.c')
-rw-r--r--gcc/c/c-typeck.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 7b90b5cd2f0..19fb73f840b 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -10528,11 +10528,14 @@ c_finish_if_stmt (location_t if_locus, tree cond, tree then_block,
the beginning of the loop. COND is the loop condition. COND_IS_FIRST
is false for DO loops. INCR is the FOR increment expression. BODY is
the statement controlled by the loop. BLAB is the break label. CLAB is
- the continue label. Everything is allowed to be NULL. */
+ the continue label. Everything is allowed to be NULL.
+ COND_LOCUS is the location of the loop condition, INCR_LOCUS is the
+ location of the FOR increment expression. */
void
-c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
- tree blab, tree clab, bool cond_is_first)
+c_finish_loop (location_t start_locus, location_t cond_locus, tree cond,
+ location_t incr_locus, tree incr, tree body, tree blab,
+ tree clab, bool cond_is_first)
{
tree entry = NULL, exit = NULL, t;
@@ -10574,12 +10577,8 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
}
t = build_and_jump (&blab);
- if (cond_is_first)
- exit = fold_build3_loc (start_locus,
- COND_EXPR, void_type_node, cond, exit, t);
- else
- exit = fold_build3_loc (input_location,
- COND_EXPR, void_type_node, cond, exit, t);
+ exit = fold_build3_loc (cond_is_first ? start_locus : input_location,
+ COND_EXPR, void_type_node, cond, exit, t);
}
else
{
@@ -10600,9 +10599,23 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
if (clab)
add_stmt (build1 (LABEL_EXPR, void_type_node, clab));
if (incr)
- add_stmt (incr);
+ {
+ if (MAY_HAVE_DEBUG_MARKER_STMTS && incr_locus != UNKNOWN_LOCATION)
+ {
+ t = build0 (DEBUG_BEGIN_STMT, void_type_node);
+ SET_EXPR_LOCATION (t, incr_locus);
+ add_stmt (t);
+ }
+ add_stmt (incr);
+ }
if (entry)
add_stmt (entry);
+ if (MAY_HAVE_DEBUG_MARKER_STMTS && cond_locus != UNKNOWN_LOCATION)
+ {
+ t = build0 (DEBUG_BEGIN_STMT, void_type_node);
+ SET_EXPR_LOCATION (t, cond_locus);
+ add_stmt (t);
+ }
if (exit)
add_stmt (exit);
if (blab)