llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> We don't want to allow e.g. cast from a record to an array or the other way arround. --- Full diff: https://github.com/llvm/llvm-project/pull/107564.diff 1 Files Affected: - (modified) clang/lib/AST/ByteCode/Compiler.cpp (+9-2) ``````````diff diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index a831f196abdcb5..c376dd8325fe2e 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -2478,8 +2478,15 @@ bool Compiler<Emitter>::VisitCXXReinterpretCastExpr( const CXXReinterpretCastExpr *E) { const Expr *SubExpr = E->getSubExpr(); - bool TypesMatch = classify(E) == classify(SubExpr); - if (!this->emitInvalidCast(CastKind::Reinterpret, /*Fatal=*/!TypesMatch, E)) + bool Fatal = false; + std::optional<PrimType> FromT = classify(SubExpr); + std::optional<PrimType> ToT = classify(E); + if (!FromT || !ToT) + Fatal = true; + else + Fatal = (ToT != FromT); + + if (!this->emitInvalidCast(CastKind::Reinterpret, Fatal, E)) return false; return this->delegate(SubExpr); `````````` </details> https://github.com/llvm/llvm-project/pull/107564 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits