From 63de18a76af433048cc3a869062002819d472fbb Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Tue, 24 Sep 2019 19:44:02 +0100
Subject: [PATCH 118/124] FIXME: precision-of-wording for
 -Wanalyzer-possible-null-dereference

---
 gcc/analyzer/sm-malloc.cc                                    |  2 +-
 .../gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-2.c |  2 +-
 .../gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-3.c |  2 +-
 gcc/testsuite/gcc.dg/analyzer/malloc-1.c                     | 12 ++++++------
 gcc/testsuite/gcc.dg/analyzer/malloc-2.c                     |  2 +-
 gcc/testsuite/gcc.dg/analyzer/malloc-ipa-1.c                 |  4 ++--
 gcc/testsuite/gcc.dg/analyzer/malloc-ipa-5.c                 |  6 +++---
 gcc/testsuite/gcc.dg/analyzer/malloc-ipa-8-unchecked.c       |  4 ++--
 gcc/testsuite/gcc.dg/analyzer/malloc-paths-3.c               |  2 +-
 gcc/testsuite/gcc.dg/analyzer/malloc-paths-9.c               |  4 ++--
 gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-4.c            |  2 +-
 11 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index 78ad633..aece3a1 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -262,7 +262,7 @@ public:
     metadata m;
     m.add_cwe (690);
     warning_at (rich_loc, m, OPT_Wanalyzer_possible_null_dereference,
-		"use of possibly-NULL %qE", m_arg);
+		"dereference of possibly-NULL %qE", m_arg);
   }
 
   /* FIXME.  */
