diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2017-04-20 22:23:10 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2017-04-20 22:23:10 +0000 |
commit | b8a9d6cf3ba65f6c2048db8df7a8bdd946613815 (patch) | |
tree | b1d8623cb1bd4f48713026a4c838f21b986ca088 | |
parent | 0229ffa91b35240bff435429f316b641d890544f (diff) | |
download | clang-b8a9d6cf3ba65f6c2048db8df7a8bdd946613815.tar.gz |
Sema: protect against ObjC++ typo-correction failure
ObjC++ has two different types of "pointer" types (ObjCClassPointerType
and PointerType). Both can be indirected through. However, the former
is not a member expression. Ensure that we do not try to rebuild the
MRE in that case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300909 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/TreeTransform.h | 3 | ||||
-rw-r--r-- | test/SemaObjCXX/pr32725.mm | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 693b5c088a..f4a97f5578 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -2220,6 +2220,9 @@ public: Base = BaseResult.get(); QualType BaseType = Base->getType(); + if (isArrow && !BaseType->isPointerType()) + return ExprError(); + // FIXME: this involves duplicating earlier analysis in a lot of // cases; we should avoid this when possible. LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName); diff --git a/test/SemaObjCXX/pr32725.mm b/test/SemaObjCXX/pr32725.mm new file mode 100644 index 0000000000..8d7d116325 --- /dev/null +++ b/test/SemaObjCXX/pr32725.mm @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx -fsyntax-only -verify -x objective-c++ %s -o /dev/null +// REQUIRES: asserts + +struct objc_class { + unsigned long long bits; +}; +typedef struct objc_class *Class; +static void f(Class c) { (void)(c->bits & RW_HAS_OVERFLOW_REFCOUNT); } +// expected-error@-1{{use of undeclared identifier 'RW_HAS_OVERFLOW_REFCOUNT}} |