| 1 |
/* Simplified version of test for ensuring we issue a FILE * leak diagnostic, |
| 2 |
made trivial. |
| 3 |
Adapted from intl/localealias.c, with all #includes removed. */ |
| 4 |
|
| 5 |
/* { dg-do "compile" } */ |
| 6 |
|
| 7 |
/* Handle aliases for locale names. |
| 8 |
Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. |
| 9 |
|
| 10 |
This program is free software; you can redistribute it and/or modify it |
| 11 |
under the terms of the GNU Library General Public License as published |
| 12 |
by the Free Software Foundation; either version 2, or (at your option) |
| 13 |
any later version. |
| 14 |
|
| 15 |
This program is distributed in the hope that it will be useful, |
| 16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 |
Library General Public License for more details. |
| 19 |
|
| 20 |
You should have received a copy of the GNU Library General Public |
| 21 |
License along with this program; if not, write to the Free Software |
| 22 |
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, |
| 23 |
USA. */ |
| 24 |
|
| 25 |
/* Minimal version of system headers. */ |
| 26 |
#define NULL ((void *) 0) |
| 27 |
typedef struct _IO_FILE FILE; |
| 28 |
extern FILE *fopen(const char *__restrict __filename, |
| 29 |
const char *__restrict __modes); |
| 30 |
extern int fclose(FILE *__stream); |
| 31 |
|
| 32 |
void |
| 33 |
read_alias_file (int flag) |
| 34 |
{ |
| 35 |
FILE *fp; |
| 36 |
|
| 37 |
fp = fopen ("name", "r"); /* { dg-message "opened here" } */ |
| 38 |
if (fp == NULL) |
| 39 |
return; |
| 40 |
|
| 41 |
if (flag) |
| 42 |
return; /* { dg-warning "leak of FILE 'fp'" } */ |
| 43 |
|
| 44 |
fclose (fp); |
| 45 |
} |