Skip to content

Commit f8d6788

Browse files
committed
Add test for verifier
1 parent eb25aa9 commit f8d6788

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
@@ -1921,7 +1921,7 @@ mlir::Value ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *e) {
19211921
Expr *op = e->getSubExpr();
19221922
if (op->getType()->isAnyComplexType()) {
19231923
// If it's an l-value, load through the appropriate subobject l-value.
1924-
// Note that we have to ask E because Op might be an l-value that
1924+
// Note that we have to ask `e` because `op` might be an l-value that
19251925
// this won't work for, e.g. an Obj-C property.
19261926
if (e->isGLValue()) {
19271927
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
@@ -1938,7 +1938,7 @@ OpFoldResult cir::ComplexRealOp::fold(FoldAdaptor adaptor) {
19381938

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

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,15 @@ module {
3333
cir.return
3434
}
3535
}
36+
37+
// -----
38+
39+
module {
40+
cir.func @complex_imag_invalid_result_type() -> !cir.double {
41+
%0 = cir.alloca !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>, ["c"]
42+
%2 = cir.load align(8) %0 : !cir.ptr<!cir.complex<!cir.double>>, !cir.complex<!cir.double>
43+
// expected-error @below {{result type does not match operand type}}
44+
%3 = cir.complex.imag %2 : !cir.complex<!cir.double> -> !cir.float
45+
cir.return
46+
}
47+
}

0 commit comments

Comments
 (0)