[clang] Warning for incorrect useof 'pure' attribute (PR #78200)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 17 07:47:51 PST 2024
================
@@ -11792,6 +11792,32 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD,
OldDecl, Previous);
}
+static void CheckFunctionDeclarationAttributesUsage(Sema &S,
+ FunctionDecl *NewFD) {
+ const bool is_pure = NewFD->hasAttr<PureAttr>();
+ const bool is_const = NewFD->hasAttr<ConstAttr>();
+
+ if (is_pure && is_const) {
+ S.Diag(NewFD->getLocation(), diag::warn_const_attr_with_pure_attr);
+ NewFD->dropAttr<PureAttr>();
+ }
+ if (is_pure || is_const) {
+ if (isa<CXXConstructorDecl>(NewFD)) {
----------------
erichkeane wrote:
>(not counting placement new)
Thats a big 'not counting' there...
`A a = A(args...);`
That isn't calling the constructor, that is effectively 'constructing an object, then copying it to the LHS (though we omit the copy)'.
`A a{args...};` is also valid, which shows that it isn't the same.
https://github.com/llvm/llvm-project/pull/78200
More information about the cfe-commits
mailing list