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

Recursive DataStructures must be validated and reported as a problem #686

Closed
riederm opened this issue Dec 8, 2022 · 0 comments · Fixed by #721
Closed

Recursive DataStructures must be validated and reported as a problem #686

riederm opened this issue Dec 8, 2022 · 0 comments · Fixed by #721
Labels
validation candidate for syntactic or semantic validation

Comments

@riederm
Copy link
Collaborator

riederm commented Dec 8, 2022

Recursive datastructures cannot be declared in ST. We need a validation to permit users from declaring such datastructures using STRUCTS, FB and CLASSES.

example:

TYPE A: STRUCT
     other: B;
END_STRUCT
END_TYPE

TYPE B: STRUCT
     other: A;
END_STRUCT
END_TYPE

Such recursions can be immediate (a struct containing itself) but they can also be formed over numerous hops (A->B->...->H->A).

We basically need to show that the declaration-graph (starting from all global variables and all programs) contains no cycles.

Every cycle should be reported as a problem.

Note that POINTER-declarations must not be treated as edges in the declaration-graph.

@riederm riederm added the validation candidate for syntactic or semantic validation label Dec 8, 2022
volsa added a commit that referenced this issue Jan 31, 2023
Recursive data structures such as structs, arrays within structs as well as function blocks are now correctly detected and displayed as errors. For example a self-referencing struct such as 
```
TYPE A : STRUCT
    a : A;
END_STRUCT END_TYPE
```
will now generate the error message `Recursive data structure `A -> A` has infinite size`. Despite detecting such recursions the compiler will still crash with this commit because we do not abort codegen.
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.

1 participant