+2018-06-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/86210
+ * c-common.c (check_nonnull_arg): Use fold_for_warn. Adjust obsolete
+ comment.
+
2018-06-18 Martin Sebor <msebor@redhat.com>
PR middle-end/85602
if (TREE_CODE (TREE_TYPE (param)) != POINTER_TYPE)
return;
- /* When not optimizing diagnose the simple cases of null arguments.
- When optimization is enabled defer the checking until expansion
- when more cases can be detected. */
- if (integer_zerop (param))
+ /* Diagnose the simple cases of null arguments. */
+ if (integer_zerop (fold_for_warn (param)))
{
warning_at (pctx->loc, OPT_Wnonnull, "null argument where non-null "
"required (argument %lu)", (unsigned long) param_num);
+2018-06-20 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/86210
+ * g++.dg/warn/Wnonnull4.C: New test.
+
2018-06-20 Marek Polacek <polacek@redhat.com>
PR c++/86240
--- /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;
+}