public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/arsenic/heads/analyzer_extension)] deja test failing
@ 2021-07-15 11:11 Ankur saini
  0 siblings, 0 replies; only message in thread
From: Ankur saini @ 2021-07-15 11:11 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:01a88a14b0b5f34bfe106d7bcbf24714bc4d130a

commit 01a88a14b0b5f34bfe106d7bcbf24714bc4d130a
Author: Ankur Saini <arsenic@sourceware.org>
Date:   Thu Jul 15 16:41:01 2021 +0530

    deja test failing

Diff:
---
 gcc/testsuite/gcc.dg/analyzer/call-via-fnptr.c | 49 +++++++++++++++++++++-----
 gcc/testsuite/gcc.dg/analyzer/function-ptr-4.c | 22 ++++++++++++
 gcc/testsuite/gcc.dg/analyzer/pr100546.c       | 17 +++++++++
 gcc/testsuite/lib/prune.exp                    |  2 +-
 4 files changed, 81 insertions(+), 9 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/analyzer/call-via-fnptr.c b/gcc/testsuite/gcc.dg/analyzer/call-via-fnptr.c
index d0e1fc22108..29213e29312 100644
--- a/gcc/testsuite/gcc.dg/analyzer/call-via-fnptr.c
+++ b/gcc/testsuite/gcc.dg/analyzer/call-via-fnptr.c
@@ -3,18 +3,51 @@
 
 void fun(int *int_ptr)
 {
-    free(int_ptr);
+	free(int_ptr);  /* { dg-warning "double-‘free’ of ‘int_ptr’" } */
 }
 
-int test()
+void single_call()
 {
-    int *int_ptr = (int*)malloc(sizeof(int));
-    void (*fun_ptr)(int *) = &fun;
-    (*fun_ptr)(int_ptr);
-    return 0;
+	int *int_ptr = (int*)malloc(sizeof(int));
+	void (*fun_ptr)(int *) = &fun;
+	(*fun_ptr)(int_ptr);
 }
 
-void test_2()
+void double_call()
 {
-  test();
+	int *int_ptr = (int*)malloc(sizeof(int));
+	void (*fun_ptr)(int *) = &fun;
+	(*fun_ptr)(int_ptr);
+	(*fun_ptr)(int_ptr);
 }
+
+/*{ dg-begin-multiline-output "" }
+    6 |         free(int_ptr);
+      |         ^~~~~~~~~~~~~
+  ‘double_call’: events 1-2
+    |
+    |   16 | void double_call()
+    |      |      ^~~~~~~~~~~
+    |      |      |
+    |      |      (1) entry to ‘double_call’
+    |   17 | {
+    |   18 |         int *int_ptr = (int*)malloc(sizeof(int));
+    |      |                              ~~~~~~~~~~~~~~~~~~~
+    |      |                              |
+    |      |                              (2) allocated here
+    |
+    +--> ‘fun’: events 3-6
+           |
+           |    4 | void fun(int *int_ptr)
+           |      |      ^~~
+           |      |      |
+           |      |      (3) entry to ‘fun’
+           |      |      (5) entry to ‘fun’
+           |    5 | {
+           |    6 |         free(int_ptr);
+           |      |         ~~~~~~~~~~~~~
+           |      |         |
+           |      |         (4) first ‘free’ here
+           |      |         (6) second ‘free’ here; first ‘free’ was at (4)
+           |
+*/
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.dg/analyzer/function-ptr-4.c b/gcc/testsuite/gcc.dg/analyzer/function-ptr-4.c
new file mode 100644
index 00000000000..d4a51bff5d6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/function-ptr-4.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+void fun(int *int_ptr)
+{
+	free(int_ptr);
+}
+
+void single_call()
+{
+	int *int_ptr = (int*)malloc(sizeof(int));
+	void (*fun_ptr)(int *) = &fun;
+	(*fun_ptr)(int_ptr);
+}
+
+void double_call()
+{
+	int *int_ptr = (int*)malloc(sizeof(int));
+	void (*fun_ptr)(int *) = &fun;
+	(*fun_ptr)(int_ptr);
+	(*fun_ptr)(int_ptr);
+} /* { dg-warning "double-‘free’ of ‘int_ptr’" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr100546.c b/gcc/testsuite/gcc.dg/analyzer/pr100546.c
new file mode 100644
index 00000000000..3349d4067af
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr100546.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+static void noReturn(const char *str) __attribute__((noreturn));
+static void noReturn(const char *str) {
+    printf("%s\n", str);
+    exit(1);
+}
+
+void (*noReturnPtr)(const char *str) = &noReturn;
+
+int main(int argc, char **argv) {
+    char *str = 0;
+    if (!str)
+        noReturnPtr(__FILE__);
+    return printf("%c\n", *str);
+}
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index 91f165bec38..be5be201b18 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -32,7 +32,7 @@ set TEST_ALWAYS_FLAGS "-fdiagnostics-plain-output $TEST_ALWAYS_FLAGS"
 proc prune_gcc_output { text } {
     global srcdir
 
-    #send_user "Before:$text\n"
+    send_user "Before:$text\n"
 
     # Handle any freeform regexps.
     set text [handle-dg-regexps $text]


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-15 11:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 11:11 [gcc(refs/users/arsenic/heads/analyzer_extension)] deja test failing Ankur saini

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).