aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.h
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2020-09-19 17:37:05 -0600
committerMartin Sebor <msebor@redhat.com>2020-09-19 17:37:05 -0600
commitbaad4c48a85a354d2bf1b17e5aff71203c08adea (patch)
treeb29b89090fb1eb5436ff4183d0b11ba2dc765a4a /gcc/builtins.h
parent72be80e47d059f33ff11f5015b9494c42b4e0a12 (diff)
downloadgcc-baad4c48a85a354d2bf1b17e5aff71203c08adea.zip
gcc-baad4c48a85a354d2bf1b17e5aff71203c08adea.tar.gz
gcc-baad4c48a85a354d2bf1b17e5aff71203c08adea.tar.bz2
Extend -Wstringop-overflow to detect out-of-bounds accesses to array parameters.
gcc/ChangeLog: PR c/50584 * builtins.c (warn_for_access): Add argument. Distinguish between reads and writes. (check_access): Add argument. Distinguish between reads and writes. (gimple_call_alloc_size): Set range even on failure. (gimple_parm_array_size): New function. (compute_objsize): Call it. (check_memop_access): Pass check_access an additional argument. (expand_builtin_memchr, expand_builtin_strcat): Same. (expand_builtin_strcpy, expand_builtin_stpcpy_1): Same. (expand_builtin_stpncpy, check_strncat_sizes): Same. (expand_builtin_strncat, expand_builtin_strncpy): Same. (expand_builtin_memcmp): Same. * builtins.h (compute_objsize): Declare a new overload. (gimple_parm_array_size): Declare. (check_access): Add argument. * calls.c (append_attrname): Simplify. (maybe_warn_rdwr_sizes): Handle internal attribute access. * tree-ssa-uninit.c (maybe_warn_pass_by_reference): Avoid adding quotes. gcc/testsuite/ChangeLog: PR c/50584 * c-c++-common/Wsizeof-pointer-memaccess1.c: Disable new expected warnings. * g++.dg/ext/attr-access.C: Update text of expected warnings. * gcc.dg/Wstringop-overflow-23.c: Same. * gcc.dg/Wstringop-overflow-24.c: Same. * gcc.dg/attr-access-none.c: Same. * gcc.dg/dfp/composite-type.c: Prune expected warnings. * gcc.dg/torture/pr57147-1.c: Add a member to an otherwise empty struct to avoid a warning. * gcc.dg/torture/pr57147-3.c: Same. * gcc.dg/Warray-bounds-30.c: Adjust. * gcc.dg/attr-access-none.c: Same. * gcc.dg/Wstringop-overflow-40.c: New test. * gcc.dg/attr-access-2.c: New test.
Diffstat (limited to 'gcc/builtins.h')
-rw-r--r--gcc/builtins.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/gcc/builtins.h b/gcc/builtins.h
index 94ff96b..8136b76 100644
--- a/gcc/builtins.h
+++ b/gcc/builtins.h
@@ -133,13 +133,6 @@ extern tree fold_call_stmt (gcall *, bool);
extern void set_builtin_user_assembler_name (tree decl, const char *asmspec);
extern bool is_simple_builtin (tree);
extern bool is_inexpensive_builtin (tree);
-
-class vr_values;
-tree gimple_call_alloc_size (gimple *, wide_int[2] = NULL,
- const vr_values * = NULL);
-extern tree compute_objsize (tree, int, tree * = NULL, tree * = NULL,
- const vr_values * = NULL);
-
extern bool readonly_data_expr (tree exp);
extern bool init_target_chars (void);
extern unsigned HOST_WIDE_INT target_newline;
@@ -202,7 +195,15 @@ struct access_data
access_mode mode;
};
-extern bool check_access (tree, tree, tree, tree, tree,
- access_mode, const access_data * = NULL);
+class vr_values;
+extern tree gimple_call_alloc_size (gimple *, wide_int[2] = NULL,
+ const vr_values * = NULL);
+extern tree gimple_parm_array_size (tree, wide_int[2], const vr_values * = NULL);
+extern tree compute_objsize (tree, int, tree * = NULL, tree * = NULL,
+ const vr_values * = NULL);
+extern tree compute_objsize (tree, int, access_ref *, const vr_values * = NULL);
+
+extern bool check_access (tree, tree, tree, tree, tree, access_mode,
+ const access_data * = NULL);
#endif /* GCC_BUILTINS_H */