c-convert.c (convert): Make use of do_ubsan_in_current_function.
authorMarek Polacek <polacek@redhat.com>
Mon, 9 Mar 2015 11:57:33 +0000 (11:57 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 9 Mar 2015 11:57:33 +0000 (11:57 +0000)
* c-convert.c (convert): Make use of do_ubsan_in_current_function.
* c-decl.c (grokdeclarator): Likewise.
* c-typeck.c (build_binary_op): Likewise.

From-SVN: r221278

gcc/c/ChangeLog
gcc/c/c-convert.c
gcc/c/c-decl.c
gcc/c/c-typeck.c

index 7152fc0d6c1fb68d04c99c5a272c314748b78703..a5fcb35e32f2cfdcd858ed90a59e1608485d75c7 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-09  Marek Polacek  <polacek@redhat.com>
+
+       * c-convert.c (convert): Make use of do_ubsan_in_current_function.
+       * c-decl.c (grokdeclarator): Likewise.
+       * c-typeck.c (build_binary_op): Likewise.
+
 2015-02-27  Marek Polacek  <polacek@redhat.com>
 
        PR c/65228
index 2cb53f748d6aed3096f7e6f926adf3716dfea957..27fc3fc0e8edd1579dd704d32287468f8260053e 100644 (file)
@@ -121,9 +121,7 @@ convert (tree type, tree expr)
       if (flag_sanitize & SANITIZE_FLOAT_CAST
          && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
          && COMPLETE_TYPE_P (type)
-         && current_function_decl != NULL_TREE
-         && !lookup_attribute ("no_sanitize_undefined",
-                               DECL_ATTRIBUTES (current_function_decl)))
+         && do_ubsan_in_current_function ())
        {
          tree arg;
          if (in_late_binary_op)
index 749785801ee3aad5f092a8545c9d04bd584ef6fa..c140837f1392b33b5020ca0fe71111f126c390f0 100644 (file)
@@ -5837,10 +5837,7 @@ grokdeclarator (const struct c_declarator *declarator,
                    warn_variable_length_array (name, size);
                    if (flag_sanitize & SANITIZE_VLA
                        && decl_context == NORMAL
-                       && current_function_decl != NULL_TREE
-                       && !lookup_attribute ("no_sanitize_undefined",
-                                             DECL_ATTRIBUTES
-                                               (current_function_decl)))
+                       && do_ubsan_in_current_function ())
                      {
                        /* Evaluate the array size only once.  */
                        size = c_save_expr (size);
index a3a9c7760c72f8d39300116f9d1d3dcda730cf34..7c6d974a4867e5722662832c51f4b52a72c6ce8d 100644 (file)
@@ -11229,9 +11229,7 @@ build_binary_op (location_t location, enum tree_code code,
 
   if ((flag_sanitize & (SANITIZE_SHIFT | SANITIZE_DIVIDE
                        | SANITIZE_FLOAT_DIVIDE))
-      && 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.  */