From: Immad Mir <mirimmad@outlook.com>
To: gcc-patches@gcc.gnu.org
Cc: dmalcolm@redhat.com, mirimnan017@gmail.com,
Immad Mir <mirimmad@outlook.com>
Subject: [PATCH 3/3] analyzer: add a new testcase to demonstrate passsing of a file descriptor to a function that does not emit any warning
Date: Wed, 6 Jul 2022 19:55:43 +0530 [thread overview]
Message-ID: <CY4PR1801MB1910CCF78855681CBB47335AC6809@CY4PR1801MB1910.namprd18.prod.outlook.com> (raw)
In-Reply-To: <20220706142543.3790-1-mirimmad@outlook.com>
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/fd-4.c: Add a new testcase to demonstrate passsing
of a file descriptor to a function that does not emit any warning.
Signed-off-by: Immad Mir <mirimmad@outlook.com>
---
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
--
2.25.1
next prev parent reply other threads:[~2022-07-06 14:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220706142543.3790-1-mirimmad@outlook.com>
2022-07-06 14:25 ` [PATCH 2/3] analyzer: reorder initialization of state m_invalid in sm-fd.cc [PR106184] Immad Mir
2022-07-06 15:29 ` David Malcolm
2022-07-06 14:25 ` Immad Mir [this message]
2022-07-06 15:37 ` [PATCH 3/3] analyzer: add a new testcase to demonstrate passsing of a file descriptor to a function that does not emit any warning David Malcolm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CY4PR1801MB1910CCF78855681CBB47335AC6809@CY4PR1801MB1910.namprd18.prod.outlook.com \
--to=mirimmad@outlook.com \
--cc=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mirimnan017@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).