diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-29 23:42:03 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-29 23:42:03 +0000 |
commit | d976ca4fcacdd965446bcfbe8cb03b4ee67cd827 (patch) | |
tree | 34d2a9fb9b5d0d474b5ad3b7b815d0656bc84e13 /lib/Sema/SemaChecking.cpp | |
parent | bbd340717422bf011d56cd0164d2576601368111 (diff) |
Revert r120331 since it causes spurious warnings and a possible assertion hit when self-host.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120351 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 807a550750..ed45de53f2 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/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; } |