Skip to content

Commit d868df3

Browse files
committed
Add test for verifier
1 parent e3a6c2e commit d868df3

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,7 @@ mlir::Value ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *e) {
18981898
Expr *op = e->getSubExpr();
18991899
if (op->getType()->isAnyComplexType()) {
19001900
// If it's an l-value, load through the appropriate subobject l-value.
1901-
// Note that we have to ask E because Op might be an l-value that
1901+
// Note that we have to ask `e` because `op` might be an l-value that
19021902
// this won't work for, e.g. an Obj-C property.
19031903
if (e->isGLValue()) {
19041904
mlir::Location loc = cgf.getLoc(e->getExprLoc());

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ OpFoldResult cir::ComplexCreateOp::fold(FoldAdaptor adaptor) {
19391939

19401940
LogicalResult cir::ComplexImagOp::verify() {
19411941
if (getType() != getOperand().getType().getElementType()) {
1942-
emitOpError() << "cir.complex.imag result type does not match operand type";
1942+
emitOpError() << ": result type does not match operand type";
19431943
return failure();
19441944
}
19451945
return success();

clang/test/CIR/IR/invalid-complex.cir

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,15 @@ module {
2121
cir.global external @ci2 = #cir.const_complex<#cir.int<1> : !s32i, #cir.int<2> : !s64i> : !cir.complex<!s32i>
2222

2323
}
24+
25+
// -----
26+
27+
module {
28+
cir.func @complex_imag_invalid_result_type() -> !cir.double {
29+
%0 = cir.alloca !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>, ["c"]
30+
%2 = cir.load align(8) %0 : !cir.ptr<!cir.complex<!cir.double>>, !cir.complex<!cir.double>
31+
// expected-error @below {{result type does not match operand type}}
32+
%3 = cir.complex.imag %2 : !cir.complex<!cir.double> -> !cir.float
33+
cir.return
34+
}
35+
}

0 commit comments

Comments
 (0)