aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.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-decl.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-decl.c')
-rw-r--r--gcc/c/c-decl.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 12fbc18..a54e121 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -6052,6 +6052,7 @@ grokdeclarator (const struct c_declarator *declarator,
this_size_varies = size_varies = true;
warn_variable_length_array (name, size);
if (sanitize_flags_p (SANITIZE_VLA)
+ && current_function_decl != NULL_TREE
&& decl_context == NORMAL)
{
/* Evaluate the array size only once. */