From 6a7253a4a9d6087827414eeee7036d9eb4b1e472 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 30 Jun 2014 13:15:20 +0000 Subject: 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 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-decl.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc/c') 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 + + * c-decl.c (grokdeclarator): Don't instrument VLAs if the function + has no_sanitize_undefined attribute. + 2014-06-30 Igor Zamyatin 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); -- cgit v1.1