Commit a2bfdbb
[CIR][IR] Relax get_member verifier for incomplete types (#269)
This is a suggestion to relax the existing verification even more than
we did it in PR #257.
Here we also skip verification if a field on the given index is also of
incomplete type - and we can not compare it with the result type of the
operation.
Now the next code fails with type mismatch error:
```
typedef struct Node {
struct Node* next;
} NodeStru;
void foo(NodeStru* a) {
a->next = 0;
}
```
because the result type is kind of full and the type of field is not
(for the reasons discussed in #256).
Basically, the problem is in the `GetMemberOp` result type generated as
following (via `CIRGenTypes::convertType`)
`!cir.ptr<!cir.struct<struct "Node" {!cir.ptr<!cir.struct<struct "Node"
incomplete #cir.record.decl.ast>>} #cir.record.decl.ast>>`
where the field type at index differs from the record type - compare
with
`!cir.ptr<!cir.struct<struct "Node" incomplete #cir.record.decl.ast>>`
We just slightly relax the previous solution in #257 - and the
compilation won't fail in the case of recursive types.
Well, if there are some other thoughts?1 parent c47ec75 commit a2bfdbb
File tree
2 files changed
+28
-3
lines changed- clang
- lib/CIR/Dialect/IR
- test/CIR/CodeGen
2 files changed
+28
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2412 | 2412 | | |
2413 | 2413 | | |
2414 | 2414 | | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
2415 | 2423 | | |
2416 | 2424 | | |
2417 | 2425 | | |
| |||
2424 | 2432 | | |
2425 | 2433 | | |
2426 | 2434 | | |
2427 | | - | |
| 2435 | + | |
2428 | 2436 | | |
2429 | 2437 | | |
2430 | 2438 | | |
2431 | 2439 | | |
2432 | 2440 | | |
2433 | 2441 | | |
2434 | 2442 | | |
2435 | | - | |
2436 | | - | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
2437 | 2449 | | |
2438 | 2450 | | |
2439 | 2451 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| 25 | + | |
| 26 | + | |
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
| |||
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
0 commit comments