Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate warnings if a downcast is involved in a function call #729

Closed
Tracked by #737
volsa opened this issue Jan 13, 2023 · 0 comments · Fixed by #760
Closed
Tracked by #737

Generate warnings if a downcast is involved in a function call #729

volsa opened this issue Jan 13, 2023 · 0 comments · Fixed by #760
Assignees
Labels
validation candidate for syntactic or semantic validation

Comments

@volsa
Copy link
Member

volsa commented Jan 13, 2023

Given the following code snippet

FUNCTION fn_int : INT
    VAR_INPUT {ref}
        in_ref : INT;
    END_VAR
    VAR_IN_OUT
        in_out : INT;
    END_VAR
END_FUNCTION

PROGRAM main
    VAR
        var1_lint, var2_lint : LINT := 4;
    END_VAR

    fn_int(var1_lint, var2_lint);
END_PROGRAM

Rusty currently does not generate any warnings although the arguments are incompatible with the function signature. Once issue #698 is implemented, whether it's going to be in the form of a bitcast[1] or a truncate instruction, potential data-loss might be involved. Thus it would be nice if some warnings are generated for the end-user. For reference, clang generates something along

warning: incompatible pointer types passing 'long *' to parameter of type 'int *' [-Wincompatible-pointer-types]

[1] as it is implemented in the current PR where the IR looks similar to its C counter-part, i.e.

  %var1_lint = getelementptr inbounds %main, %main* %0, i32 0, i32 0
  %var2_lint = getelementptr inbounds %main, %main* %0, i32 0, i32 1
  %1 = bitcast i64* %var1_lint to i16*
  %2 = bitcast i64* %var2_lint to i16*
  %call = call i16 @fn_int(i16* %1, i16* %2)
@volsa volsa changed the title Generate warnings when a downcast is involved in a function call Generate warnings if a downcast is involved in a function call Jan 13, 2023
@99NIMI 99NIMI mentioned this issue Jan 26, 2023
5 tasks
@mhasel mhasel self-assigned this Jan 31, 2023
@mhasel mhasel linked a pull request Feb 3, 2023 that will close this issue
@99NIMI 99NIMI added the validation candidate for syntactic or semantic validation label Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation candidate for syntactic or semantic validation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants