================
@@ -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);
----------------
ChuanqiXu9 wrote:

Then the title and the diagnostic might be confusing if the user are using 
`[[gnu::const]]`.  You can look at the use of `%select` in 
`clang/include/clang/Basic/DiagnosticSemaKinds.td` to improve this. Also we 
need a test for `[[gnu::const]]` too.

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

Reply via email to