===================================================================
@@ -4415,7 +4415,8 @@ cp_build_binary_op (location_t location,
&& decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)))
{
if ((complain & tf_warning)
- && c_inhibit_evaluation_warnings == 0)
+ && c_inhibit_evaluation_warnings == 0
+ && !TREE_NO_WARNING (op0))
warning (OPT_Waddress, "the address of %qD will never be NULL",
TREE_OPERAND (op0, 0));
}
@@ -4436,7 +4437,8 @@ cp_build_binary_op (location_t location,
&& decl_with_nonnull_addr_p (TREE_OPERAND (op1, 0)))
{
if ((complain & tf_warning)
- && c_inhibit_evaluation_warnings == 0)
+ && c_inhibit_evaluation_warnings == 0
+ && !TREE_NO_WARNING (op1))
warning (OPT_Waddress, "the address of %qD will never be NULL",
TREE_OPERAND (op1, 0));
}
@@ -4537,6 +4539,8 @@ cp_build_binary_op (location_t location,
op1 = save_expr (op1);
pfn0 = pfn_from_ptrmemfunc (op0);
+ /* Avoid -Waddress warnings (c++/64877). */
+ TREE_NO_WARNING (pfn0) = 1;
pfn1 = pfn_from_ptrmemfunc (op1);
delta0 = delta_from_ptrmemfunc (op0);
delta1 = delta_from_ptrmemfunc (op1);
===================================================================
@@ -0,0 +1,24 @@
+// PR c++/64877
+// { dg-options "-Waddress" }
+
+template<class Derived>
+struct S
+{
+ void m() {
+ }
+
+ S()
+ {
+ if (&S<Derived>::Unwrap != &Derived::Unwrap)
+ m();
+ }
+
+ void Unwrap() {
+ }
+};
+
+struct T : public S<T>
+{
+};
+
+T t;