[clang] Warning for incorrect useof 'pure' attribute (PR #78200)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 18:24:05 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())
----------------
ChuanqiXu9 wrote:

Also let's get some comments for the rationale here even if you feel it is obivious.

https://github.com/llvm/llvm-project/pull/78200


More information about the cfe-commits mailing list