aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-convert.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2017-07-31 10:53:00 +0200
committerMartin Liska <marxin@gcc.gnu.org>2017-07-31 08:53:00 +0000
commitf34ebeb25ef25e5937f60b7e6115c3f693a12ac3 (patch)
treebbf935d2f3780cbc507657f93feae23ae87fbd39 /gcc/c/c-convert.c
parent066bbc5721fbda2affe061fc4025a622bf30d5b5 (diff)
downloadgcc-f34ebeb25ef25e5937f60b7e6115c3f693a12ac3.zip
gcc-f34ebeb25ef25e5937f60b7e6115c3f693a12ac3.tar.gz
gcc-f34ebeb25ef25e5937f60b7e6115c3f693a12ac3.tar.bz2
Do UBSAN sanitization just when current_function_decl != NULL_TREE (PR sanitize/81530).
2017-07-31 Martin Liska <mliska@suse.cz> 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 <mliska@suse.cz> 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 <mliska@suse.cz> 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 <mliska@suse.cz> 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 <mliska@suse.cz> PR sanitize/81530 * g++.dg/ubsan/pr81530.C: New test. From-SVN: r250730
Diffstat (limited to 'gcc/c/c-convert.c')
-rw-r--r--gcc/c/c-convert.c1
1 files changed, 1 insertions, 0 deletions
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))
{