From: Martin Liska Date: Wed, 11 Oct 2017 12:31:59 +0000 (+0200) Subject: Do not error for no_sanitize attributes (PR sanitizer/82490). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a266bcd811d8fdf3e9ad9134c40324aafa1bac9;p=gcc.git Do not error for no_sanitize attributes (PR sanitizer/82490). 2017-10-11 Martin Liska PR sanitizer/82490 * opts.c (parse_no_sanitize_attribute): Do not use error_value variable. * opts.h (parse_no_sanitize_attribute): Remove last argument. 2017-10-11 Martin Liska PR sanitizer/82490 * c-attribs.c (handle_no_sanitize_attribute): Report directly Wattributes warning. 2017-10-11 Martin Liska PR sanitizer/82490 * c-c++-common/ubsan/attrib-5.c: New test. From-SVN: r253640 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 61ad754936c..7dba1098f6a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-10-11 Martin Liska + + PR sanitizer/82490 + * opts.c (parse_no_sanitize_attribute): Do not use error_value + variable. + * opts.h (parse_no_sanitize_attribute): Remove last argument. + 2017-10-11 Martin Liska * print-rtl.c (print_insn): Move declaration of idbuf diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index b63673035f4..51e1b771aad 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2017-10-11 Martin Liska + + PR sanitizer/82490 + * c-attribs.c (handle_no_sanitize_attribute): Report directly + Wattributes warning. + 2017-10-10 Richard Sandiford * c-ada-spec.c (dump_generic_ada_node): Use wi::to_wide when diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 4e6754fba20..bd8ca306c2d 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -613,15 +613,8 @@ handle_no_sanitize_attribute (tree *node, tree name, tree args, int, return NULL_TREE; } - char *error_value = NULL; char *string = ASTRDUP (TREE_STRING_POINTER (id)); - unsigned int flags = parse_no_sanitize_attribute (string, &error_value); - - if (error_value) - { - error ("wrong argument: \"%s\"", error_value); - return NULL_TREE; - } + unsigned int flags = parse_no_sanitize_attribute (string); add_no_sanitize_value (*node, flags); diff --git a/gcc/opts.c b/gcc/opts.c index 5aa5d066dbe..adf3d89851d 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1700,11 +1700,10 @@ parse_sanitizer_options (const char *p, location_t loc, int scode, } /* Parse string values of no_sanitize attribute passed in VALUE. - Values are separated with comma. Wrong argument is stored to - WRONG_ARGUMENT variable. */ + Values are separated with comma. */ unsigned int -parse_no_sanitize_attribute (char *value, char **wrong_argument) +parse_no_sanitize_attribute (char *value) { unsigned int flags = 0; unsigned int i; @@ -1722,7 +1721,8 @@ parse_no_sanitize_attribute (char *value, char **wrong_argument) } if (sanitizer_opts[i].name == NULL) - *wrong_argument = q; + warning (OPT_Wattributes, + "%<%s%> attribute directive ignored", q); q = strtok (NULL, ","); } diff --git a/gcc/opts.h b/gcc/opts.h index 2774e2c8b40..10938615725 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -390,7 +390,7 @@ extern void handle_common_deferred_options (void); unsigned int parse_sanitizer_options (const char *, location_t, int, unsigned int, int, bool); -unsigned int parse_no_sanitize_attribute (char *value, char **wrong_argument); +unsigned int parse_no_sanitize_attribute (char *value); extern bool common_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, const struct cl_decoded_option *decoded, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1f51a7217bc..04adb938767 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-11 Martin Liska + + PR sanitizer/82490 + * c-c++-common/ubsan/attrib-5.c: New test. + 2017-10-11 Martin Liska Revert r253637: diff --git a/gcc/testsuite/c-c++-common/ubsan/attrib-5.c b/gcc/testsuite/c-c++-common/ubsan/attrib-5.c new file mode 100644 index 00000000000..fee1df1c433 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/attrib-5.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-fsanitize=undefined" } */ + +__attribute__((no_sanitize("foobar"))) +static void +float_cast2 (void) +{ /* { dg-warning "attribute directive ignored" } */ + volatile double d = 300; + volatile signed char c; + c = d; +}