aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2014-08-05 05:19:17 +0000
committerBill Wendling <isanbard@gmail.com>2014-08-05 05:19:17 +0000
commit13b8dc20402a4d63289faf1d4992f3ae2c48bebc (patch)
tree17d722f70d84c255af568eb5618f8b98f62b2b50 /clang
parent6a183487cc3cc74492ec27a877eb56833ddd83be (diff)
downloadllvm-13b8dc20402a4d63289faf1d4992f3ae2c48bebc.zip
llvm-13b8dc20402a4d63289faf1d4992f3ae2c48bebc.tar.gz
llvm-13b8dc20402a4d63289faf1d4992f3ae2c48bebc.tar.bz2
Merging r214734:
------------------------------------------------------------------------ r214734 | ogoffart | 2014-08-04 10:28:05 -0700 (Mon, 04 Aug 2014) | 7 lines Fix crash when assiging to a property with an invalid type This is a regression from clang 3.4 Set the result to ExprError and returns true, rather than simply returns false because errors have been reported already and returning false show a confusing error ------------------------------------------------------------------------ llvm-svn: 214839
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaPseudoObject.cpp7
-rw-r--r--clang/test/SemaObjCXX/property-invalid-type.mm19
2 files changed, 25 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp
index c8d34f8..fac7774 100644
--- a/clang/lib/Sema/SemaPseudoObject.cpp
+++ b/clang/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/clang/test/SemaObjCXX/property-invalid-type.mm b/clang/test/SemaObjCXX/property-invalid-type.mm
new file mode 100644
index 0000000..e249ace
--- /dev/null
+++ b/clang/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
+
+