[cfe-commits] r112443 - in /cfe/trunk: lib/Parse/ParseTentative.cpp test/SemaObjCXX/foreach-block.mm
Fariborz Jahanian
fjahanian at apple.com
Sun Aug 29 10:20:53 PDT 2010
Author: fjahanian
Date: Sun Aug 29 12:20:53 2010
New Revision: 112443
URL: http://llvm.org/viewvc/llvm-project?rev=112443&view=rev
Log:
ObjClang++: Allow declaration of block variable in a collection
statement header (fixes radar 8295106).
Added:
cfe/trunk/test/SemaObjCXX/foreach-block.mm
Modified:
cfe/trunk/lib/Parse/ParseTentative.cpp
Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=112443&r1=112442&r2=112443&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Sun Aug 29 12:20:53 2010
@@ -188,7 +188,7 @@
ConsumeParen();
if (!SkipUntil(tok::r_paren))
return TPResult::Error();
- } else if (Tok.is(tok::equal)) {
+ } else if (Tok.is(tok::equal) || isTokIdentifier_in()) {
// MSVC and g++ won't examine the rest of declarators if '=' is
// encountered; they just conclude that we have a declaration.
// EDG parses the initializer completely, which is the proper behavior
@@ -197,6 +197,12 @@
// At present, Clang follows MSVC and g++, since the parser does not have
// the ability to parse an expression fully without recording the
// results of that parse.
+ // Also allow 'in' after on objective-c declaration as in:
+ // for (int (^b)(void) in array). Ideally this should be done in the
+ // context of parsing for-init-statement of a foreach statement only. But,
+ // in any other context 'in' is invalid after a declaration and parser
+ // issues the error regardless of outcome of this decision.
+ // FIXME. Change if above assumption does not hold.
return TPResult::True();
}
Added: cfe/trunk/test/SemaObjCXX/foreach-block.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/foreach-block.mm?rev=112443&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/foreach-block.mm (added)
+++ cfe/trunk/test/SemaObjCXX/foreach-block.mm Sun Aug 29 12:20:53 2010
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
+// rdar://8295106
+
+int main() {
+id array;
+
+ for (int (^b)(void) in array) {
+ if (b() == 10000) {
+ return 1;
+ }
+ }
+
+ int (^b)(void) in array; // expected-error {{expected ';' at end of declaration}}
+}
More information about the cfe-commits
mailing list