Skip to content

Commit 21431e0

Browse files
committed
[clang][Interp] Remove questionable initializer special case
I'm not sure where this would be needed, but for the time being, removing it fixes a problem.
1 parent 925768e commit 21431e0

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,17 +2473,6 @@ bool ByteCodeExprGen<Emitter>::dereferenceVar(
24732473
}
24742474
}
24752475

2476-
// If the declaration is a constant value, emit it here even
2477-
// though the declaration was not evaluated in the current scope.
2478-
// The access mode can only be read in this case.
2479-
if (!DiscardResult && AK == DerefKind::Read) {
2480-
if (VD->hasLocalStorage() && VD->hasInit() && !VD->isConstexpr()) {
2481-
QualType VT = VD->getType();
2482-
if (VT.isConstQualified() && VT->isFundamentalType())
2483-
return this->visit(VD->getInit());
2484-
}
2485-
}
2486-
24872476
// Value cannot be produced - try to emit pointer.
24882477
return visit(LV) && Indirect(T);
24892478
}

clang/test/AST/Interp/functions.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,3 +543,12 @@ namespace StaticLocals {
543543
static_assert(m == 0, "");
544544
}
545545
}
546+
547+
namespace Local {
548+
/// We used to run into infinite recursin here because we were
549+
/// trying to evaluate t's initializer while evaluating t's initializer.
550+
int a() {
551+
const int t=t;
552+
return t;
553+
}
554+
}

0 commit comments

Comments
 (0)