@@ -7513,46 +7513,36 @@ void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
7513
7513
}
7514
7514
}
7515
7515
7516
- // If the callee uses AArch64 SME ZA state but the caller doesn't define
7517
- // any, then this is an error.
7518
- FunctionType::ArmStateValue ArmZAState =
7516
+ FunctionType::ArmStateValue CalleeArmZAState =
7519
7517
FunctionType::getArmZAState(ExtInfo.AArch64SMEAttributes);
7520
- if (ArmZAState != FunctionType::ARM_None) {
7518
+ FunctionType::ArmStateValue CalleeArmZT0State =
7519
+ FunctionType::getArmZT0State(ExtInfo.AArch64SMEAttributes);
7520
+ if (CalleeArmZAState != FunctionType::ARM_None ||
7521
+ CalleeArmZT0State != FunctionType::ARM_None) {
7521
7522
bool CallerHasZAState = false;
7523
+ bool CallerHasZT0State = false;
7522
7524
if (const auto *CallerFD = dyn_cast<FunctionDecl>(CurContext)) {
7523
7525
auto *Attr = CallerFD->getAttr<ArmNewAttr>();
7524
7526
if (Attr && Attr->isNewZA())
7525
7527
CallerHasZAState = true;
7526
- else if (const auto *FPT =
7527
- CallerFD->getType()->getAs<FunctionProtoType>())
7528
- CallerHasZAState = FunctionType::getArmZAState(
7529
- FPT->getExtProtoInfo().AArch64SMEAttributes) !=
7530
- FunctionType::ARM_None;
7531
- }
7532
-
7533
- if (!CallerHasZAState)
7534
- Diag(Loc, diag::err_sme_za_call_no_za_state);
7535
- }
7536
-
7537
- // If the callee uses AArch64 SME ZT0 state but the caller doesn't define
7538
- // any, then this is an error.
7539
- FunctionType::ArmStateValue ArmZT0State =
7540
- FunctionType::getArmZT0State(ExtInfo.AArch64SMEAttributes);
7541
- if (ArmZT0State != FunctionType::ARM_None) {
7542
- bool CallerHasZT0State = false;
7543
- if (const auto *CallerFD = dyn_cast<FunctionDecl>(CurContext)) {
7544
- auto *Attr = CallerFD->getAttr<ArmNewAttr>();
7545
7528
if (Attr && Attr->isNewZT0())
7546
7529
CallerHasZT0State = true;
7547
- else if (const auto *FPT =
7548
- CallerFD->getType()->getAs<FunctionProtoType>())
7549
- CallerHasZT0State =
7530
+ if (const auto *FPT = CallerFD->getType()->getAs<FunctionProtoType>()) {
7531
+ CallerHasZAState |=
7532
+ FunctionType::getArmZAState(
7533
+ FPT->getExtProtoInfo().AArch64SMEAttributes) !=
7534
+ FunctionType::ARM_None;
7535
+ CallerHasZT0State |=
7550
7536
FunctionType::getArmZT0State(
7551
7537
FPT->getExtProtoInfo().AArch64SMEAttributes) !=
7552
7538
FunctionType::ARM_None;
7539
+ }
7553
7540
}
7554
7541
7555
- if (!CallerHasZT0State)
7542
+ if (CalleeArmZAState != FunctionType::ARM_None && !CallerHasZAState)
7543
+ Diag(Loc, diag::err_sme_za_call_no_za_state);
7544
+
7545
+ if (CalleeArmZT0State != FunctionType::ARM_None && !CallerHasZT0State)
7556
7546
Diag(Loc, diag::err_sme_zt0_call_no_zt0_state);
7557
7547
}
7558
7548
}
0 commit comments