[clang] [clang][bytecode] Dummy variables can have pointers to them (PR #166908)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 7 00:55:27 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

at the point when they become proper globals.

---
Full diff: https://github.com/llvm/llvm-project/pull/166908.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Program.cpp (+2-1) 
- (modified) clang/test/SemaCXX/cxx2b-consteval-propagate.cpp (+2) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index 4d34e0b0a9b46..c468303efea7e 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -197,7 +197,8 @@ UnsignedOrNone Program::createGlobal(const ValueDecl *VD, const Expr *Init) {
     // global variable and points to the block we just created.
     if (auto DummyIt = DummyVariables.find(Redecl);
         DummyIt != DummyVariables.end()) {
-      assert(!Globals[DummyIt->second]->block()->hasPointers());
+      Global *Dummy = Globals[DummyIt->second];
+      Dummy->block()->movePointersTo(NewGlobal->block());
       Globals[DummyIt->second] = NewGlobal;
       DummyVariables.erase(DummyIt);
     }
diff --git a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
index 331fe8387e1c7..ff104243a9735 100644
--- a/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
+++ b/clang/test/SemaCXX/cxx2b-consteval-propagate.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++2a -Wno-unused-value %s -verify
+// RUN: %clang_cc1 -std=c++2a -Wno-unused-value %s -verify -fexperimental-new-constant-interpreter
 // RUN: %clang_cc1 -std=c++2b -Wno-unused-value %s -verify
+// RUN: %clang_cc1 -std=c++2b -Wno-unused-value %s -verify -fexperimental-new-constant-interpreter
 
 consteval int id(int i) { return i; }
 constexpr char id(char c) { return c; }

``````````

</details>


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


More information about the cfe-commits mailing list