From db8c6fd18f9d38fe0dc549a402e2672f943702ab Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 20 Sep 2010 17:13:33 +0000 Subject: Check that an overloaded function name, when used by the ! operator, actually resolves to a particular function. Fixes PR8181, from Faisal Vali! llvm-svn: 114331 --- clang/lib/Sema/SemaExpr.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/lib/Sema/SemaExpr.cpp') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 40009844482..2db253a8933 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6814,6 +6814,13 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, 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; -- cgit v1.2.3