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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |msebor at gcc dot 
gnu.org
   Last reconfirmed|2017-12-30 00:00:00         |2021-4-2
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=31279
      Known to fail|                            |10.2.0, 11.0, 8.3.0, 9.3.0
   Target Milestone|---                         |12.0
             Status|NEW                         |ASSIGNED

--- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> ---
Pr31279 asks for a warning for a warning for call-by-reference arguments with
known intent(in).  This is the converse, but as I mentioned in pr31279 comment
#7 the middle end infrastructure to issue these warnings is in place.  The
Fortran front end needs to make use of it.

That being said, detecting read accesses to write-only arguments within the
annotated function itself isn't implemented yet (only passing uninitialized
arguments to read-only arguments is).  So I suggest tracking the Fortran
changes in pr31279 and the missing middle-end support here.

$ cat z.c && gcc -S -Wall z.c
__attribute__ ((access (read_only, 1)))
void f1 (int *);

void f2 (void)
{
  int i;
  f1 (&i);         // -Wuninitialized (good)
}

__attribute__ ((access (write_only, 1)))
int g1 (int *p)
{
  return *p;       // missing warning
}

z.c: In function ‘f2’:
z.c:7:3: warning: ‘i’ is used uninitialized [-Wuninitialized]
    7 |   f1 (&i);         // -Wuninitialized (good)
      |   ^~~~~~~
z.c:2:6: note: in a call to ‘f1’ declared with attribute ‘access (read_only,
1)’ here
    2 | void f1 (int *);
      |      ^~
z.c:6:7: note: ‘i’ declared here
    6 |   int i;
      |       ^

Reply via email to