================ @@ -834,34 +829,55 @@ void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability( OffendingDecl)) return; - // We would like to emit the diagnostic even if -Wunguarded-availability is - // not specified for deployment targets >= to iOS 11 or equivalent or - // for declarations that were introduced in iOS 11 (macOS 10.13, ...) or - // later. - bool UseNewDiagKind = shouldDiagnoseAvailabilityByDefault( - SemaRef.Context, - SemaRef.Context.getTargetInfo().getPlatformMinVersion(), Introduced); - const TargetInfo &TI = SemaRef.getASTContext().getTargetInfo(); + + // In HLSL, emit diagnostic here during parsing only if the diagnostic + // mode is set to strict (-fhlsl-strict-availability), and either the decl + // availability is not restricted to a specific environment/shader stage, + // or the target stage is known (= it is not shader library). + const LangOptions &LandOpts = SemaRef.getLangOpts(); + if (LandOpts.HLSL) { + if (!LandOpts.HLSLStrictAvailability || + (AA->getEnvironment() != nullptr && + TI.getTriple().getEnvironment() == + llvm::Triple::EnvironmentType::Library)) + return; + } ---------------- hekota wrote:
`shouldDiagnoseAvailabilityByDefault` just determines which diag id to use, not wherther to skip the diagnostic. But I can move it to `ShouldDiagnoseAvailabilityInContext`. https://github.com/llvm/llvm-project/pull/93860 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits