public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-1541] analyzer: add testcase of using closed fd without warning.
@ 2022-07-06 16:46 Immad Mir
0 siblings, 0 replies; only message in thread
From: Immad Mir @ 2022-07-06 16:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:acb696b792eeab92167f516b5236ed9242e62deb
commit r13-1541-gacb696b792eeab92167f516b5236ed9242e62deb
Author: Immad Mir <mirimmad@outlook.com>
Date: Wed Jul 6 21:38:27 2022 +0530
analyzer: add testcase of using closed fd without warning.
This patch adds a testcase for passing a closed fd to a function
that does not emit any warning.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fd-4.c: Add a new testcase to demonstrate
passsing of a closed file descriptor to a function that does
not emit any warning.
Signed-off-by: Immad Mir <mirimmad@outlook.com>
Diff:
---
gcc/testsuite/gcc.dg/analyzer/fd-4.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/analyzer/fd-4.c b/gcc/testsuite/gcc.dg/analyzer/fd-4.c
index c992db619e7..fcfa6168efa 100644
--- a/gcc/testsuite/gcc.dg/analyzer/fd-4.c
+++ b/gcc/testsuite/gcc.dg/analyzer/fd-4.c
@@ -1,3 +1,5 @@
+#include <stdio.h>
+
int open(const char *, int mode);
void close(int fd);
int write (int fd, void *buf, int nbytes);
@@ -60,3 +62,11 @@ test_4 (const char *path, void *buf)
/* {dg-message "\\(3\\) 'write' on closed file descriptor 'fd'; 'close' was at \\(2\\)" "" {target *-*-*} .-1 } */
}
}
+
+void
+test_5 (const char *path)
+{
+ int fd = open (path, O_RDWR);
+ close(fd);
+ printf("%d", fd); /* { dg-bogus "'printf' on a closed file descriptor 'fd'" } */
+}
\ No newline at end of file
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-06 16:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06 16:46 [gcc r13-1541] analyzer: add testcase of using closed fd without warning Immad Mir
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).