aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-10-13 21:19:37 +0000
committerAnders Carlsson <andersca@mac.com>2009-10-13 21:19:37 +0000
commit26a2a07acfacc06406e6a48c6d22e4b26bcd6382 (patch)
treeed87e7964df96b413239a3b11699c02869ca5522 /lib/Sema
parent3f09327b26033d0a9676d52d80cf92c48f581aff (diff)
Diagnose invalid return types for unary operators.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84030 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/SemaOverload.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 7744ae7c59..e44a6989c7 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -4526,9 +4526,7 @@ Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
}
// Determine the result type
- QualType ResultTy
- = FnDecl->getType()->getAs<FunctionType>()->getResultType();
- ResultTy = ResultTy.getNonReferenceType();
+ QualType ResultTy = FnDecl->getResultType().getNonReferenceType();
// Build the actual expression node.
Expr *FnExpr = new (Context) DeclRefExpr(FnDecl, FnDecl->getType(),
@@ -4537,9 +4535,15 @@ Sema::OwningExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
input.release();
- Expr *CE = new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
- &Input, 1, ResultTy, OpLoc);
- return MaybeBindToTemporary(CE);
+ ExprOwningPtr<CallExpr> TheCall(this,
+ new (Context) CXXOperatorCallExpr(Context, Op, FnExpr,
+ &Input, 1, ResultTy, OpLoc));
+
+ if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall.get(),
+ FnDecl))
+ return ExprError();
+
+ return MaybeBindToTemporary(TheCall.release());
} else {
// We matched a built-in operator. Convert the arguments, then
// break out so that we will build the appropriate built-in