[prev in list] [next in list] [prev in thread] [next in thread]
List: cfe-commits
Subject: [PATCH] Fix crash when assiging to a property with an invalid type
From: Olivier Goffart <ogoffart () kde ! org>
Date: 2014-07-30 7:42:40
Message-ID: 1578492.itqGIZ9yIk () finn
[Download RAW message or body]
Hi,
Attached you will find a fix for a crash I have when parsing objective C with
missing include.
This is a regression against clang 3.4 which did not crash.
My approach here is naive and just fixes the symptoms (the crash).
Regards
--
Olivier
["0001-Fix-crash-when-assiging-to-a-property-with-an-invali.patch" (0001-Fix-crash-when-assiging-to-a-property-with-an-invali.patch)]
From 41ab6b5e34dbccd1d258ce7676fd493bade10c67 Mon Sep 17 00:00:00 2001
From: Olivier Goffart <ogoffart@woboq.com>
Date: Wed, 30 Jul 2014 00:45:58 +0200
Subject: [PATCH] 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
---
lib/Sema/SemaPseudoObject.cpp | 7 ++++++-
test/SemaObjCXX/property-invalid-type.mm | 19 +++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 test/SemaObjCXX/property-invalid-type.mm
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp
index c8d34f8..fac7774 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 0000000..e249ace
--- /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
+
+
--
2.0.3
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic