[clang] [clang-tools-extra] Reland [clang][Sema, Lex, Parse] Preprocessor embed in C and C++ (PR #95802)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 20 10:57:50 PDT 2024
Fznamznon wrote:
I'm trying to insert a cast using emitCast:
```
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1347,6 +1347,13 @@ bool ByteCodeExprGen<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
}
auto Eval = [&](Expr *Init, unsigned ElemIndex) {
+ auto ArrayTy = Ctx.getASTContext().getAsConstantArrayType(T);
+ std::optional<PrimType> FromT = classify(Init->getType());
+ std::optional<PrimType> ToT = classify(ArrayTy->getElementType());
+ if (FromT != ToT) {
+ if (!this->emitCast(*FromT, *ToT, Init))
+ return false;
+ }
return visitArrayElemInit(ElemIndex, Init);
};
```
But it fails with an assertion
```
source/llvm-project/clang/lib/AST/Interp/InterpStack.h:46: T clang::interp::InterpStack::pop() [with T = clang::interp::Integral<8, false>]: Asserti
on `ItemTypes.back() == toPrimType<T>()' failed.
```
https://github.com/llvm/llvm-project/pull/95802
More information about the cfe-commits
mailing list