In debugger support mode, if we have a top-level message send

expression with an unknown result type, assume that the result type is
'id'. Fixes <rdar://problem/10400663>.

llvm-svn: 146622
This commit is contained in:
Douglas Gregor 2011-12-15 00:53:32 +00:00
parent 16ad2905a3
commit 95715f9ecf
3 changed files with 18 additions and 3 deletions

View File

@ -4674,6 +4674,15 @@ ExprResult Sema::ActOnFinishFullExpr(Expr *FE) {
if (DiagnoseUnexpandedParameterPack(FullExpr.get()))
return ExprError();
// Top-level message sends default to 'id' when we're in a debugger.
if (getLangOptions().DebuggerSupport &&
FullExpr.get()->getType() == Context.UnknownAnyTy &&
isa<ObjCMessageExpr>(FullExpr.get())) {
FullExpr = forceUnknownAnyToType(FullExpr.take(), Context.getObjCIdType());
if (FullExpr.isInvalid())
return ExprError();
}
FullExpr = CheckPlaceholderExpr(FullExpr.take());
if (FullExpr.isInvalid())
return ExprError();

View File

@ -17,8 +17,13 @@ void test_unknown_anytype_receiver() {
int *ip = [test0 getIntPtr];
float *fp = [test1() getFloatPtr];
double *dp = [test1() getSomePtr]; // okay: picks first method found
[[test0 unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
[[test0 unknownMethod] otherUnknownMethod];
(void)(int)[[test0 unknownMethod] otherUnknownMethod];;
[[test1() unknownMethod] otherUnknownMethod]; // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
[[test1() unknownMethod] otherUnknownMethod];
(void)(id)[[test1() unknownMethod] otherUnknownMethod];
if ([[test0 unknownMethod] otherUnknownMethod]) { // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
}
if ([[test1() unknownMethod] otherUnknownMethod]) { // expected-error{{no known method '-otherUnknownMethod'; cast the message send to the method's return type}}
}
}

View File

@ -3,6 +3,7 @@
// rdar://problem/9416370
namespace test0 {
void test(id x) {
[x foo]; // expected-error {{no known method '-foo'; cast the message send to the method's return type}}
if ([x foo]) {} // expected-error {{no known method '-foo'; cast the message send to the method's return type}}
[x foo];
}
}