Author: Timm Bäder Date: 2024-02-19T12:18:49+01:00 New Revision: 21431e0f94c95703bd76e9ec5d2f0b39b8509680
URL: https://github.com/llvm/llvm-project/commit/21431e0f94c95703bd76e9ec5d2f0b39b8509680 DIFF: https://github.com/llvm/llvm-project/commit/21431e0f94c95703bd76e9ec5d2f0b39b8509680.diff LOG: [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. Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/test/AST/Interp/functions.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index e36a7a0c0a7175..74ed436bdb544b 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -2473,17 +2473,6 @@ bool ByteCodeExprGen<Emitter>::dereferenceVar( } } - // If the declaration is a constant value, emit it here even - // though the declaration was not evaluated in the current scope. - // The access mode can only be read in this case. - if (!DiscardResult && AK == DerefKind::Read) { - if (VD->hasLocalStorage() && VD->hasInit() && !VD->isConstexpr()) { - QualType VT = VD->getType(); - if (VT.isConstQualified() && VT->isFundamentalType()) - return this->visit(VD->getInit()); - } - } - // Value cannot be produced - try to emit pointer. return visit(LV) && Indirect(T); } diff --git a/clang/test/AST/Interp/functions.cpp b/clang/test/AST/Interp/functions.cpp index bf582362460ebc..51269741eb9018 100644 --- a/clang/test/AST/Interp/functions.cpp +++ b/clang/test/AST/Interp/functions.cpp @@ -543,3 +543,12 @@ namespace StaticLocals { static_assert(m == 0, ""); } } + +namespace Local { + /// We used to run into infinite recursin here because we were + /// trying to evaluate t's initializer while evaluating t's initializer. + int a() { + const int t=t; + return t; + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits