Debian Codegraph @

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

raw
1 // RUN: cir-opt %s -verify-diagnostics -split-input-file
2
3 !s32i = !cir.int<s, 32>
4 !s64i = !cir.int<s, 64>
5
6 module {
7
8 // expected-error @below {{type of the real part does not match the complex type}}
9 cir.global external @ci2 = #cir.const_complex<#cir.int<1> : !s64i, #cir.int<2> : !s32i> : !cir.complex<!s32i>
10
11 }
12
13 // -----
14
15 !s32i = !cir.int<s, 32>
16 !s64i = !cir.int<s, 64>
17
18 module {
19
20 // expected-error @below {{type of the imaginary part does not match the complex type}}
21 cir.global external @ci2 = #cir.const_complex<#cir.int<1> : !s32i, #cir.int<2> : !s64i> : !cir.complex<!s32i>
22
23 }
24
25 // -----
26
27 module {
28 cir.func @complex_real_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.real %2 : !cir.complex<!cir.double> -> !cir.float
33 cir.return
34 }
35 }
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 }
48
49
50 // -----
51
52 module {
53 cir.func @complex_real_ptr_invalid_result_type() -> !cir.double {
54 %0 = cir.alloca !cir.complex<!cir.double>, !cir.ptr<!cir.complex<!cir.double>>, ["c"]
55 // expected-error @below {{result type does not match operand type}}
56 %1 = cir.complex.real_ptr %0 : !cir.ptr<!cir.complex<!cir.double>> -> !cir.ptr<!cir.float>
57 cir.return
58 }
59 }