Sema: protect against ObjC++ typo-correction failure
authorSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 20 Apr 2017 22:23:10 +0000 (22:23 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Thu, 20 Apr 2017 22:23:10 +0000 (22:23 +0000)
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

clang/lib/Sema/TreeTransform.h
clang/test/SemaObjCXX/pr32725.mm [new file with mode: 0644]

index 693b5c0..f4a97f5 100644 (file)
@@ -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 (file)
index 0000000..8d7d116
--- /dev/null
@@ -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}}