(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
analyzer/
pr99716-1.c
       1  typedef struct FILE   FILE;
       2  
       3  FILE* fopen (const char*, const char*);
       4  int   fclose (FILE*);
       5  int fprintf (FILE *, const char *, ...);
       6  
       7  #define NULL ((void *)0)
       8  
       9  void
      10  test_1 (void)
      11  {
      12    int i;
      13  
      14    for (i = 0; i < 2; ++i) {
      15      FILE *fp = fopen ("/tmp/test", "w");
      16      fprintf (fp, "hello:%s ", "world");
      17      fclose (fp); /* { dg-bogus "double 'fclose'" } */
      18    }
      19  }
      20  
      21  void
      22  test_2 (void)
      23  {
      24    int i;
      25  
      26    for (i = 0; i < 2; ++i) {
      27      FILE *fp = fopen ("/tmp/test", "w");
      28      fprintf (fp, "hello");
      29    }
      30  } /* { dg-warning "leak of FILE 'fp'" } */
      31  
      32  FILE *fp3;
      33  
      34  void
      35  test_3 (FILE **fpp)
      36  {
      37    int i;
      38  
      39    for (i = 0; i < 2; ++i) {
      40      *fpp = fopen ("/tmp/test", "w");
      41      fprintf (*fpp, "hello");
      42      fclose (*fpp); /* { dg-bogus "double 'fclose'" } */
      43      *fpp = NULL;
      44    }
      45  }