diff options
author | Steve Naroff <snaroff@apple.com> | 2008-09-16 22:25:10 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-09-16 22:25:10 +0000 |
commit | 3b1e172d7ef08504b001aac21a15ada002d0993e (patch) | |
tree | 8a06b53bb9173261a7da1eee5e6122e8cb685f28 /clang/lib | |
parent | 64d6c6fe301b987afba0cb07961400d11e463967 (diff) | |
download | bcm5719-llvm-3b1e172d7ef08504b001aac21a15ada002d0993e.tar.gz bcm5719-llvm-3b1e172d7ef08504b001aac21a15ada002d0993e.zip |
Sema::ActOnBlockReturnStmt(): Need to perform the UsualUnaryConversions on the return type.
Sema::CheckReturnStackAddr(): Make sure we skip over implicit casts.
Added some more test cases...
llvm-svn: 56254
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 00b469b7c05..f870e26b6a3 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -716,7 +716,12 @@ Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, Diag(DR->getLocStart(), diag::warn_ret_stack_addr, DR->getDecl()->getIdentifier()->getName(), RetValExp->getSourceRange()); - + + // Skip over implicit cast expressions when checking for block expressions. + if (ImplicitCastExpr *IcExpr = + dyn_cast_or_null<ImplicitCastExpr>(RetValExp)) + RetValExp = IcExpr->getSubExpr(); + if (BlockExpr *C = dyn_cast_or_null<BlockExpr>(RetValExp)) Diag(C->getLocStart(), diag::err_ret_local_block, C->getSourceRange()); diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index d7a812cb2a8..3cadd526a77 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -678,9 +678,10 @@ Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) { // If this is the first return we've seen in the block, infer the type of // the block from it. if (CurBlock->ReturnType == 0) { - if (RetValExp) + if (RetValExp) { + UsualUnaryConversions(RetValExp); CurBlock->ReturnType = RetValExp->getType().getTypePtr(); - else + } else CurBlock->ReturnType = Context.VoidTy.getTypePtr(); return new ReturnStmt(ReturnLoc, RetValExp); } |