[cfe-commits] r127682 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/property-lookup-in-id.m

Fariborz Jahanian fjahanian at apple.com
Tue Mar 15 10:27:48 PDT 2011


Author: fjahanian
Date: Tue Mar 15 12:27:48 2011
New Revision: 127682

URL: http://llvm.org/viewvc/llvm-project?rev=127682&view=rev
Log:
Don't poke into redefined 'id' type looking for a property
declaration as this results in a confusing error message,
instead of message related to missing property declaration.
// rdar://9106929

Added:
    cfe/trunk/test/SemaObjC/property-lookup-in-id.m
Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=127682&r1=127681&r2=127682&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar 15 12:27:48 2011
@@ -3905,8 +3905,9 @@
                                                          MemberLoc, BaseExpr));
         }
       }
-
-      if (ShouldTryAgainWithRedefinitionType(*this, BaseExpr))
+      // Use of id.member can only be for a property reference. Do not
+      // use the 'id' redefinition in this case.
+      if (IsArrow && ShouldTryAgainWithRedefinitionType(*this, BaseExpr))
         return LookupMemberExpr(R, BaseExpr, IsArrow, OpLoc, SS,
                                 ObjCImpDecl, HasTemplateArgs);
 

Added: cfe/trunk/test/SemaObjC/property-lookup-in-id.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-lookup-in-id.m?rev=127682&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/property-lookup-in-id.m (added)
+++ cfe/trunk/test/SemaObjC/property-lookup-in-id.m Tue Mar 15 12:27:48 2011
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+// rdar://9106929
+
+typedef struct objc_class *Class;
+
+typedef struct objc_object {
+    Class isa;
+} *id;
+
+
+typedef struct __FSEventStream* FSEventStreamRef;
+
+extern id NSApp;
+
+ at interface FileSystemMonitor { 
+
+ FSEventStreamRef fsEventStream;
+}
+ at property(assign) FSEventStreamRef fsEventStream;
+
+ at end
+
+ at implementation FileSystemMonitor
+ at synthesize fsEventStream;
+
+- (void)startFSEventGathering:(id)sender
+{
+  fsEventStream = [NSApp delegate].fsEventStream; // expected-warning {{warning: method '-delegate' not found (return type defaults to 'id')}} \
+                                                  // expected-error {{property 'fsEventStream' not found on object of type 'id'}}
+
+}
+ at end
+





More information about the cfe-commits mailing list