[cfe-commits] r81176 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/Sema/block-return.c
Chris Lattner
sabre at nondot.org
Mon Sep 7 17:36:37 PDT 2009
Author: lattner
Date: Mon Sep 7 19:36:37 2009
New Revision: 81176
URL: http://llvm.org/viewvc/llvm-project?rev=81176&view=rev
Log:
reject returning a block expr even when it has parens and casts in the way.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/block-return.c
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=81176&r1=81175&r2=81176&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Sep 7 19:36:37 2009
@@ -1254,9 +1254,7 @@
<< DR->getDecl()->getDeclName() << RetValExp->getSourceRange();
// Skip over implicit cast expressions when checking for block expressions.
- if (ImplicitCastExpr *IcExpr =
- dyn_cast_or_null<ImplicitCastExpr>(RetValExp))
- RetValExp = IcExpr->getSubExpr();
+ RetValExp = RetValExp->IgnoreParenCasts();
if (BlockExpr *C = dyn_cast_or_null<BlockExpr>(RetValExp))
if (C->hasBlockDeclRefExprs())
Modified: cfe/trunk/test/Sema/block-return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=81176&r1=81175&r2=81176&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-return.c (original)
+++ cfe/trunk/test/Sema/block-return.c Mon Sep 7 19:36:37 2009
@@ -91,6 +91,8 @@
if (j)
return ^{ ^{ i=0; }(); }; // expected-error {{returning block that lives on the local stack}}
return ^{ i=0; }; // expected-error {{returning block that lives on the local stack}}
+ return (^{ i=0; }); // expected-error {{returning block that lives on the local stack}}
+ return (void*)(^{ i=0; }); // expected-error {{returning block that lives on the local stack}}
}
int (*funcptr3[5])(long);
More information about the cfe-commits
mailing list