From 7e3a813f688232145d278bdecf7b85e2f311f898 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 8 Mar 2013 21:45:35 +0100 Subject: [PATCH] cuda.c: stmt_print_global_index: add extra parentheses around index expression The index expression may contain operators (specifically ?:) that have a lower precedence that + and so we have to make sure the index expression is evaluated first. Reported-by: Tobias Grosser Signed-off-by: Sven Verdoolaege --- cuda.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cuda.c b/cuda.c index babe8d0..b23e840 100644 --- a/cuda.c +++ b/cuda.c @@ -452,10 +452,12 @@ static __isl_give isl_printer *stmt_print_global_index( bound_i = isl_pw_aff_list_get_pw_aff(bound, i); p = isl_printer_print_str(p, ") * ("); p = isl_printer_print_pw_aff(p, bound_i); - p = isl_printer_print_str(p, ") + "); + p = isl_printer_print_str(p, ") + ("); isl_pw_aff_free(bound_i); } p = isl_printer_print_ast_expr(p, expr); + if (i) + p = isl_printer_print_str(p, ")"); isl_ast_expr_free(expr); } p = isl_printer_print_str(p, "]"); -- 2.11.4.GIT