aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaDeclObjC.cpp21
-rw-r--r--test/SemaObjC/property-1.m8
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 0241655026..4e05a137a5 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -874,6 +874,9 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
}
}
}
+ // Save the size so we can detect if we've added any property methods.
+ unsigned int insMethodsSizePriorToPropAdds = insMethods.size();
+ unsigned int clsMethodsSizePriorToPropAdds = clsMethods.size();
if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
// Compares properties declared in this class to those of its
@@ -925,6 +928,24 @@ void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl,
}
}
}
+ // Add any synthesized methods to the global pool. This allows us to
+ // handle the following, which is supported by GCC (and part of the design).
+ //
+ // @interface Foo
+ // @property double bar;
+ // @end
+ //
+ // void thisIsUnfortunate() {
+ // id foo;
+ // double bar = [foo bar];
+ // }
+ //
+ if (insMethodsSizePriorToPropAdds < insMethods.size())
+ for (unsigned i = insMethodsSizePriorToPropAdds; i < insMethods.size(); i++)
+ AddInstanceMethodToGlobalPool(insMethods[i]);
+ if (clsMethodsSizePriorToPropAdds < clsMethods.size())
+ for (unsigned i = clsMethodsSizePriorToPropAdds; i < clsMethods.size(); i++)
+ AddFactoryMethodToGlobalPool(clsMethods[i]);
}
diff --git a/test/SemaObjC/property-1.m b/test/SemaObjC/property-1.m
index 2641105162..6d13a7b8c6 100644
--- a/test/SemaObjC/property-1.m
+++ b/test/SemaObjC/property-1.m
@@ -35,5 +35,13 @@
@dynamic d; // expected-error {{property implementation in a category with no category declaration}}
@end
+@interface Foo
+@property double bar;
+@end
+int main() {
+ id foo;
+ double bar = [foo bar];
+ return 0;
+}