diff options
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 59b71aa..81b2018 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,11 @@ 2013-09-18 Marek Polacek <polacek@redhat.com> + PR sanitize/58443 + * c-typeck.c (build_binary_op): Properly honor -fsanitize options. + Remove unnecessary check. + +2013-09-18 Marek Polacek <polacek@redhat.com> + PR sanitizer/58411 * c-typeck.c (build_binary_op): Don't sanitize function if it has the no_sanitize_undefined attribute. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 7dc5527..7ecafe4 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -10496,7 +10496,7 @@ build_binary_op (location_t location, enum tree_code code, return error_mark_node; } - if (flag_sanitize & SANITIZE_UNDEFINED + if ((flag_sanitize & (SANITIZE_SHIFT | SANITIZE_DIVIDE)) && current_function_decl != 0 && !lookup_attribute ("no_sanitize_undefined", DECL_ATTRIBUTES (current_function_decl)) @@ -10507,9 +10507,9 @@ build_binary_op (location_t location, enum tree_code code, op1 = c_save_expr (op1); op0 = c_fully_fold (op0, false, NULL); op1 = c_fully_fold (op1, false, NULL); - if (doing_div_or_mod) + if (doing_div_or_mod && (flag_sanitize & SANITIZE_DIVIDE)) instrument_expr = ubsan_instrument_division (location, op0, op1); - else if (doing_shift) + else if (doing_shift && (flag_sanitize & SANITIZE_SHIFT)) instrument_expr = ubsan_instrument_shift (location, code, op0, op1); } @@ -10537,7 +10537,7 @@ build_binary_op (location_t location, enum tree_code code, ret = build1 (EXCESS_PRECISION_EXPR, semantic_result_type, ret); protected_set_expr_location (ret, location); - if ((flag_sanitize & SANITIZE_UNDEFINED) && instrument_expr != NULL) + if (instrument_expr != NULL) ret = fold_build2 (COMPOUND_EXPR, TREE_TYPE (ret), instrument_expr, ret); |