diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index 64b376e101c87..4f7778bdd2ff3 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -1004,7 +1004,7 @@ bool SetThisField(InterpState &S, CodePtr OpPC, uint32_t I) { template ::T> bool GetGlobal(InterpState &S, CodePtr OpPC, uint32_t I) { - auto *B = S.P.getGlobal(I); + const Block *B = S.P.getGlobal(I); if (B->isExtern()) return false; S.Stk.push(B->deref()); diff --git a/clang/lib/AST/Interp/InterpBlock.h b/clang/lib/AST/Interp/InterpBlock.h index 9d0c4859fd06c..9db82567d2d5d 100644 --- a/clang/lib/AST/Interp/InterpBlock.h +++ b/clang/lib/AST/Interp/InterpBlock.h @@ -98,6 +98,9 @@ class Block final { /// Returns a view over the data. template T &deref() { return *reinterpret_cast(data()); } + template const T &deref() const { + return *reinterpret_cast(data()); + } /// Invokes the constructor. void invokeCtor() {