forked from PLC-lang/rusty
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(resolver): Annotate assignments with a hint when dealing with str…
…ucts (PLC-lang#1020) Fixes PLC-lang#1019 This commit adds a type-hint on struct field assignments when dealing with array of structs. For example given structs - `STRUCT1 { idx: DINT, arr: ARRAY[...] OF STRUCT2 }` and - `STRUCT2 { x: DINT, y: DINT }` The following snippet `ARRAY[1..3] OF STRUCT1 := [(idx := 0, arr := [(x := 1)])];` will result in `idx := 0` having a type-hint on `STRUCT1` and `x := 1` on `STRUCT2`
- Loading branch information
Showing
5 changed files
with
132 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...__type_initializers__skipped_field_members_for_array_of_structs_are_zero_initialized.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
source: src/codegen/tests/initialization_test/type_initializers.rs | ||
expression: res | ||
--- | ||
; ModuleID = 'main' | ||
source_filename = "main" | ||
|
||
%main = type { [3 x %STRUCT1] } | ||
%STRUCT1 = type { i32, [2 x %STRUCT2] } | ||
%STRUCT2 = type { i32, i32 } | ||
|
||
@main_instance = global %main { [3 x %STRUCT1] [%STRUCT1 { i32 0, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 2, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 1 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 1, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 { i32 0, i32 2 }] }] } | ||
@__STRUCT1__init = unnamed_addr constant %STRUCT1 zeroinitializer | ||
@__STRUCT2__init = unnamed_addr constant %STRUCT2 zeroinitializer | ||
@__main.var_init1__init = unnamed_addr constant [3 x %STRUCT1] [%STRUCT1 { i32 0, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 2, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 1 }, %STRUCT2 zeroinitializer] }, %STRUCT1 { i32 1, [2 x %STRUCT2] [%STRUCT2 { i32 1, i32 0 }, %STRUCT2 { i32 0, i32 2 }] }] | ||
|
||
define void @main(%main* %0) { | ||
entry: | ||
%var_init1 = getelementptr inbounds %main, %main* %0, i32 0, i32 0 | ||
ret void | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters