https://github.com/StephenYoung2754 updated https://github.com/llvm/llvm-project/pull/157585
>From 41d2b7628de0471145979ae67a7af750dc8ac77a Mon Sep 17 00:00:00 2001 From: StephenYoung2754 <stephenyoung2...@gmail.com> Date: Tue, 9 Sep 2025 08:55:15 +0800 Subject: [PATCH] [AST] StructuralEquivalence: avoid diagnostics when Complain=false in CheckStructurallyEquivalentAttributes --- clang/lib/AST/ASTStructuralEquivalence.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp index 1292c30d47589..94512488d0738 100644 --- a/clang/lib/AST/ASTStructuralEquivalence.cpp +++ b/clang/lib/AST/ASTStructuralEquivalence.cpp @@ -471,15 +471,18 @@ CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context, if (D2->hasAttrs()) D2Attr = *D2->getAttrs().begin(); if ((D1Attr || D2Attr) && !D1->isImplicit() && !D2->isImplicit()) { - const auto *DiagnoseDecl = cast<TypeDecl>(PrimaryDecl ? PrimaryDecl : D2); - Context.Diag2(DiagnoseDecl->getLocation(), - diag::warn_odr_tag_type_with_attributes) - << Context.ToCtx.getTypeDeclType(DiagnoseDecl) - << (PrimaryDecl != nullptr); - if (D1Attr) - Context.Diag1(D1Attr->getLoc(), diag::note_odr_attr_here) << D1Attr; - if (D2Attr) - Context.Diag1(D2Attr->getLoc(), diag::note_odr_attr_here) << D2Attr; + if (!Context.Complain) + return false; + const auto *DiagnoseDecl = cast<TypeDecl>(PrimaryDecl ? PrimaryDecl : D2); + Context.Diag2(DiagnoseDecl->getLocation(), + diag::warn_odr_tag_type_with_attributes) + << Context.ToCtx.getTypeDeclType(DiagnoseDecl) + << (PrimaryDecl != nullptr); + if (D1Attr) + Context.Diag1(D1Attr->getLoc(), diag::note_odr_attr_here) << D1Attr; + if (D2Attr) + Context.Diag2(D2Attr->getLoc(), diag::note_odr_attr_here) << D2Attr; + return false; } // The above diagnostic is a warning which defaults to an error. If treated _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits