aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2014-06-30 13:15:20 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2014-06-30 13:15:20 +0000
commit6a7253a4a9d6087827414eeee7036d9eb4b1e472 (patch)
treed9fbba8c55ca2e01e66ea39234d507306dac9bed /gcc/c
parent670d96d7307b8cfa23000c050fe35c1298301cb4 (diff)
downloadgcc-6a7253a4a9d6087827414eeee7036d9eb4b1e472.zip
gcc-6a7253a4a9d6087827414eeee7036d9eb4b1e472.tar.gz
gcc-6a7253a4a9d6087827414eeee7036d9eb4b1e472.tar.bz2
convert.c (convert_to_integer): Don't instrument conversions if the function has no_sanitize_undefined attribute.
* convert.c (convert_to_integer): Don't instrument conversions if the function has no_sanitize_undefined attribute. * ubsan.c: Don't run the ubsan pass if the function has no_sanitize_undefined attribute. c/ * c-decl.c (grokdeclarator): Don't instrument VLAs if the function has no_sanitize_undefined attribute. cp/ * cp-gimplify.c (cp_genericize): Don't instrument returns if the function has no_sanitize_undefined attribute. * decl.c (compute_array_index_type): Don't instrument VLAs if the function has no_sanitize_undefined attribute. testsuite/ * c-c++-common/ubsan/attrib-2.c: New test. * g++.dg/ubsan/return-3.C: New test. From-SVN: r212148
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog5
-rw-r--r--gcc/c/c-decl.c6
2 files changed, 10 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 02a0f2f..6740d51 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-30 Marek Polacek <polacek@redhat.com>
+
+ * c-decl.c (grokdeclarator): Don't instrument VLAs if the function
+ has no_sanitize_undefined attribute.
+
2014-06-30 Igor Zamyatin <igor.zamyatin@intel.com>
PR middle-end/57541
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index def10a2..7c37edf 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -5505,7 +5505,11 @@ grokdeclarator (const struct c_declarator *declarator,
this_size_varies = size_varies = true;
warn_variable_length_array (name, size);
if (flag_sanitize & SANITIZE_VLA
- && decl_context == NORMAL)
+ && decl_context == NORMAL
+ && current_function_decl != NULL_TREE
+ && !lookup_attribute ("no_sanitize_undefined",
+ DECL_ATTRIBUTES
+ (current_function_decl)))
{
/* Evaluate the array size only once. */
size = c_save_expr (size);