@@ -7354,11 +7354,14 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &CallerRHS,
7354
7354
LHSType->isBlockPointerType()) &&
7355
7355
RHS.get()->isNullPointerConstant(Context,
7356
7356
Expr::NPC_ValueDependentIsNull)) {
7357
- CastKind Kind;
7358
- CXXCastPath Path;
7359
- CheckPointerConversion(RHS.get(), LHSType, Kind, Path, false);
7360
- if (ConvertRHS)
7361
- RHS = ImpCastExprToType(RHS.get(), LHSType, Kind, VK_RValue, &Path);
7357
+ if (Diagnose || ConvertRHS) {
7358
+ CastKind Kind;
7359
+ CXXCastPath Path;
7360
+ CheckPointerConversion(RHS.get(), LHSType, Kind, Path,
7361
+ /*IgnoreBaseAccess=*/false, Diagnose);
7362
+ if (ConvertRHS)
7363
+ RHS = ImpCastExprToType(RHS.get(), LHSType, Kind, VK_RValue, &Path);
7364
+ }
7362
7365
return Compatible;
7363
7366
}
7364
7367
@@ -7376,8 +7379,8 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &CallerRHS,
7376
7379
}
7377
7380
7378
7381
Expr *PRE = RHS.get()->IgnoreParenCasts();
7379
- if (ObjCProtocolExpr *OPE = dyn_cast <ObjCProtocolExpr>(PRE)) {
7380
- ObjCProtocolDecl *PDecl = OPE ->getProtocol();
7382
+ if (Diagnose && isa <ObjCProtocolExpr>(PRE)) {
7383
+ ObjCProtocolDecl *PDecl = cast<ObjCProtocolExpr>(PRE) ->getProtocol();
7381
7384
if (PDecl && !PDecl->hasDefinition()) {
7382
7385
Diag(PRE->getExprLoc(), diag::warn_atprotocol_protocol) << PDecl->getName();
7383
7386
Diag(PDecl->getLocation(), diag::note_entity_declared_at) << PDecl;
@@ -7399,11 +7402,11 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &CallerRHS,
7399
7402
Expr *E = RHS.get();
7400
7403
if (getLangOpts().ObjCAutoRefCount)
7401
7404
CheckObjCARCConversion(SourceRange(), Ty, E, CCK_ImplicitConversion,
7402
- DiagnoseCFAudited);
7405
+ Diagnose, DiagnoseCFAudited);
7403
7406
if (getLangOpts().ObjC1 &&
7404
- (CheckObjCBridgeRelatedConversions(E->getLocStart(),
7405
- LHSType, E->getType(), E) ||
7406
- ConversionToObjCStringLiteralCheck(LHSType, E))) {
7407
+ (CheckObjCBridgeRelatedConversions(E->getLocStart(), LHSType,
7408
+ E->getType(), E, Diagnose ) ||
7409
+ ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose ))) {
7407
7410
RHS = E;
7408
7411
return Compatible;
7409
7412
}
@@ -8961,8 +8964,9 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
8961
8964
else {
8962
8965
Expr *E = RHS.get();
8963
8966
if (getLangOpts().ObjCAutoRefCount)
8964
- CheckObjCARCConversion(SourceRange(), LHSType, E, CCK_ImplicitConversion, false,
8965
- Opc);
8967
+ CheckObjCARCConversion(SourceRange(), LHSType, E,
8968
+ CCK_ImplicitConversion, /*Diagnose=*/true,
8969
+ /*DiagnoseCFAudited=*/false, Opc);
8966
8970
RHS = ImpCastExprToType(E, LHSType,
8967
8971
LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
8968
8972
}
@@ -11830,8 +11834,8 @@ ExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) {
11830
11834
return new (Context) GNUNullExpr(Ty, TokenLoc);
11831
11835
}
11832
11836
11833
- bool
11834
- Sema::ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&Exp ) {
11837
+ bool Sema::ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&Exp,
11838
+ bool Diagnose ) {
11835
11839
if (!getLangOpts().ObjC1)
11836
11840
return false;
11837
11841
@@ -11857,8 +11861,9 @@ Sema::ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&Exp) {
11857
11861
StringLiteral *SL = dyn_cast<StringLiteral>(SrcExpr);
11858
11862
if (!SL || !SL->isAscii())
11859
11863
return false;
11860
- Diag(SL->getLocStart(), diag::err_missing_atsign_prefix)
11861
- << FixItHint::CreateInsertion(SL->getLocStart(), "@");
11864
+ if (Diagnose)
11865
+ Diag(SL->getLocStart(), diag::err_missing_atsign_prefix)
11866
+ << FixItHint::CreateInsertion(SL->getLocStart(), "@");
11862
11867
Exp = BuildObjCStringLiteral(SL->getLocStart(), SL).get();
11863
11868
return true;
11864
11869
}
0 commit comments