diff options
-rw-r--r-- | lib/Sema/SemaPseudoObject.cpp | 7 | ||||
-rw-r--r-- | test/SemaObjCXX/property-invalid-type.mm | 19 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp index c8d34f84e1..fac7774734 100644 --- a/lib/Sema/SemaPseudoObject.cpp +++ b/lib/Sema/SemaPseudoObject.cpp @@ -845,7 +845,12 @@ bool ObjCPropertyOpBuilder::tryBuildGetOfReference(Expr *op, if (!S.getLangOpts().CPlusPlus) return false; findGetter(); - assert(Getter && "property has no setter and no getter!"); + if (!Getter) { + // The property has no setter and no getter! This can happen if the type is + // invalid. Error have already been reported. + result = ExprError(); + return true; + } // Only do this if the getter returns an l-value reference type. QualType resultType = Getter->getReturnType(); diff --git a/test/SemaObjCXX/property-invalid-type.mm b/test/SemaObjCXX/property-invalid-type.mm new file mode 100644 index 0000000000..e249ace3d2 --- /dev/null +++ b/test/SemaObjCXX/property-invalid-type.mm @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s + +@interface I +{ + A* response; // expected-error {{unknown type name 'A'}} +} +@end +@interface I () +@property A* response; // expected-error {{unknown type name 'A'}} +@end +@implementation I +@synthesize response; +- (void) foo :(A*) a // expected-error {{expected a type}} +{ + self.response = a; +} +@end + + |