================ @@ -8374,20 +8376,212 @@ static void HandlePtrAuthQualifier(ASTContext &Ctx, QualType &T, IsInvalid |= !S.checkPointerAuthDiscriminatorArg( ExtraDiscriminatorArg, Sema::PADAK_ExtraDiscPtrAuth, ExtraDiscriminator); - if (IsInvalid) { - Attr.setInvalid(); - return; + std::optional<PointerAuthenticationMode> AuthenticationMode = std::nullopt; + SourceRange AuthenticationModeRange; + + if (AuthenticationOptionsArg && !AuthenticationOptionsArg->containsErrors()) { + std::string OptionsString; + bool IsInitialized = false; + const StringLiteral *OptionsStringLiteral = + dyn_cast<StringLiteral>(AuthenticationOptionsArg); + auto ReportEvaluationOfExpressionIfNeeded = [&]() { + if (OptionsStringLiteral || !IsInitialized) + return; + S.Diag(AuthenticationOptionsArg->getBeginLoc(), + diag::note_ptrauth_evaluating_options) + << OptionsString << AuthenticationOptionsArg->getSourceRange(); + }; + auto DiagnoseInvalidOptionsParameter = [&](llvm::StringRef Reason, + std::optional<char> InvalidCh, + auto Location) { + S.Diag(AuthenticationOptionsArg->getExprLoc(), + diag::err_ptrauth_invalid_option) + << AttrName << Reason << Location << !!InvalidCh + << (InvalidCh ? *InvalidCh : '\0'); + Attr.setInvalid(); + ReportEvaluationOfExpressionIfNeeded(); + }; + if (AuthenticationOptionsArg->isValueDependent() || + AuthenticationOptionsArg->isTypeDependent()) { + DiagnoseInvalidOptionsParameter( + "is dependent", std::nullopt, + AuthenticationOptionsArg->getSourceRange()); + return; ---------------- ojhunt wrote:
@cor3ntin oh, when you say delayed until later do you mean template instantiation? That would be nice but currently the ptrauth qualifier does not support dependent parameters at all - it's something I've wanted to add support for (because it would be very useful) but is never high enough on the priority list, and seems to require an inordinate amount of seemingly mechanical work to achieve :-/ https://github.com/llvm/llvm-project/pull/136828 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits