================ @@ -11801,6 +11801,26 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD, OldDecl, Previous); } +static void CheckFunctionDeclarationAttributesUsage(Sema &S, + FunctionDecl *NewFD) { + bool IsPure = NewFD->hasAttr<PureAttr>(); + bool IsConst = NewFD->hasAttr<ConstAttr>(); + + if (IsPure && IsConst) { + S.Diag(NewFD->getLocation(), diag::warn_const_attr_with_pure_attr); + NewFD->dropAttrs<PureAttr>(); + } + if (!IsPure && !IsConst) + return; ---------------- AaronBallman wrote:
```suggestion // If there are no pure or const attributes, there's nothing to check. if (!IsPure || !IsConst) return; // If the function is marked both pure and const, we retain the const attribute // because it makes stronger guarantees than the pure attribute, and we drop // the pure attribute explicitly to prevent later confusion about semantics. if (IsPure && IsConst) { S.Diag(NewFD->getLocation(), diag::warn_const_attr_with_pure_attr); NewFD->dropAttrs<PureAttr>(); } ``` Rearranging the logic and adding some comments. https://github.com/llvm/llvm-project/pull/78200 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits