================ @@ -302,27 +307,43 @@ void Sema::DiagnoseUnusedExprResult(const Stmt *S, unsigned DiagID) { if (const Decl *FD = CE->getCalleeDecl()) { if (ShouldSuppress) return; - if (FD->hasAttr<PureAttr>()) { - Diag(Loc, diag::warn_unused_call) << R1 << R2 << "pure"; - return; - } - if (FD->hasAttr<ConstAttr>()) { - Diag(Loc, diag::warn_unused_call) << R1 << R2 << "const"; + + const InheritableAttr *A = nullptr; + if (const auto *PA = FD->getAttr<PureAttr>()) + A = PA; + else if (const auto *CA = FD->getAttr<ConstAttr>()) + A = CA; + + if (A) { + StringRef type = (isa<PureAttr>(A) ? "pure" : "const"); + Diag(Loc, diag::warn_unused_call) << R1 << R2 << type; + if (const auto *ND = dyn_cast<NamedDecl>(OffendingDecl)) { + if (!ND->getIdentifier()->getBuiltinID()) ---------------- erichkeane wrote:
Hmm... thats actually pretty strange: https://godbolt.org/z/q6EMMs6fa If you make it NOT an error for the first declaration, it does what I suspect it SHOULD be doing in all cases, creating the overload set without a location: https://godbolt.org/z/4zeq99bne So there is perhaps a bug in the builtin recovery we need to understand before we can move on. https://github.com/llvm/llvm-project/pull/112289 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits