https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93132

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-01-07
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
I was able to reproduce a problem with the test case below, so confirmed. 
Thanks for pointing it out!  Your fix makes sense to me with one caveat:
Positional arguments are 1-based so I think the diagnostic needs to add 1 to
the atoi() result.  If you have a test case of your own please also add it the
patch (in addition to the one below if it they have different symptoms) and
post it to gcc-patches for review.  Alternatively, let me know if you would
prefer me to fix it.

$ cat pr93132.c && gcc -S -Wall  pr93132.c
/* 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);

void __attribute__ ((access (read_only, 1, 3)))
f (void*, int, int, int, int);   // { dg-warning "attribute
'access\\\(read_only, 1, 3\\\)' mismatch positional argument values 3 and 5" }
pr93132.c:10:1: warning: attribute ‘access(read_only, 1, 3)’ mismatch
positional argument values 3 and 5 [-Wattributes]
   10 | f (void*, int, int, int, int);   // { dg-warning "attribute
'access\\\(read_only, 1, 3\\\)' mismatch positional argument values 3 and 5" }
      | ^
pr93132.c:7:1: note: previous declaration here
    7 | f (void*, int, int, int, int);
      | ^

Reply via email to