-
Notifications
You must be signed in to change notification settings - Fork 1.3k
halcompile: reject declarations that claim the same HAL name #4298
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
Open
tzuohann
wants to merge
1
commit into
LinuxCNC:master
Choose a base branch
from
tzuohann:halcompile-halname-upstream
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+191
−6
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,8 @@ | ||
| array_limit.c | ||
| collide_array.c | ||
| collide_funct_time.c | ||
| collide_function.c | ||
| collide_personality.c | ||
| collide_pin_param.c | ||
| collide_pin_pin.c | ||
| separate_namespaces.c |
This file contains hidden or 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,6 @@ | ||
| component array_limit; | ||
| license "GPL"; | ||
| pin in bool x_#[257]; | ||
| function _; | ||
| ;; | ||
| FUNCTION(_) {} |
This file contains hidden or 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,7 @@ | ||
| component collide_array; | ||
| license "GPL"; | ||
| pin in bool x_#[4]; | ||
| pin out bool x_0; | ||
| function _; | ||
| ;; | ||
| FUNCTION(_) {} |
This file contains hidden or 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,6 @@ | ||
| component collide_funct_time; | ||
| license "GPL"; | ||
| pin out sint f.time; | ||
| function f; | ||
| ;; | ||
| FUNCTION(f) {} |
This file contains hidden or 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,8 @@ | ||
| component collide_function; | ||
| license "GPL"; | ||
| pin in bool enable; | ||
| function a_b; | ||
| function a_b_; | ||
| ;; | ||
| FUNCTION(a_b) {} | ||
| FUNCTION(a_b_) {} |
This file contains hidden or 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,7 @@ | ||
| component collide_personality; | ||
| license "GPL"; | ||
| pin in bool x_y if personality == 1; | ||
| pin out bool x_y_ if personality == 0; | ||
| function _; | ||
| ;; | ||
| FUNCTION(_) {} |
This file contains hidden or 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,7 @@ | ||
| component collide_pin_param; | ||
| license "GPL"; | ||
| pin in bool x_y; | ||
| param rw bool x_y_; | ||
| function _; | ||
| ;; | ||
| FUNCTION(_) {} |
This file contains hidden or 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,7 @@ | ||
| component collide_pin_pin; | ||
| license "GPL"; | ||
| pin in bool x_y; | ||
| pin out bool x_y_; | ||
| function _; | ||
| ;; | ||
| FUNCTION(_) {} |
This file contains hidden or 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,21 @@ | ||
| collide_pin_pin.comp:4:19: Name collision: pin 'x_y' and pin 'x_y_' both become 'x-y' and are indistinguishable. | ||
| > pin out bool x_y_; | ||
| > ^ | ||
| collide_pin_param.comp:4:20: Name collision: pin 'x_y' and param 'x_y_' both become 'x-y' and are indistinguishable. | ||
| > param rw bool x_y_; | ||
| > ^ | ||
| collide_function.comp:5:15: Name collision: function 'a_b' and function 'a_b_' both become 'a-b' and are indistinguishable. | ||
| > function a_b_; | ||
| > ^ | ||
| collide_array.comp:4:18: Name collision: pin 'x_#' and pin 'x_0' both become 'x-0' and are indistinguishable. | ||
| > pin out bool x_0; | ||
| > ^ | ||
| collide_funct_time.comp:4:12: Name collision: pin 'f.time' and the .time of function 'f' both become 'f.time' and are indistinguishable. | ||
| > function f; | ||
| > ^ | ||
| collide_personality.comp:4:39: Name collision: pin 'x_y' and pin 'x_y_' both become 'x-y' and are indistinguishable. | ||
| > pin out bool x_y_ if personality == 0; | ||
| > ^ | ||
| array_limit.comp:3:22: Array size 257 exceeds the maximum of 256: 'x_#' | ||
| > pin in bool x_#[257]; | ||
| > ^ |
This file contains hidden or 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,6 @@ | ||
| component separate_namespaces; | ||
| license "GPL"; | ||
| pin in bool x_y; | ||
| function x_y_; | ||
| ;; | ||
| FUNCTION(x_y_) {} |
This file contains hidden or 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,20 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Two declarations that claim one HAL name must be rejected here, not left to | ||
| # fail at loadrt as "HAL: ERROR: duplicate pin". Pins and params share one | ||
| # namespace in hal_lib.c; functions have their own, but hal_export_funct() | ||
| # also creates <funct>.time, .tmax and .tmax-increased as a pin and params. | ||
| # An array claims one name per element, and is limited to 256 elements. | ||
| for c in collide_pin_pin collide_pin_param collide_function collide_array \ | ||
| collide_funct_time collide_personality array_limit; do | ||
| rm -f "$c.c" | ||
| halcompile --preprocess "$c.comp" 2>&1 && echo "halcompile accepted $c.comp" | ||
| [ -f "$c.c" ] && echo "halcompile produced $c.c" | ||
| done | ||
|
|
||
| # A pin and a function that mangle to one name are exported into different | ||
| # HAL namespaces, so they do not collide. | ||
| c=separate_namespaces | ||
| rm -f "$c.c" | ||
| halcompile --preprocess "$c.comp" 2>&1 || echo "halcompile rejected $c.comp" | ||
| [ -f "$c.c" ] || echo "halcompile did not produce $c.c" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to change the behaviour of the
Error()function?You are adding a named parameter, but where in the code is that used?
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
claim() passes it through; nothing else.
pos facilitates avoiding a confusing error message. Consider a userspace component with function _ left in and a pin called time. Userspace components get no functions, so .time is never created. If the check runs at the declaration it errors about something that doesn't exist - confusing especially if one traces backwards.
That is why the check waits until the end of the file, so pos remembers where the function was.
It is one optional argument and defaults to the old behavior. Your call.