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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127682 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index d0528b1..7ef3348 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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);
diff --git a/test/SemaObjC/property-lookup-in-id.m b/test/SemaObjC/property-lookup-in-id.m
new file mode 100644
index 0000000..389e0bd
--- /dev/null
+++ b/test/SemaObjC/property-lookup-in-id.m
@@ -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;
+
+@interface FileSystemMonitor {
+
+ FSEventStreamRef fsEventStream;
+}
+@property(assign) FSEventStreamRef fsEventStream;
+
+@end
+
+@implementation FileSystemMonitor
+@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'}}
+
+}
+@end
+