diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-09-20 17:13:33 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-09-20 17:13:33 +0000 |
commit | db8c6fd18f9d38fe0dc549a402e2672f943702ab (patch) | |
tree | a73061daa16f4d5d586c35e0c599520c6c9a3f74 /clang/lib | |
parent | 433d7741bdc771e9608027b6efe73eedb810f9d3 (diff) | |
download | bcm5719-llvm-db8c6fd18f9d38fe0dc549a402e2672f943702ab.tar.gz bcm5719-llvm-db8c6fd18f9d38fe0dc549a402e2672f943702ab.zip |
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
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
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; |