Debian Codegraph @

clang/test/CIR/IR/invalid-const-record.cir

raw
1 // RUN: cir-opt %s -verify-diagnostics -split-input-file
2
3 !s32i = !cir.int<s, 32>
4 !rec_anon_struct = !cir.record<struct packed {!s32i, !s32i, !cir.array<!s32i x 8>}>
5
6 // expected-error @below {{expected !cir.record type}}
7 cir.global external @e = #cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.zero : !cir.array<!s32i x 8>}> : !cir.ptr<!rec_anon_struct>
8
9 // -----
10
11 !s32i = !cir.int<s, 32>
12 !rec_anon_struct = !cir.record<struct packed {!s32i, !s32i, !cir.array<!s32i x 8>}>
13
14 // expected-error @below {{number of elements must match}}
15 cir.global external @e = #cir.const_record<{#cir.int<1> : !s32i, #cir.zero : !cir.array<!s32i x 8>}> : !rec_anon_struct
16
17 // -----
18
19 !s32i = !cir.int<s, 32>
20 !rec_anon_struct = !cir.record<struct packed {!s32i, !s32i, !cir.array<!s32i x 8>}>
21
22 // expected-error @below {{element at index 1 has type '!cir.float' but the expected type for this element is '!cir.int<s, 32>'}}
23 cir.global external @e = #cir.const_record<{#cir.int<1> : !s32i, #cir.fp<2.000000e+00> : !cir.float, #cir.zero : !cir.array<!s32i x 8>}> : !rec_anon_struct