summaryrefslogtreecommitdiffstats
path: root/lib/Sema/SemaStmt.cpp
diff options
context:
space:
mode:
authorArtyom Skrobov <Artyom.Skrobov@arm.com>2014-01-24 11:10:39 +0000
committerArtyom Skrobov <Artyom.Skrobov@arm.com>2014-01-24 11:10:39 +0000
commit786d1b4b2bf5cfad9fc6ea9dc7658ff8285c8e3a (patch)
tree8d83f816cf7eae5ecc3123795982cd3b07d987fa /lib/Sema/SemaStmt.cpp
parentadf9b544aa52b98e65055ba986a5c4f17620b116 (diff)
Combine the checks for returns_nonnull and for operator new returning null, in Sema::CheckReturnValExpr. Add the missing handling of value-dependent expressions for returns_nonnull.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199989 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r--lib/Sema/SemaStmt.cpp25
1 files changed, 2 insertions, 23 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index badd048bd8..e9ae7b90f0 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -2975,29 +2975,8 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
RetValExp = Res.takeAs<Expr>();
}
- CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc, isObjCMethod, Attrs);
-
- // C++11 [basic.stc.dynamic.allocation]p4:
- // If an allocation function declared with a non-throwing
- // exception-specification fails to allocate storage, it shall return
- // a null pointer. Any other allocation function that fails to allocate
- // storage shall indicate failure only by throwing an exception [...]
- if (const FunctionDecl *FD = getCurFunctionDecl()) {
- OverloadedOperatorKind Op = FD->getOverloadedOperator();
- if (Op == OO_New || Op == OO_Array_New) {
- const FunctionProtoType *Proto
- = FD->getType()->castAs<FunctionProtoType>();
- bool ReturnValueNonNull;
-
- if (!Proto->isNothrow(Context, /*ResultIfDependent*/true) &&
- !RetValExp->isValueDependent() &&
- RetValExp->EvaluateAsBooleanCondition(ReturnValueNonNull,
- Context) &&
- !ReturnValueNonNull)
- Diag(ReturnLoc, diag::warn_operator_new_returns_null)
- << FD << getLangOpts().CPlusPlus11;
- }
- }
+ CheckReturnValExpr(RetValExp, FnRetType, ReturnLoc, isObjCMethod, Attrs,
+ getCurFunctionDecl());
}
if (RetValExp) {