From: Martin Sebor Date: Fri, 10 Jan 2020 17:04:00 +0000 (+0000) Subject: PR c/93132 - bogus 'attribute((access))' warning when size-index is specified X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f25e33fa1b62a6f6c8dddf8e6a7961fae6847a0e;p=gcc.git PR c/93132 - bogus 'attribute((access))' warning when size-index is specified gcc/c-family/ChangeLog: PR c/93132 * c-attribs.c (append_access_attrs): Validate against the translated access string rather than the human-readable representation. gcc/testsuite/ChangeLog: PR c/93132 * gcc.dg/attr-access-read-only-2.c: New test. From-SVN: r280124 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ca6609ff4d2..5448acf2f7b 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2020-01-10 Martin Sebor + + PR c/93132 + * c-attribs.c (append_access_attrs): Validate against the translated + access string rather than the human-readable representation. + 2020-01-01 Jakub Jelinek Update copyright years. diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index 77649e839c9..dc9579c5c60 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -3970,14 +3970,15 @@ append_access_attrs (tree t, tree attrs, const char *attrstr, return NULL_TREE; } - if (n2 && strncmp (attrstr + n1 + 1, pos + n1, n2)) + if (n2 && strncmp (attrspec + n1 + 1, pos + n1, n2)) { /* Mismatch in the value of the size argument. */ auto_diagnostic_group d; if (warning (OPT_Wattributes, - "attribute %qs mismatch positional argument " + "attribute %qs mismatched positional argument " "values %i and %i", - attrstr, atoi (attrstr + n1 + 1), atoi (pos + n1)) + attrstr, atoi (attrspec + n1 + 1) + 1, + atoi (pos + n1) + 1) && DECL_P (t)) inform (DECL_SOURCE_LOCATION (t), "previous declaration here"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8dc47ea6c93..4c7a61591a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-10 Martin Sebor + + PR c/93132 + * gcc.dg/attr-access-read-only-2.c: New test. + 2020-01-10 Richard Sandiford * gcc.target/aarch64/sve/sel_1.c: Use SVE types for the arguments and diff --git a/gcc/testsuite/gcc.dg/attr-access-read-only-2.c b/gcc/testsuite/gcc.dg/attr-access-read-only-2.c new file mode 100644 index 00000000000..d3069b04ec8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/attr-access-read-only-2.c @@ -0,0 +1,16 @@ +/* PR c/93132 - bogus 'attribute((access))' warning when size-index + is specified + { dg-do compile } + { dg-options "-Wall" } */ + +void __attribute__ ((access (read_only, 1, 5))) +f (void*, int, int, int, int); // { dg-message "previous declaration" } + +void __attribute__ ((access (read_only, 1, 3))) +f (void*, int, int, int, int); // { dg-warning "attribute 'access\\\(read_only, 1, 3\\\)' mismatched positional argument values 3 and 5" } + +void __attribute__ ((access (read_only, 1, 4))) +f (void*, int, int, int, int); // { dg-warning "attribute 'access\\\(read_only, 1, 4\\\)' mismatched positional argument values 4 and 5" } + +void __attribute__ ((access (read_only, 1, 5))) +f (void*, int, int, int, int);