60 lines · plain
1// RUN: cir-opt %s -verify-diagnostics -split-input-file2 3!s32i = !cir.int<s, 32>4!s64i = !cir.int<s, 64>5 6module {7 8// expected-error @below {{type of the real part does not match the complex type}}9cir.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 18module {19 20// expected-error @below {{type of the imaginary part does not match the complex type}}21cir.global external @ci2 = #cir.const_complex<#cir.int<1> : !s32i, #cir.int<2> : !s64i> : !cir.complex<!s32i>22 23}24 25// -----26 27module {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.float33 cir.return34 }35}36 37// -----38 39module {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.float45 cir.return46 }47}48 49 50// -----51 52module {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.return58 }59}60