[cfe-commits] r51963 - in /cfe/trunk: lib/Parse/ParseObjc.cpp test/Sema/objc-synchronized.m

Steve Naroff snaroff at apple.com
Wed Jun 4 13:36:13 PDT 2008


Author: snaroff
Date: Wed Jun  4 15:36:13 2008
New Revision: 51963

URL: http://llvm.org/viewvc/llvm-project?rev=51963&view=rev
Log:
Parser::ParseObjCSynchronizedStmt() needs to Enter/Exit a decl scope.

Added:
    cfe/trunk/test/Sema/objc-synchronized.m
Modified:
    cfe/trunk/lib/Parse/ParseObjc.cpp

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=51963&r1=51962&r2=51963&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Wed Jun  4 15:36:13 2008
@@ -1143,7 +1143,13 @@
     Diag (Tok, diag::err_expected_lbrace);
     return true;
   }
+  // Enter a scope to hold everything within the compound stmt.  Compound
+  // statements can always hold declarations.
+  EnterScope(Scope::DeclScope);
+
   StmtResult SynchBody = ParseCompoundStatementBody();
+  
+  ExitScope();
   if (SynchBody.isInvalid)
     SynchBody = Actions.ActOnNullStmt(Tok.getLocation());
   return Actions.ActOnObjCAtSynchronizedStmt(atLoc, Res.Val, SynchBody.Val);

Added: cfe/trunk/test/Sema/objc-synchronized.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-synchronized.m?rev=51963&view=auto

==============================================================================
--- cfe/trunk/test/Sema/objc-synchronized.m (added)
+++ cfe/trunk/test/Sema/objc-synchronized.m Wed Jun  4 15:36:13 2008
@@ -0,0 +1,75 @@
+// RUN: clang -fsyntax-only -verify %s
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+typedef struct _NSZone NSZone;
+ at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+
+ at protocol NSObject
+- (BOOL)isEqual:(id)object;
+ at end
+
+ at protocol NSCopying
+- (id)copyWithZone:(NSZone *)zone;
+ at end
+
+ at protocol NSMutableCopying
+- (id)mutableCopyWithZone:(NSZone *)zone;
+ at end
+
+ at protocol NSCoding
+- (void)encodeWithCoder:(NSCoder *)aCoder;
+ at end
+
+ at interface NSObject <NSObject> {} @end
+
+typedef float CGFloat;
+typedef struct { int a; } NSFastEnumerationState;
+
+ at protocol NSFastEnumeration 
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+ at end
+
+typedef unsigned short unichar;
+
+ at interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
+- (NSUInteger)length;
+ at end
+
+ at interface NSSimpleCString : NSString {} @end
+
+ at interface NSConstantString : NSSimpleCString @end
+
+extern void *_NSConstantStringClassReference;
+
+ at interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+- (NSUInteger)count;
+ at end
+
+ at interface NSMutableDictionary : NSDictionary
+- (void)removeObjectForKey:(id)aKey;
+ at end
+
+ at class NSArray, NSSet, NSHashTable;
+
+ at protocol PBXTrackableTask <NSObject>
+- (float) taskPercentComplete;
+- taskIdentifier;
+ at end
+
+ at interface PBXTrackableTaskManager : NSObject {
+  NSMutableDictionary *_trackableTasks;
+}
+ at end
+
+NSString *XCExecutableDebugTaskIdentifier = @"XCExecutableDebugTaskIdentifier";
+
+ at implementation PBXTrackableTaskManager
+- (id) init {}
+- (void) unregisterTask:(id <PBXTrackableTask>) task {
+  @synchronized (self) {
+  id taskID = [task taskIdentifier];
+  id task = [_trackableTasks objectForKey:taskID]; // expected-warning{{method '-objectForKey:' not found (return type defaults to 'id')}}
+  }
+}
+ at end
+





More information about the cfe-commits mailing list