================
@@ -1918,23 +1918,22 @@ static bool CheckConstexprMissingReturn(Sema &SemaRef, 
const FunctionDecl *Dcl);
 
 bool Sema::CheckConstexprFunctionDefinition(const FunctionDecl *NewFD,
                                             CheckConstexprKind Kind) {
-  const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD);
-  if (MD && MD->isInstance()) {
+  if ((!getLangOpts().CPlusPlus26 && isa<CXXConstructorDecl>(NewFD)) ||
+      ((getLangOpts().CPlusPlus20 && !getLangOpts().CPlusPlus26) &&
+       isa<CXXDestructorDecl>(NewFD))) {
+    const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(NewFD);
----------------
Fznamznon wrote:

That should be a cast because ctor and dtor are both methods and it is 
dereferenced without a null check later.
```suggestion
  if ((!getLangOpts().CPlusPlus26 && isa<CXXConstructorDecl>(NewFD)) ||
      ((getLangOpts().CPlusPlus20 && !getLangOpts().CPlusPlus26) &&
       isa<CXXDestructorDecl>(NewFD))) {
    const CXXMethodDecl *MD = cast<CXXMethodDecl>(NewFD);
```

https://github.com/llvm/llvm-project/pull/163690
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to