Index: test/SemaCXX/attr-nonnull.cpp
===================================================================
--- test/SemaCXX/attr-nonnull.cpp	(revision 173314)
+++ test/SemaCXX/attr-nonnull.cpp	(working copy)
@@ -40,3 +40,15 @@
   f(static_cast<char*>(0));  // expected-warning{{null passed}}
 }
 }
+
+namespace test4 {
+struct X {
+  bool operator!=(const void *) const __attribute__((nonnull(2)));
+};
+bool operator==(const X&, const void *) __attribute__((nonnull(2)));
+
+void test(const X& x) {
+  (void)(x == 0);  // expected-warning{{null passed}}
+  (void)(x != 0);  // expected-warning{{null passed}}
+}
+}
Index: lib/Sema/SemaOverload.cpp
===================================================================
--- lib/Sema/SemaOverload.cpp	(revision 173314)
+++ lib/Sema/SemaOverload.cpp	(working copy)
@@ -10336,6 +10336,13 @@
                                 FnDecl))
           return ExprError();
 
+        ArrayRef<const Expr *> ArgsArray(Args, 2);
+        // Cut off the implicit 'this'.
+        if (isa<CXXMethodDecl>(FnDecl))
+          ArgsArray = ArgsArray.slice(1);
+        checkCall(FnDecl, ArgsArray, 0, isa<CXXMethodDecl>(FnDecl), OpLoc, 
+                  TheCall->getSourceRange(), VariadicDoesNotApply);
+
         return MaybeBindToTemporary(TheCall);
       } else {
         // We matched a built-in operator. Convert the arguments, then
