[clang] [clang][Sema] Don't diagnose unevaluated or constant-evaluated device code (PR #244019)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 26 04:54:24 PST 2026
================
@@ -2063,6 +2071,19 @@ class DeferredDiagnosticsEmitter
asImpl().visitUsedDecl(Dtor->getLocation(), Dtor);
}
+ // Skip initializers evaluated at compile time.
+ auto IsConstantInitialized = [&](const Decl *D) {
+ const auto *VD = dyn_cast<VarDecl>(D);
+ return VD && VD->isUsableInConstantExpressions(S.Context);
+ };
+ if (llvm::any_of(DS->decls(), IsConstantInitialized)) {
+ for (auto *D : DS->decls())
+ if (auto *VD = dyn_cast<VarDecl>(D); VD && !IsConstantInitialized(VD))
+ if (Expr *Init = VD->getInit())
----------------
yxsamliu wrote:
Could we still check the array bound here? In HIP, `int &ref = backing, arr[helper(b)];` loses the host-only call error. Splitting it into two declarations brings the error back.
https://github.com/llvm/llvm-project/pull/244019
More information about the cfe-commits
mailing list