Skip to content

Commit 7b07102

Browse files
authored
[CIR] Backport fix verifier error messages for Complex Real and Imag (#1720)
Fix the verifier error messages from `unexpected error: 'cir.complex.imag' op cir.complex.imag result type does not match operand type` to `unexpected error: 'cir.complex.imag' op : result type does not match operand type`
1 parent 8bb46a9 commit 7b07102

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ OpFoldResult cir::ComplexCreateOp::fold(FoldAdaptor adaptor) {
921921

922922
LogicalResult cir::ComplexRealOp::verify() {
923923
if (getType() != getOperand().getType().getElementType()) {
924-
emitOpError() << "cir.complex.real result type does not match operand type";
924+
emitOpError() << ": result type does not match operand type";
925925
return failure();
926926
}
927927
return success();
@@ -936,7 +936,7 @@ OpFoldResult cir::ComplexRealOp::fold(FoldAdaptor adaptor) {
936936

937937
LogicalResult cir::ComplexImagOp::verify() {
938938
if (getType() != getOperand().getType().getElementType()) {
939-
emitOpError() << "cir.complex.imag result type does not match operand type";
939+
emitOpError() << ": result type does not match operand type";
940940
return failure();
941941
}
942942
return success();

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: cir-opt %s -verify-diagnostics -split-input-file
2+
3+
module {
4+
cir.func @complex_real_invalid_result_type() -> !cir.double {
5+
%0 = cir.alloca !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>, ["c"]
6+
%2 = cir.load align(8) %0 : !cir.ptr<!cir.complex<!cir.double>>, !cir.complex<!cir.double>
7+
// expected-error @below {{op : result type does not match operand type}}
8+
%3 = cir.complex.real %2 : !cir.complex<!cir.double> -> !cir.float
9+
cir.return
10+
}
11+
}
12+
13+
// -----
14+
15+
module {
16+
cir.func @complex_imag_invalid_result_type() -> !cir.double {
17+
%0 = cir.alloca !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>, ["c"]
18+
%2 = cir.load align(8) %0 : !cir.ptr<!cir.complex<!cir.double>>, !cir.complex<!cir.double>
19+
// expected-error @below {{op : result type does not match operand type}}
20+
%3 = cir.complex.imag %2 : !cir.complex<!cir.double> -> !cir.float
21+
cir.return
22+
}
23+
}

0 commit comments

Comments
 (0)