From a326bae77ade88390ba6acd40eeb1f421eafa73a Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Sat, 31 May 2008 02:19:15 +0000 Subject: [PATCH] Fix clang: bad receiver type 'id const' llvm-svn: 51809 --- clang/lib/Sema/SemaExprObjC.cpp | 5 +++-- clang/test/Sema/const-id.m | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 clang/test/Sema/const-id.m diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index c55c05893f53..dd90b9ca19d6 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -199,11 +199,12 @@ Sema::ExprResult Sema::ActOnInstanceMessage( Expr **ArgExprs = reinterpret_cast(Args); Expr *RExpr = static_cast(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/clang/test/Sema/const-id.m b/clang/test/Sema/const-id.m new file mode 100644 index 000000000000..9087e4ce7df6 --- /dev/null +++ b/clang/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; +} +