+2017-03-09 Marek Polacek <polacek@redhat.com>
+
+ PR c++/79962
+ PR c++/79984
+ * c-attribs.c (handle_nonnull_attribute): Save the result of default
+ conversion to the attribute list.
+
2017-03-09 Martin Liska <mliska@suse.cz>
* c-ada-spec.c (macro_length): Increment value instead of a pointer.
tree arg = TREE_VALUE (args);
if (arg && TREE_CODE (arg) != IDENTIFIER_NODE
&& TREE_CODE (arg) != FUNCTION_DECL)
- arg = default_conversion (arg);
+ TREE_VALUE (args) = arg = default_conversion (arg);
if (!get_nonnull_operand (arg, &arg_num))
{
+2017-03-09 Marek Polacek <polacek@redhat.com>
+
+ PR c++/79962
+ PR c++/79984
+ * c-c++-common/nonnull-3.c: New test.
+ * g++.dg/warn/Wnonnull3.C: New test.
+
2017-03-09 Matthew Fortune <matthew.fortune@imgtec.com>
* gcc.target/mips/lxc1-sxc1-1.c: Use -mhard-float.
--- /dev/null
+/* PR c++/79984 */
+/* { dg-do compile } */
+/* { dg-options "-Wnonnull-compare" } */
+
+enum { r = 1 };
+
+__attribute__ ((nonnull (r))) int
+f (int *p)
+{
+ return p == 0; /* { dg-warning "nonnull argument 'p' compared to NULL" } */
+}
--- /dev/null
+// PR c++/79962
+// { dg-options "-Wnonnull" }
+
+template <class T>
+__attribute__ ((__nonnull__ (T::i))) void f (typename T::U) { }
+
+struct S1 { enum { i = 1 }; typedef void* U; };
+struct S2 { static const int i = 1; typedef void* U; };
+
+void
+g ()
+{
+ f<S1>(0); // { dg-warning "null argument where non-null required" }
+ f<S2>(0); // { dg-warning "null argument where non-null required" }
+}