summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimm Baeder <tbaeder@redhat.com>2025-11-07 10:51:17 +0100
committerGitHub <noreply@github.com>2025-11-07 10:51:17 +0100
commita96ad136f6f6116a369337c52d0e86f94c548e8c (patch)
tree2323062d4d77cdce2ef14d3fce851a5ffd1a6234
parent9a8203df3f7aecf1ffe5362866ea0cd6c44abbd8 (diff)
[clang][bytecode] Dummy variables can have pointers to them (#166908)
at the point when they become proper globals.
-rw-r--r--clang/lib/AST/ByteCode/Program.cpp3
-rw-r--r--clang/test/SemaCXX/cxx2b-consteval-propagate.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index 4d34e0b0a9b4..c468303efea7 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 331fe8387e1c..ff104243a973 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; }