[clang] Warning for incorrect useof 'pure' attribute (PR #78200)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 15 23:33:56 PST 2024
================
@@ -11889,6 +11889,13 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
NewFD->setInvalidDecl();
}
+ if (NewFD->hasAttr<PureAttr>() || NewFD->hasAttr<ConstAttr>()) {
+ if (isa<CXXConstructorDecl>(NewFD))
+ Diag(NewFD->getLocation(), diag::warn_pure_attr_on_cxx_constructor);
+ else if (NewFD->getReturnType()->isVoidType())
+ Diag(NewFD->getLocation(), diag::warn_pure_function_returns_void);
----------------
kelbon wrote:
I think it may be confusing, because name 'const' is similar to keyword 'const', specially for constructor
```cpp
struct A {
A() const;
}
```
But i will check now to improve it
https://github.com/llvm/llvm-project/pull/78200
More information about the cfe-commits
mailing list