[cfe-commits] r98135 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/exprs.m
Douglas Gregor
dgregor at apple.com
Tue Mar 9 20:54:39 PST 2010
Author: dgregor
Date: Tue Mar 9 22:54:39 2010
New Revision: 98135
URL: http://llvm.org/viewvc/llvm-project?rev=98135&view=rev
Log:
Statement expressions can be used in global- or namespace-scoped blocks
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/exprs.m
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=98135&r1=98134&r2=98135&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar 9 22:54:39 2010
@@ -6593,7 +6593,8 @@
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));
Modified: cfe/trunk/test/SemaObjC/exprs.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/exprs.m?rev=98135&r1=98134&r2=98135&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/exprs.m (original)
+++ cfe/trunk/test/SemaObjC/exprs.m Tue Mar 9 22:54:39 2010
@@ -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 @@
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); };
More information about the cfe-commits
mailing list