| 1 |
// RUN: cir-opt %s -verify-diagnostics -split-input-file |
| 2 |
|
| 3 |
// ----- |
| 4 |
|
| 5 |
!u16i = !cir.int<u, 16> |
| 6 |
!u32i = !cir.int<u, 32> |
| 7 |
!struct1 = !cir.record<struct "Struct1" {!u16i, !u32i}> |
| 8 |
|
| 9 |
// expected-error@+1 {{member type of a #cir.data_member attribute must match the attribute type}} |
| 10 |
#invalid_member_ty = #cir.data_member<0> : !cir.data_member<!u32i in !struct1> |
| 11 |
|
| 12 |
// ----- |
| 13 |
|
| 14 |
!u16i = !cir.int<u, 16> |
| 15 |
!incomplete_struct = !cir.record<struct "Incomplete" incomplete> |
| 16 |
|
| 17 |
// expected-error@+1 {{incomplete 'cir.record' cannot be used to build a non-null data member pointer}} |
| 18 |
#incomplete_cls_member = #cir.data_member<0> : !cir.data_member<!u16i in !incomplete_struct> |
| 19 |
|
| 20 |
// ----- |
| 21 |
|
| 22 |
!u16i = !cir.int<u, 16> |
| 23 |
!u32i = !cir.int<u, 32> |
| 24 |
!struct1 = !cir.record<struct "Struct1" {!u16i, !u32i}> |
| 25 |
|
| 26 |
// expected-error@+1 {{member index of a #cir.data_member attribute is out of range}} |
| 27 |
#invalid_member_ty = #cir.data_member<2> : !cir.data_member<!u32i in !struct1> |
| 28 |
|
| 29 |
// ----- |
| 30 |
|
| 31 |
!u16i = !cir.int<u, 16> |
| 32 |
!u32i = !cir.int<u, 32> |
| 33 |
!struct1 = !cir.record<struct "Struct1" {!u16i, !u32i}> |
| 34 |
!struct2 = !cir.record<struct "Struct2" {!u16i, !u32i}> |
| 35 |
|
| 36 |
module { |
| 37 |
cir.func @invalid_base_type(%arg0 : !cir.data_member<!u32i in !struct1>) { |
| 38 |
%0 = cir.alloca !struct2, !cir.ptr<!struct2>, ["tmp"] {alignment = 4 : i64} |
| 39 |
// expected-error@+1 {{record type does not match the member pointer type}} |
| 40 |
%1 = cir.get_runtime_member %0[%arg0 : !cir.data_member<!u32i in !struct1>] : !cir.ptr<!struct2> -> !cir.ptr<!u32i> |
| 41 |
cir.return |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
// ----- |
| 46 |
|
| 47 |
!u16i = !cir.int<u, 16> |
| 48 |
!u32i = !cir.int<u, 32> |
| 49 |
!struct1 = !cir.record<struct "Struct1" {!u16i, !u32i}> |
| 50 |
|
| 51 |
module { |
| 52 |
cir.func @invalid_base_type(%arg0 : !cir.data_member<!u32i in !struct1>) { |
| 53 |
%0 = cir.alloca !struct1, !cir.ptr<!struct1>, ["tmp"] {alignment = 4 : i64} |
| 54 |
// expected-error@+1 {{result type does not match the member pointer type}} |
| 55 |
%1 = cir.get_runtime_member %0[%arg0 : !cir.data_member<!u32i in !struct1>] : !cir.ptr<!struct1> -> !cir.ptr<!u16i> |
| 56 |
cir.return |
| 57 |
} |
| 58 |
} |