aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 4f1c818..5b6d39a 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -8912,6 +8912,29 @@ fold_builtin_memory_op (location_t loc, tree dest, tree src,
off0 = build_int_cst (build_pointer_type_for_mode (char_type_node,
ptr_mode, true), 0);
+ /* For -fsanitize={bool,enum} make sure the load isn't performed in
+ the bool or enum type. */
+ if (((flag_sanitize & SANITIZE_BOOL)
+ && TREE_CODE (desttype) == BOOLEAN_TYPE)
+ || ((flag_sanitize & SANITIZE_ENUM)
+ && TREE_CODE (desttype) == ENUMERAL_TYPE))
+ {
+ tree destitype
+ = lang_hooks.types.type_for_mode (TYPE_MODE (desttype),
+ TYPE_UNSIGNED (desttype));
+ desttype = build_aligned_type (destitype, TYPE_ALIGN (desttype));
+ }
+ if (((flag_sanitize & SANITIZE_BOOL)
+ && TREE_CODE (srctype) == BOOLEAN_TYPE)
+ || ((flag_sanitize & SANITIZE_ENUM)
+ && TREE_CODE (srctype) == ENUMERAL_TYPE))
+ {
+ tree srcitype
+ = lang_hooks.types.type_for_mode (TYPE_MODE (srctype),
+ TYPE_UNSIGNED (srctype));
+ srctype = build_aligned_type (srcitype, TYPE_ALIGN (srctype));
+ }
+
destvar = dest;
STRIP_NOPS (destvar);
if (TREE_CODE (destvar) == ADDR_EXPR