aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-01-08 16:27:22 -0500
committerJason Merrill <jason@gcc.gnu.org>2015-01-08 16:27:22 -0500
commitf5481fc443060065cde9ed7bc6f3fd83bc1ecc4c (patch)
treecbafc576a2a3a432c0727f066088eb9aa5369156 /gcc/cp
parent46621807e9bf7bc94302cda27852e33a3c766112 (diff)
downloadgcc-f5481fc443060065cde9ed7bc6f3fd83bc1ecc4c.zip
gcc-f5481fc443060065cde9ed7bc6f3fd83bc1ecc4c.tar.gz
gcc-f5481fc443060065cde9ed7bc6f3fd83bc1ecc4c.tar.bz2
ubsan.c (do_ubsan_in_current_function): New.
gcc/ * ubsan.c (do_ubsan_in_current_function): New. (pass_ubsan::gate): Use it. * ubsan.h: Declare it. * convert.c (convert_to_integer): Use it. gcc/c-family/ * c-ubsan.c (ubsan_maybe_instrument_array_ref): Use do_ubsan_in_current_function. (ubsan_maybe_instrument_reference_or_call): Likewise. * c-ubsan.h: Declare it. gcc/cp/ * cp-gimplify.c (cp_genericize): Use do_ubsan_in_current_function. * decl.c (compute_array_index_type): Likewise. * init.c (build_vec_init): Likewise. * typeck.c (cp_build_binary_op): Likewise. From-SVN: r219360
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/cp-gimplify.c4
-rw-r--r--gcc/cp/decl.c5
-rw-r--r--gcc/cp/init.c5
-rw-r--r--gcc/cp/typeck.c4
5 files changed, 11 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 46d7957..8afaafa 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2015-01-08 Jason Merrill <jason@redhat.com>
+ * cp-gimplify.c (cp_genericize): Use do_ubsan_in_current_function.
+ * decl.c (compute_array_index_type): Likewise.
+ * init.c (build_vec_init): Likewise.
+ * typeck.c (cp_build_binary_op): Likewise.
+
+2015-01-08 Jason Merrill <jason@redhat.com>
+
* init.c (build_vec_init): Call ubsan_instrument_bounds to check
whether an initializer-list is too big for a VLA.
(throw_bad_array_length): Remove.
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index a23076f..33dce29 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1350,9 +1350,7 @@ cp_genericize (tree fndecl)
cp_genericize_tree (&DECL_SAVED_TREE (fndecl));
if (flag_sanitize & SANITIZE_RETURN
- && current_function_decl != NULL_TREE
- && !lookup_attribute ("no_sanitize_undefined",
- DECL_ATTRIBUTES (current_function_decl)))
+ && do_ubsan_in_current_function ())
cp_ubsan_maybe_instrument_return (fndecl);
/* Do everything else. */
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 65ccf77..dd000c3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -8595,10 +8595,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain)
stabilize_vla_size (itype);
if (flag_sanitize & SANITIZE_VLA
- && current_function_decl != NULL_TREE
- && !lookup_attribute ("no_sanitize_undefined",
- DECL_ATTRIBUTES
- (current_function_decl)))
+ && do_ubsan_in_current_function ())
{
/* We have to add 1 -- in the ubsan routine we generate
LE_EXPR rather than LT_EXPR. */
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 6f32492..3bd470b 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -3575,10 +3575,7 @@ build_vec_init (tree base, tree maxindex, tree init,
/* Don't check an array new when -fno-exceptions. */
}
else if (flag_sanitize & SANITIZE_BOUNDS
- && current_function_decl
- && !lookup_attribute ("no_sanitize_undefined",
- DECL_ATTRIBUTES
- (current_function_decl)))
+ && do_ubsan_in_current_function ())
{
/* Make sure the last element of the initializer is in bounds. */
finish_expr_stmt
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index b4af8b0..fb0ffd1 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4973,9 +4973,7 @@ cp_build_binary_op (location_t location,
if ((flag_sanitize & (SANITIZE_SHIFT | SANITIZE_DIVIDE
| SANITIZE_FLOAT_DIVIDE))
&& !processing_template_decl
- && current_function_decl != 0
- && !lookup_attribute ("no_sanitize_undefined",
- DECL_ATTRIBUTES (current_function_decl))
+ && do_ubsan_in_current_function ()
&& (doing_div_or_mod || doing_shift))
{
/* OP0 and/or OP1 might have side-effects. */