[SemaObjC] Fix a crash on an invalid ternary with ARC pointers

FindCompositeObjCPointerType nulls out the subexpressions on error, so bail out
instead of trying to deref them.
This commit is contained in:
Erik Pilkington 2020-10-13 12:40:55 -04:00
parent bcdd4359e1
commit 498c7fa48a
2 changed files with 9 additions and 0 deletions

View File

@ -6325,6 +6325,8 @@ QualType Sema::CXXCheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
// Similarly, attempt to find composite type of two objective-c pointers.
Composite = FindCompositeObjCPointerType(LHS, RHS, QuestionLoc);
if (LHS.isInvalid() || RHS.isInvalid())
return QualType();
if (!Composite.isNull())
return Composite;

View File

@ -216,3 +216,10 @@ void ownership_transfer_in_cast(void *vp, Block *pblk) {
// Make sure we don't crash.
void writeback_test(NSString & &) {} // expected-error {{type name declared as a reference to a reference}}
void test_strong_opaque() {
__strong NSString *sptr;
void *vptr;
(void)(0 ? sptr : vptr); // expected-error{{operands to conditional of types 'NSString *' and 'void *' are incompatible in ARC mode}}
}