From f34ebeb25ef25e5937f60b7e6115c3f693a12ac3 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 31 Jul 2017 10:53:00 +0200 Subject: Do UBSAN sanitization just when current_function_decl != NULL_TREE (PR sanitize/81530). 2017-07-31 Martin Liska PR sanitize/81530 * cp-gimplify.c (cp_genericize): Guard condition with flag_sanitize_p also with current_function_decl non-null equality. * cp-ubsan.c (cp_ubsan_instrument_vptr_p): Likewise. * decl.c (compute_array_index_type): Likewise. * init.c (finish_length_check): Likewise. * typeck.c (cp_build_binary_op): Likewise. 2017-07-31 Martin Liska PR sanitize/81530 * c-convert.c (convert): Guard condition with flag_sanitize_p also with current_function_decl non-null equality. * c-decl.c (grokdeclarator): Likewise. * c-typeck.c (build_binary_op): Likewise. 2017-07-31 Martin Liska PR sanitize/81530 * convert.c (convert_to_integer_1): Guard condition with flag_sanitize_p also with current_function_decl non-null equality. 2017-07-31 Martin Liska PR sanitize/81530 * c-ubsan.c (ubsan_maybe_instrument_array_ref): Guard condition with flag_sanitize_p also with current_function_decl non-null equality. (ubsan_maybe_instrument_reference_or_call): Likewise. 2017-07-31 Martin Liska PR sanitize/81530 * g++.dg/ubsan/pr81530.C: New test. From-SVN: r250730 --- gcc/c/c-convert.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/c/c-convert.c') diff --git a/gcc/c/c-convert.c b/gcc/c/c-convert.c index 33c9143..bc64917 100644 --- a/gcc/c/c-convert.c +++ b/gcc/c/c-convert.c @@ -108,6 +108,7 @@ convert (tree type, tree expr) case INTEGER_TYPE: case ENUMERAL_TYPE: if (sanitize_flags_p (SANITIZE_FLOAT_CAST) + && current_function_decl != NULL_TREE && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE && COMPLETE_TYPE_P (type)) { -- cgit v1.1