/cp
2012-03-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52718
* decl.c (check_default_argument): With -Wzero-as-null-pointer-constant
warn for a zero as null pointer constant default argument.
/testsuite
2012-03-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52718
* g++.dg/warn/Wzero-as-null-pointer-constant-5.C: New.
From-SVN: r185983
+2012-03-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/52718
+ * decl.c (check_default_argument): With -Wzero-as-null-pointer-constant
+ warn for a zero as null pointer constant default argument.
+
2012-03-29 Jason Merrill <jason@redhat.com>
PR c++/52685
return error_mark_node;
}
+ if (warn_zero_as_null_pointer_constant
+ && c_inhibit_evaluation_warnings == 0
+ && (POINTER_TYPE_P (decl_type) || TYPE_PTR_TO_MEMBER_P (decl_type))
+ && null_ptr_cst_p (arg)
+ && !NULLPTR_TYPE_P (TREE_TYPE (arg)))
+ {
+ warning (OPT_Wzero_as_null_pointer_constant,
+ "zero as null pointer constant");
+ return nullptr_node;
+ }
+
/* [dcl.fct.default]
Local variables shall not be used in default argument
+2012-03-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/52718
+ * g++.dg/warn/Wzero-as-null-pointer-constant-5.C: New.
+
2012-03-29 Jason Merrill <jason@redhat.com>
PR c++/52685
--- /dev/null
+// PR c++/52718
+// { dg-options "-Wzero-as-null-pointer-constant" }
+
+struct foo
+{
+ foo(void* a = 0) {}; // { dg-warning "zero as null pointer" }
+};
+
+void* fun(void* a = 0) {}; // { dg-warning "zero as null pointer" }
+
+struct bar: foo
+{
+ bar() {};
+};
+
+struct baz
+{
+ baz(const foo& f1 = foo(),
+ void* f2 = fun()) {};
+};