Skip to content

Commit a96ad13

Browse files
authored
[clang][bytecode] Dummy variables can have pointers to them (#166908)
at the point when they become proper globals.
1 parent 9a8203d commit a96ad13

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/lib/AST/ByteCode/Program.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ UnsignedOrNone Program::createGlobal(const ValueDecl *VD, const Expr *Init) {
197197
// global variable and points to the block we just created.
198198
if (auto DummyIt = DummyVariables.find(Redecl);
199199
DummyIt != DummyVariables.end()) {
200-
assert(!Globals[DummyIt->second]->block()->hasPointers());
200+
Global *Dummy = Globals[DummyIt->second];
201+
Dummy->block()->movePointersTo(NewGlobal->block());
201202
Globals[DummyIt->second] = NewGlobal;
202203
DummyVariables.erase(DummyIt);
203204
}

clang/test/SemaCXX/cxx2b-consteval-propagate.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// RUN: %clang_cc1 -std=c++2a -Wno-unused-value %s -verify
2+
// RUN: %clang_cc1 -std=c++2a -Wno-unused-value %s -verify -fexperimental-new-constant-interpreter
23
// RUN: %clang_cc1 -std=c++2b -Wno-unused-value %s -verify
4+
// RUN: %clang_cc1 -std=c++2b -Wno-unused-value %s -verify -fexperimental-new-constant-interpreter
35

46
consteval int id(int i) { return i; }
57
constexpr char id(char c) { return c; }

0 commit comments

Comments
 (0)