]> granicus.if.org Git - clang/commitdiff
Fix crash-on-invalid where a ParenListExpr shows up as a message receiver
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 15 Feb 2013 18:34:15 +0000 (18:34 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Fri, 15 Feb 2013 18:34:15 +0000 (18:34 +0000)
while trying to do error recovery.

rdar://13207886

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175282 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprObjC.cpp
test/SemaObjC/message.m

index 7f0c832575b47153e6085b4c949f5ef48f7a9a8c..76ee98371227522ce2c1dd1063a7a7d77fed9638 100644 (file)
@@ -2485,6 +2485,13 @@ ExprResult Sema::ActOnInstanceMessage(Scope *S,
                                       MultiExprArg Args) {
   if (!Receiver)
     return ExprError();
+
+  // A ParenListExpr can show up while doing error recovery with invalid code.
+  if (isa<ParenListExpr>(Receiver)) {
+    ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Receiver);
+    if (Result.isInvalid()) return ExprError();
+    Receiver = Result.take();
+  }
   
   if (RespondsToSelectorSel.isNull()) {
     IdentifierInfo *SelectorId = &Context.Idents.get("respondsToSelector");
index 621a18fc9bf003af1ebf9f791197c0cfbb9694ad..4015690bd0a742353e4f9039c4e2b40d9414777f 100644 (file)
@@ -98,3 +98,11 @@ void foo4() {
   [X rect]; // expected-warning {{receiver type 'struct objc_object *' is not 'id' or interface pointer, consider casting it to 'id'}} expected-warning {{method '-rect' not found (return type defaults to 'id')}}
 }
 
+// rdar://13207886
+void foo5(id p) {
+  p
+  [(id)(p) bar]; // expected-error {{missing '['}} \
+                 // expected-error {{expected ']'}} \
+                 // expected-note {{to match this '['}} \
+                 // expected-warning {{instance method '-bar' not found}}
+}