aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-family/c-common.c')
-rw-r--r--gcc/c-family/c-common.c70
1 files changed, 68 insertions, 2 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 532923c..ed72314 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -391,6 +391,9 @@ static tree handle_omp_declare_simd_attribute (tree *, tree, tree, int,
static tree handle_omp_declare_target_attribute (tree *, tree, tree, int,
bool *);
static tree handle_designated_init_attribute (tree *, tree, tree, int, bool *);
+static tree handle_bnd_variable_size_attribute (tree *, tree, tree, int, bool *);
+static tree handle_bnd_legacy (tree *, tree, tree, int, bool *);
+static tree handle_bnd_instrument (tree *, tree, tree, int, bool *);
static void check_function_nonnull (tree, int, tree *);
static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT);
@@ -623,7 +626,12 @@ const struct c_common_resword c_common_reswords[] =
const unsigned int num_c_common_reswords =
sizeof c_common_reswords / sizeof (struct c_common_resword);
-/* Table of machine-independent attributes common to all C-like languages. */
+/* Table of machine-independent attributes common to all C-like languages.
+
+ All attributes referencing arguments should be additionally processed
+ in chkp_copy_function_type_adding_bounds for correct instrumentation
+ by Pointer Bounds Checker.
+ Current list of processed common attributes: nonnull. */
const struct attribute_spec c_common_attribute_table[] =
{
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
@@ -790,12 +798,22 @@ const struct attribute_spec c_common_attribute_table[] =
handle_assume_aligned_attribute, false },
{ "designated_init", 0, 0, false, true, false,
handle_designated_init_attribute, false },
+ { "bnd_variable_size", 0, 0, true, false, false,
+ handle_bnd_variable_size_attribute, false },
+ { "bnd_legacy", 0, 0, true, false, false,
+ handle_bnd_legacy, false },
+ { "bnd_instrument", 0, 0, true, false, false,
+ handle_bnd_instrument, false },
{ NULL, 0, 0, false, false, false, NULL, false }
};
/* Give the specifications for the format attributes, used by C and all
- descendants. */
+ descendants.
+ All attributes referencing arguments should be additionally processed
+ in chkp_copy_function_type_adding_bounds for correct instrumentation
+ by Pointer Bounds Checker.
+ Current list of processed format attributes: format, format_arg. */
const struct attribute_spec c_common_format_attribute_table[] =
{
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
@@ -8258,6 +8276,54 @@ handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, tree ARG_UNUSED (name),
return NULL_TREE;
}
+/* Handle a "bnd_variable_size" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_bnd_variable_size_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FIELD_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "bnd_legacy" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_bnd_legacy (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "bnd_instrument" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_bnd_instrument (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
/* Handle a "warn_unused" attribute; arguments as in
struct attribute_spec.handler. */