Skip to content

Commit 74f2af5

Browse files
committed
Add support for CK_ToVoid
1 parent d89e963 commit 74f2af5

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
296296
// Handle pointer conversions next: pointers can only be converted to/from
297297
// other pointers and integers. Check for pointer types in terms of LLVM, as
298298
// some native types (like Obj-C id) may map to a pointer type.
299-
if (isa_cast<cir::PointerType>(mlirDstType)) {
299+
if (auto dstPT = dyn_cast<cir::PointerType>(mlirDstType)) {
300300
cgf.getCIRGenModule().errorNYI(loc, "pointer casts");
301301
return builder.getNullPtr(dstPT, src.getLoc());
302302
}
@@ -497,8 +497,7 @@ mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr *ce) {
497497
return builder.createPtrToInt(Visit(subExpr), cgf.convertType(destTy));
498498
}
499499
case CK_ToVoid:
500-
cgf.getCIRGenModule().errorNYI(subExpr->getSourceRange(),
501-
"ignored expression on void cast");
500+
cgf.emitIgnoredExpr(subExpr);
502501
return {};
503502

504503
case CK_IntegralToFloating:

clang/test/CIR/CodeGen/cast.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ void should_not_cast() {
5858

5959
unsigned uu = (unsigned)x1;
6060
bool ib = (bool)x1;
61+
(void) ib;
6162
}
6263

6364
// CHECK: cir.func @should_not_cast

0 commit comments

Comments
 (0)