-
Notifications
You must be signed in to change notification settings - Fork 274
C front-end: Do not lose comments in type checking #4622
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
Merged
Merged
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
int foo(int x) | ||
{ | ||
return x; | ||
} | ||
|
||
int main() | ||
{ | ||
int n; | ||
|
||
#pragma CPROVER check push | ||
#pragma CPROVER check disable "signed-overflow" | ||
// do not generate assertions for the following statements | ||
int x = n + n; | ||
++n; | ||
n++; | ||
n += 1; | ||
foo(x + n); | ||
// pop all annotations | ||
#pragma CPROVER check pop | ||
// but do generate assertions for these | ||
x = n + n; | ||
foo(x + n); | ||
return x; | ||
} |
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,11 @@ | ||
CORE | ||
main.c | ||
--signed-overflow-check | ||
^\[main.overflow\.1\] line 21 arithmetic overflow on signed \+ in n \+ n: FAILURE$ | ||
^\[main.overflow\.2\] line 22 arithmetic overflow on signed \+ in x \+ n: FAILURE$ | ||
^\*\* 2 of 2 failed | ||
^VERIFICATION FAILED$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
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 |
---|---|---|
|
@@ -2019,6 +2019,10 @@ void c_typecheck_baset::typecheck_side_effect_function_call( | |
throw 0; | ||
} | ||
|
||
irep_idt comment = expr.source_location().get_comment(); | ||
if(!comment.empty() && f_op.source_location().get_comment().empty()) | ||
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. If the comment is non empty, should we merge instead of ignoring? |
||
f_op.add_source_location().set_comment(comment); | ||
|
||
const code_typet &code_type=to_code_type(f_op.type()); | ||
|
||
expr.type()=code_type.return_type(); | ||
|
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.
If the comment is non empty, should we merge instead of ignoring?
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.
The new implementation in #4666 also resolves this problem (in parts by just removing the above code :-) ).