if (!resultType->isScalarType()) // C99 6.5.3.3p1
return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
<< resultType << Input->getSourceRange());
+
+ // Do not accept &f if f is overloaded
+ // i.e. void f(int); void f(char); bool b = &f;
+ if (resultType == Context.OverloadTy &&
+ PerformContextuallyConvertToBool(Input))
+ return ExprError(); // Diagnostic is uttered above
+
// LNot always has type int. C99 6.5.3.3p5.
// In C++, it's bool. C++ 5.3.1p8
resultType = getLangOptions().CPlusPlus ? Context.BoolTy : Context.IntTy;
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// -- prvalue of arithmetic
+
+bool b = !0;
+
+bool b2 = !1.2;
+
+bool b3 = !4;
+
+// -- unscoped enumeration
+enum { E, F };
+
+bool b4 = !E;
+bool b5 = !F;
+
+// -- pointer,
+bool b6 = !&b4;
+void f();
+bool b61 = !&f;
+
+// -- or pointer to member type can be converted to a prvalue of type bool.
+struct S { void f() { } };
+
+bool b7 = !&S::f;
+
+
+bool b8 = !S(); //expected-error {{invalid argument type 'S'}}
+
+namespace PR8181
+{
+ void f() { }
+ void f(char) { }
+ bool b = !&f; //expected-error {{value of type '<overloaded function type>' is not contextually convertible to 'bool'}}
+
+}