-
Notifications
You must be signed in to change notification settings - Fork 277
C entry point generator: no unconditional conversion to pointer type #6976
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int main(char *argv, int arc) | ||
{ | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CORE test-c++-front-end | ||
main.c | ||
|
||
'main' with signature 'signed int \(char \*argv, signed int arc\)' found | ||
^EXIT=(64|1)$ | ||
^SIGNAL=0$ | ||
-- | ||
Invariant check failed | ||
-- | ||
This test is to ensure that non-standard C entry points are handled gracefully | ||
and with a message to the user. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,7 +248,16 @@ bool generate_ansi_c_start_function( | |
{ | ||
// ok | ||
} | ||
else if(parameters.size()==2 || parameters.size()==3) | ||
// The C standard (and any related architecture descriptions) enforces an | ||
// order of parameters. The user, however, may supply arbitrary | ||
// (syntactically valid) C code, even one that does not respect the calling | ||
// conventions set out in the C standard. If the user does supply such code, | ||
// then we can only tell them that they got it wrong, which is what we do | ||
// via the error message in the else branch of this code. | ||
else if( | ||
parameters.size() >= 2 && parameters[1].type().id() == ID_pointer && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks wrong because the regression test has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The one place that enforces the order is the C standard (and any related architecture descriptions). The user, however, may supply arbitrary (syntactically valid) C code, even one that does not respect the calling conventions set out in the C standard. If the user does supply such code (as is done in the accompanying regression test), then we can only tell them that they got it wrong, which is what we do via the error message in the Does this address your concern? Should I still be making changes to the implementation? Should I perhaps add the above as a comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I'm happy to approve. The detail in your response might be nice to have in the comments though since this is not immediately clear. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment added to the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment is very helpful. |
||
(parameters.size() == 2 || | ||
(parameters.size() == 3 && parameters[2].type().id() == ID_pointer))) | ||
{ | ||
namespacet ns(symbol_table); | ||
|
||
|
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.
Can we add a description of what the test is trying to achieve? Maybe something like:
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.
Thank you, done!