Backported from mainline
2018-06-20 Jakub Jelinek <jakub@redhat.com>
PR c++/86210
* c-common.c (check_nonnull_arg): Use fold_for_warn. Adjust obsolete
comment.
* g++.dg/warn/Wnonnull4.C: New test.
From-SVN: r262102
2018-06-25 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
+ 2018-06-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/86210
+ * c-common.c (check_nonnull_arg): Use fold_for_warn. Adjust obsolete
+ comment.
+
2017-11-21 Jakub Jelinek <jakub@redhat.com>
PR c++/83059
if (TREE_CODE (TREE_TYPE (param)) != POINTER_TYPE)
return;
- if (integer_zerop (param))
+ if (integer_zerop (fold_for_warn (param)))
warning_at (*ploc, OPT_Wnonnull, "null argument where non-null required "
"(argument %lu)", (unsigned long) param_num);
}
Backported from mainline
2018-06-20 Jakub Jelinek <jakub@redhat.com>
+ PR c++/86210
+ * g++.dg/warn/Wnonnull4.C: New test.
+
PR tree-optimization/86231
* gcc.dg/tree-ssa/vrp119.c: New test.
* gcc.c-torture/execute/pr86231.c: New test.
--- /dev/null
+// PR c++/86210
+// { dg-do compile }
+// { dg-options "-Wnonnull" }
+
+void *declared_not_defined (void *p) __attribute__((nonnull));
+
+inline void *declared_and_defined (void *p) __attribute__((nonnull));
+
+int
+main ()
+{
+ int *const p = 0;
+ declared_not_defined (p); // { dg-warning "null argument where non-null required" }
+ declared_and_defined (p); // { dg-warning "null argument where non-null required" }
+}
+
+void *
+declared_and_defined (void *p)
+{
+ return p;
+}