diff options
author | Anders Carlsson <andersca@mac.com> | 2009-10-13 21:49:31 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-10-13 21:49:31 +0000 |
commit | 3d5829cd4f94d86f910a2f4a2d1daa561025107b (patch) | |
tree | 827d0bcf384557be3e9f4675a227c2c9ff37a5d5 /clang/lib | |
parent | 115741ba798a72b59ba287bcf0a0f2086243b366 (diff) | |
download | bcm5719-llvm-3d5829cd4f94d86f910a2f4a2d1daa561025107b.tar.gz bcm5719-llvm-3d5829cd4f94d86f910a2f4a2d1daa561025107b.zip |
More return type checking.
llvm-svn: 84034
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 4 |
2 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 194317ce237..56dd6702333 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1572,9 +1572,7 @@ Sema::ActOnPostfixUnaryOp(Scope *S, 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(), @@ -1583,9 +1581,15 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, Input.release(); Args[0] = Arg; - return Owned(new (Context) CXXOperatorCallExpr(Context, OverOp, FnExpr, - Args, 2, ResultTy, - OpLoc)); + + ExprOwningPtr<CXXOperatorCallExpr> + TheCall(this, new (Context) CXXOperatorCallExpr(Context, OverOp, + FnExpr, Args, 2, + ResultTy, OpLoc)); + + if (CheckCallReturnType(FnDecl->getResultType(), OpLoc, TheCall.get(), + FnDecl)) + return ExprError(); } else { // We matched a built-in operator. Convert the arguments, then // break out so that we will build the appropriate built-in diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index e44a6989c7b..7b79fa5f4af 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5050,6 +5050,10 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, ResultTy, RParenLoc)); delete [] MethodArgs; + if (CheckCallReturnType(Method->getResultType(), LParenLoc, TheCall.get(), + Method)) + return true; + // We may have default arguments. If so, we need to allocate more // slots in the call for them. if (NumArgs < NumArgsInProto) |