summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-11-29 23:42:03 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-11-29 23:42:03 +0000
commit091d97c709af4419e26968421c2eca917d2ae079 (patch)
tree6f2210dc4a885d91c46e15f297178abefef1ea3d /clang/lib/Sema/SemaChecking.cpp
parentcb803b043b820d169c29f2fce9d122334a5e8a6c (diff)
downloadbcm5719-llvm-091d97c709af4419e26968421c2eca917d2ae079.tar.gz
bcm5719-llvm-091d97c709af4419e26968421c2eca917d2ae079.zip
Revert r120331 since it causes spurious warnings and a possible assertion hit when self-host.
llvm-svn: 120351
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp30
1 files changed, 3 insertions, 27 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 807a5507508..ed45de53f26 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1787,35 +1787,11 @@ Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
<< ALE->getSourceRange();
} else if (lhsType->isReferenceType()) {
- // Perform checking for local temporaries returned by reference.
- if (RetValExp->Classify(Context).isPRValue()) {
- Diag(RetValExp->getLocStart(), diag::warn_ret_local_temp_ref)
- << RetValExp->getSourceRange();
- return;
- }
-
// Perform checking for stack values returned by reference.
// Check for a reference to the stack
- if (DeclRefExpr *DR = EvalVal(RetValExp)) {
- const VarDecl *VD = cast<VarDecl>(DR->getDecl());
- // Check for returning reference variable that binds to temporary.
- if (VD->getType()->isReferenceType()) {
- if (const Expr *init = VD->getInit())
- if (init->Classify(Context).isPRValue()) {
- Diag(DR->getLocStart(), diag::warn_ret_local_temp_var_ref)
- << VD->getDeclName() << RetValExp->getSourceRange();
- Diag(VD->getLocation(), diag::note_local_temp_var_ref)
- << VD->getDeclName() << VD->getInit()->getSourceRange();
- }
-
- // When returning a reference variable that doesn't bind to temporary,
- // no warning.
- return;
- }
-
+ if (DeclRefExpr *DR = EvalVal(RetValExp))
Diag(DR->getLocStart(), diag::warn_ret_stack_ref)
- << VD->getDeclName() << RetValExp->getSourceRange();
- }
+ << DR->getDecl()->getDeclName() << RetValExp->getSourceRange();
}
}
@@ -1977,7 +1953,7 @@ do {
DeclRefExpr *DR = cast<DeclRefExpr>(E);
if (VarDecl *V = dyn_cast<VarDecl>(DR->getDecl()))
- if (V->hasLocalStorage()) return DR;
+ if (V->hasLocalStorage() && !V->getType()->isReferenceType()) return DR;
return NULL;
}
OpenPOWER on IntegriCloud