[clang] [OpenCL] Suppress -Wreturn-stack-address for function-scope local variable (PR #181602)

Wenju He via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 18 19:01:28 PST 2026


================
@@ -1337,6 +1337,13 @@ checkExprLifetimeImpl(Sema &SemaRef, const InitializedEntity *InitEntity,
         // expression.
         if (LK == LK_StmtExprResult)
           return false;
+        if (auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
+          if (VD->getType().getAddressSpace() == LangAS::opencl_local &&
+              SemaRef.getOpenCLOptions().isAvailableOption(
+                  "__cl_clang_function_scope_local_variables",
+                  SemaRef.getLangOpts()))
----------------
wenju-he wrote:

> Shouldn't need to check if the extension is enabled

done, dropped the extension check.

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


More information about the cfe-commits mailing list