diff --git a/gcc/testsuite/gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-2.c b/gcc/testsuite/gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-2.c
index 3622c4b..b925a0e 100644
--- a/gcc/testsuite/gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-2.c
@@ -4,7 +4,7 @@ void test_2 (void)
 {
   void *p = malloc (10);
   char *buf1 = (char*)p;
-  buf1[0] = 'a'; /* { dg-warning "use of possibly-NULL 'buf1'" } */
+  buf1[0] = 'a'; /* { dg-warning "dereference of possibly-NULL 'buf1'" } */
 
   int *buf2 = (int*)p;
   buf2[0] = 0;
diff --git a/gcc/testsuite/gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-3.c b/gcc/testsuite/gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-3.c
index 005ebbd..11d9fa5 100644
--- a/gcc/testsuite/gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-3.c
+++ b/gcc/testsuite/gcc.dg/analyzer/NOT_FOR_UPSTREAM-clang-paper-example-3.c
@@ -14,7 +14,7 @@ void test_3 (void)
   struct s2 *sp;
   int a[2];
   sp = malloc(sizeof(struct s2)); /* { dg-message "allocated here" } */
-  sp->p = &data; /* { dg-warning "use of possibly-NULL 'sp'" } */
+  sp->p = &data; /* { dg-warning "dereference of possibly-NULL 'sp'" } */
   sp->p->d = 3;
   a[1] = data.d;
   __analyzer_eval (a[1] == 3); /* { dg-warning "TRUE" } */
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
index 6983b2f..5505e1c 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-1.c
@@ -22,7 +22,7 @@ void test_2 (void *ptr)
 int *test_3 (void)
 {
   int *ptr = (int *)malloc (sizeof (int));
-  *ptr = 42; /* { dg-warning "use of possibly-NULL 'ptr'" } */
+  *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
   return ptr;
 }
 
@@ -245,7 +245,7 @@ void test_22 (void)
 int *test_23 (int n)
 {
   int *ptr = (int *)calloc (n, sizeof (int));
-  ptr[0] = 42; /* { dg-warning "use of possibly-NULL 'ptr'" } */
+  ptr[0] = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
   return ptr;
 }
 
@@ -280,7 +280,7 @@ struct coord {
 struct coord *test_27 (void)
 {
   struct coord *p = (struct coord *) malloc (sizeof (struct coord)); /* { dg-message "this call could return NULL" } */
-  p->x = 0.f;  /* { dg-warning "use of possibly-NULL 'p'" } */
+  p->x = 0.f;  /* { dg-warning "dereference of possibly-NULL 'p'" } */
 
   /* Only the first such usage should be reported: */
   p->y = 0.f;
@@ -428,7 +428,7 @@ int *
 test_39 (int i)
 {
   int *p = (int*)malloc(sizeof(int*)); /* { dg-message "this call could return NULL" } */
-  *p = i; /* { dg-warning "use of possibly-NULL 'p'" } */
+  *p = i; /* { dg-warning "dereference of possibly-NULL 'p'" } */
   return p;
 }
 
@@ -436,7 +436,7 @@ int *
 test_40 (int i)
 {
   int *p = (int*)malloc(sizeof(int*));
-  i = *p; /* { dg-warning "use of possibly-NULL 'p'" } */
+  i = *p; /* { dg-warning "dereference of possibly-NULL 'p'" } */
   /* TODO: (it's also uninitialized) */
   return p;
 }
@@ -452,7 +452,7 @@ test_41 (int flag)
     buffer = NULL;
   }
 
-  buffer[0] = 'a'; /* { dg-warning "use of possibly-NULL 'buffer'" } */
+  buffer[0] = 'a'; /* { dg-warning "dereference of possibly-NULL 'buffer'" } */
   /* { dg-warning "dereference of NULL 'buffer'" "" { target *-*-* } .-1 } */
 
   return buffer;
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-2.c b/gcc/testsuite/gcc.dg/analyzer/malloc-2.c
index b197aeb..6d073f5 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-2.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-2.c
@@ -17,7 +17,7 @@ void test_1 (void)
 int *test_2 (void)
 {
   int *i = malloc (sizeof (int)); /* { dg-message "\\(1\\) this call could return NULL" } */
-  *i = 42; /* { dg-warning "use of possibly-NULL 'i'" } */
+  *i = 42; /* { dg-warning "dereference of possibly-NULL 'i'" } */
   /* { dg-message "\\(2\\) 'i' could be NULL: unchecked value from \\(1\\)" "" { target *-*-* } .-1 } */
   return i; 
 }
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-1.c b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-1.c
index a8009b9..ad536ce 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-1.c
@@ -10,7 +10,7 @@ calls_malloc (void)
 int *test_1 (int i)
 {
   int *ptr = (int *)calls_malloc ();
-  *ptr = i; /* { dg-warning "use of possibly-NULL 'ptr'" } */
+  *ptr = i; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
   return ptr;
 }
 
@@ -19,6 +19,6 @@ int *test_1 (int i)
 int *test_2 (int i)
 {
   int *ptr = (int *)calls_malloc ();
-  *ptr = i; /* { dg-warning "use of possibly-NULL 'ptr'" } */
+  *ptr = i; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
   return ptr;
 }
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-5.c b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-5.c
index b70e7cf..c66ecb5 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-5.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-5.c
@@ -7,7 +7,7 @@ static int *calls_malloc(void)
 
 int *test(void)
 {
-    int *p = calls_malloc();
-    *p = 42; /* { dg-warning "use of possibly-NULL 'p'" } */
-    return p;
+  int *p = calls_malloc(); /* { dg-message "possible return of NULL to 'test' from 'calls_malloc'" } */
+  *p = 42; /* { dg-warning "dereference of possibly-NULL 'p'" } */
+  return p;
 }
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-8-unchecked.c b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-8-unchecked.c
index d439e87..67aa120 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-8-unchecked.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-ipa-8-unchecked.c
@@ -21,11 +21,11 @@ boxed_int *
 make_boxed_int (int i)
 {
   boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
-  result->i = i; /* { dg-warning "use of possibly-NULL 'result'" } */
+  result->i = i; /* { dg-warning "dereference of possibly-NULL 'result'" } */
   return result;
 }
 
-/* "use of possibly-NULL 'result' [CWE-690]".  */
+/* "dereference of possibly-NULL 'result' [CWE-690]".  */
 /* { dg-begin-multiline-output "" }
   'make_boxed_int': events 1-2
           |
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-3.c b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-3.c
index 1bd4535..ed60260 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-3.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-3.c
@@ -8,7 +8,7 @@ int *test_3 (void)
   *ptr = 42; /* { dg-line unchecked_deref } */
   return ptr;
 
-  /* { dg-warning "use of possibly-NULL 'ptr'" "" { target *-*-* } unchecked_deref } */
+  /* { dg-warning "dereference of possibly-NULL 'ptr'" "" { target *-*-* } unchecked_deref } */
   /* { dg-message "\\(1\\) this call could return NULL" "" { target *-*-* } malloc } */
   /* { dg-message "\\(2\\) 'ptr' could be NULL" "" { target *-*-* } unchecked_deref } */
 }
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-9.c b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-9.c
index 5870d39..b454bbc 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-paths-9.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-paths-9.c
@@ -94,7 +94,7 @@ void test_2 (int x, int y)
 int test_3 (int x, int y)
 {
   int *ptr = (int *)malloc (sizeof (int));
-  *ptr = 42; /* { dg-warning "use of possibly-NULL 'ptr'" } */
+  *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
   if (x)
     free (ptr);
 
@@ -111,7 +111,7 @@ int test_3 (int x, int y)
   /* { dg-warning "leak of 'ptr'" "" { target *-*-* } .-3 } */
 }
 
-/* "use of possibly-NULL 'ptr'".  */
+/* "dereference of possibly-NULL 'ptr'".  */
 /* { dg-begin-multiline-output "" }
   'test_3': events 1-2
       |
diff --git a/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-4.c b/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-4.c
index c5520f0..d389616 100644
--- a/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-4.c
+++ b/gcc/testsuite/gcc.dg/analyzer/malloc-vs-local-4.c
@@ -2,7 +2,7 @@
 
 void __attribute__((noinline)) callee_1 (int *ptr)
 {
-  *ptr = 42; /* { dg-warning "use of possibly-NULL 'ptr'" } */
+  *ptr = 42; /* { dg-warning "dereference of possibly-NULL 'ptr'" } */
 }
 
 int test_1 (int i, int flag)
-- 
1.8.5.3

