From: Fariborz Jahanian Date: Fri, 16 Jan 2009 20:35:09 +0000 (+0000) Subject: Don't ICE (issue diagnostics) when receiver is a non-objc X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ebff1fed660fac9c50a7b7571da797bb489254a4;p=clang Don't ICE (issue diagnostics) when receiver is a non-objc type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62355 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 548389db37..8f4d677179 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -239,8 +239,9 @@ Sema::ExprResult Sema::ActOnClassMessage( if (TypedefDecl *OCTD = dyn_cast_or_null(IDecl)) { const ObjCInterfaceType *OCIT; OCIT = OCTD->getUnderlyingType()->getAsObjCInterfaceType(); - if (OCIT) - ClassDecl = OCIT->getDecl(); + if (!OCIT) + return Diag(receiverLoc, diag::err_invalid_receiver_to_message); + ClassDecl = OCIT->getDecl(); } } assert(ClassDecl && "missing interface declaration"); diff --git a/test/SemaObjC/invalid-receiver.m b/test/SemaObjC/invalid-receiver.m new file mode 100644 index 0000000000..829ec5dc97 --- /dev/null +++ b/test/SemaObjC/invalid-receiver.m @@ -0,0 +1,9 @@ +// RUN: clang -fsyntax-only -verify %s + +typedef struct NotAClass { + int a, b; +} NotAClass; + +void foo() { + [NotAClass nonexistent_method]; // expected-error {{invalid receiver to message expression}} +}