summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-04-20 22:23:10 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-04-20 22:23:10 +0000
commit1f5f5c2c2f3123c47359eb702a7ee50f1b0e27ae (patch)
treea070aac403ad05680de94683795b9805b245328a
parentd9e3bf70cd419ea8e83d6a7116c920eb2f6b41d7 (diff)
downloadbcm5719-llvm-1f5f5c2c2f3123c47359eb702a7ee50f1b0e27ae.tar.gz
bcm5719-llvm-1f5f5c2c2f3123c47359eb702a7ee50f1b0e27ae.zip
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. llvm-svn: 300909
-rw-r--r--clang/lib/Sema/TreeTransform.h3
-rw-r--r--clang/test/SemaObjCXX/pr32725.mm9
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 693b5c088ac..f4a97f55789 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/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/clang/test/SemaObjCXX/pr32725.mm b/clang/test/SemaObjCXX/pr32725.mm
new file mode 100644
index 00000000000..8d7d1163250
--- /dev/null
+++ b/clang/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}}
OpenPOWER on IntegriCloud