forked from OSchip/llvm-project
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:
parent
16ad2905a3
commit
95715f9ecf
|
@ -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();
|
||||
|
|
|
@ -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}}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue