diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-03-10 04:54:39 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-03-10 04:54:39 +0000 |
| commit | 6cf3f3c75efdf24456ee084e4b8d55ecbd3809d0 (patch) | |
| tree | 55bea87bd018db62c3a245a3602463e9a1d3aa00 | |
| parent | e78aac41debf968be07fb755ba94b6fed29167b5 (diff) | |
| download | bcm5719-llvm-6cf3f3c75efdf24456ee084e4b8d55ecbd3809d0.tar.gz bcm5719-llvm-6cf3f3c75efdf24456ee084e4b8d55ecbd3809d0.zip | |
Statement expressions can be used in global- or namespace-scoped blocks
llvm-svn: 98135
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaObjC/exprs.m | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 10001c356d1..2249579ba4e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6593,7 +6593,8 @@ Sema::ActOnStmtExpr(SourceLocation LPLoc, StmtArg substmt, assert(SubStmt && isa<CompoundStmt>(SubStmt) && "Invalid action invocation!"); CompoundStmt *Compound = cast<CompoundStmt>(SubStmt); - bool isFileScope = getCurFunctionOrMethodDecl() == 0; + bool isFileScope + = (getCurFunctionOrMethodDecl() == 0) && (getCurBlock() == 0); if (isFileScope) return ExprError(Diag(LPLoc, diag::err_stmtexpr_file_scope)); diff --git a/clang/test/SemaObjC/exprs.m b/clang/test/SemaObjC/exprs.m index 33b144461f2..3370bda0517 100644 --- a/clang/test/SemaObjC/exprs.m +++ b/clang/test/SemaObjC/exprs.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -Wno-unreachable-code +// RUN: %clang_cc1 %s -fsyntax-only -fblocks -verify -Wno-unreachable-code // rdar://6597252 Class test1(Class X) { @@ -19,3 +19,6 @@ void test2() { if (@encode(int) == "foo") { } // expected-warning {{result of comparison against @encode is unspecified}} } + +#define MAX(A,B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; }) +void (^foo)(int, int) = ^(int x, int y) { int z = MAX(x, y); }; |

