diff options
| author | Shoaib Meenai <smeenai@fb.com> | 2018-03-27 18:58:28 +0000 |
|---|---|---|
| committer | Shoaib Meenai <smeenai@fb.com> | 2018-03-27 18:58:28 +0000 |
| commit | adf5a32ec57addb326ff6cd13f1e9e0a6a10bdb8 (patch) | |
| tree | dacb579967b152f1f1938186a4801906f82254b7 /clang | |
| parent | 662f38b16f0ef69e0e55a0662d2fe68413e1e465 (diff) | |
| download | bcm5719-llvm-adf5a32ec57addb326ff6cd13f1e9e0a6a10bdb8.tar.gz bcm5719-llvm-adf5a32ec57addb326ff6cd13f1e9e0a6a10bdb8.zip | |
[Sema] Avoid crash for category implementation without interface
When we have a category implementation without a corresponding interface
(which is an error by itself), semantic checks for property accesses
will attempt to access a null interface declaration and then segfault.
Error out in such cases instead.
Differential Revision: https://reviews.llvm.org/D44916
llvm-svn: 328654
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaExprMember.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaObjC/undef-class-property-error.m | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprMember.cpp b/clang/lib/Sema/SemaExprMember.cpp index d0542742892..522e4bbe074 100644 --- a/clang/lib/Sema/SemaExprMember.cpp +++ b/clang/lib/Sema/SemaExprMember.cpp @@ -1568,6 +1568,9 @@ static ExprResult LookupMemberExpr(Sema &S, LookupResult &R, // Also must look for a getter name which uses property syntax. Selector Sel = S.PP.getSelectorTable().getNullarySelector(Member); ObjCInterfaceDecl *IFace = MD->getClassInterface(); + if (!IFace) + goto fail; + ObjCMethodDecl *Getter; if ((Getter = IFace->lookupClassMethod(Sel))) { // Check the use of this method. diff --git a/clang/test/SemaObjC/undef-class-property-error.m b/clang/test/SemaObjC/undef-class-property-error.m new file mode 100644 index 00000000000..e7e5db41efb --- /dev/null +++ b/clang/test/SemaObjC/undef-class-property-error.m @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@implementation I (C) // expected-error {{cannot find interface declaration for 'I'}} + ++ (void)f { + self.m; // expected-error {{member reference base type 'Class' is not a structure or union}} +} + +@end |

