Fix <rdar://problem/5965704> clang: bad receiver type 'id const'
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51809 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index c55c058..dd90b9c 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -199,11 +199,12 @@
Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
Expr *RExpr = static_cast<Expr *>(receiver);
- QualType receiverType = RExpr->getType().getCanonicalType();
+ QualType receiverType;
QualType returnType;
ObjCMethodDecl *Method = 0;
+
+ receiverType = RExpr->getType().getCanonicalType().getUnqualifiedType();
- // FIXME: This code is not stripping off type qualifiers! Should it?
if (receiverType == Context.getObjCIdType().getCanonicalType() ||
receiverType == Context.getObjCClassType().getCanonicalType()) {
Method = InstanceMethodPool[Sel].Method;
diff --git a/test/Sema/const-id.m b/test/Sema/const-id.m
new file mode 100644
index 0000000..9087e4c
--- /dev/null
+++ b/test/Sema/const-id.m
@@ -0,0 +1,8 @@
+// RUN: clang %s -verify -fsyntax-only
+
+int main() {
+ const id foo;
+ [foo bar]; // expected-warning {{method '-bar' not found (return type defaults to 'id')}}
+ return 0;
+}
+