================
@@ -11792,6 +11792,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->dropAttr<PureAttr>();
+  }
+  if (IsPure || IsConst) {
+    // constructors and destructors also functions which returns void
+    if (NewFD->getReturnType()->isVoidType()) {
+      S.Diag(NewFD->getLocation(), diag::warn_pure_function_returns_void)
+          << IsConst;
+      NewFD->dropAttr<PureAttr>();
+      NewFD->dropAttr<ConstAttr>();
----------------
erichkeane wrote:

Done here: https://github.com/llvm/llvm-project/pull/78476

Note that the 2nd and the 3rd from your list are actually from different decls, 
so don't help.

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