summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-09-23 23:11:38 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-09-23 23:11:38 +0000
commit44653709fdc26ae93eea9c08a82725cfc9532243 (patch)
treed7d2e9fdf58ab572eac02e4ad91885bf11cb3927
parent8b2fe2f74490e0d99a2c4abbcb2f79ad75d2caf4 (diff)
downloadbcm5719-llvm-44653709fdc26ae93eea9c08a82725cfc9532243.tar.gz
bcm5719-llvm-44653709fdc26ae93eea9c08a82725cfc9532243.zip
objc - fixes a crash when undefined typed property
followed by it implementation crashes when attempt is made to access the synthesized ivar. // rdar://10177744 llvm-svn: 140432
-rw-r--r--clang/lib/Sema/SemaExpr.cpp5
-rw-r--r--clang/test/SemaObjC/bad-property-synthesis-crash.m23
2 files changed, 27 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4dd43c8857f..31eb19e1747 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -1702,7 +1702,10 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
if (ObjCIvarDecl *Ivar = R.getAsSingle<ObjCIvarDecl>()) {
R.clear();
ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
- assert(E.isInvalid() || E.get());
+ // In a hopelessly buggy code, Objective-C instance variable
+ // lookup fails and no expression will be built to reference it.
+ if (!E.isInvalid() && !E.get())
+ return ExprError();
return move(E);
}
}
diff --git a/clang/test/SemaObjC/bad-property-synthesis-crash.m b/clang/test/SemaObjC/bad-property-synthesis-crash.m
new file mode 100644
index 00000000000..a594979f143
--- /dev/null
+++ b/clang/test/SemaObjC/bad-property-synthesis-crash.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -verify %s
+// rdar://10177744
+
+@interface Foo
+@property (nonatomic, retain) NSString* what; // expected-error {{unknown type name 'NSString'}} \
+ // expected-error {{property with}} \
+ // expected-note {{previous definition is here}}
+@end
+
+@implementation Foo
+- (void) setWhat: (NSString*) value { // expected-error {{expected a type}} \
+ // expected-warning {{conflicting parameter types in implementation of}}
+ __what; // expected-error {{use of undeclared identifier}} \
+ // expected-warning {{expression result unused}}
+}
+@synthesize what; // expected-note 2 {{'what' declared here}}
+@end
+
+@implementation Bar // expected-warning {{cannot find interface declaration for}}
+- (NSString*) what { // expected-error {{expected a type}}
+ return __what; // expected-error {{use of undeclared identifier}}
+}
+@end
OpenPOWER on IntegriCloud