[clang] [CUDA][HIP] Fix overriding of constexpr virtual function (PR #121986)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 7 13:35:20 PST 2025


================
@@ -1595,8 +1606,21 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New,
 
         // Allow overloading of functions with same signature and different CUDA
         // target attributes.
-        if (NewTarget != OldTarget)
+        if (NewTarget != OldTarget) {
+          // Special case: non-constexpr function is allowed to override
+          // constexpr virtual function
+          const auto *OldMethod = dyn_cast<CXXMethodDecl>(Old);
+          const auto *NewMethod = dyn_cast<CXXMethodDecl>(New);
----------------
cor3ntin wrote:

OldMethod/NewMethod should still be in scoped and don't need to be redeclared

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


More information about the cfe-commits mailing list