-
Notifications
You must be signed in to change notification settings - Fork 274
C front-end: cleanup label statement type checking #3277
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,13 @@ | ||
#include <assert.h> | ||
|
||
int main() | ||
{ | ||
goto label2; | ||
goto out; | ||
label1: | ||
label2: | ||
label3: | ||
assert(0); | ||
out: | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CORE | ||
main.c | ||
|
||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
^VERIFICATION FAILED$ | ||
-- | ||
^warning: ignoring | ||
-- | ||
This test checks that the assertion is reachable despite being wrapped in a | ||
nested list of labels, and that jumping to a label in the middle of that list is | ||
handled correctly. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -193,26 +193,8 @@ void c_typecheck_baset::typecheck_block(code_blockt &code) | |
|
||
for(auto &code_op : code.statements()) | ||
{ | ||
if(code_op.is_nil()) | ||
continue; | ||
|
||
if(code_op.get_statement()==ID_label) | ||
{ | ||
// these may be nested | ||
codet *code_ptr=&code_op; | ||
|
||
while(code_ptr->get_statement()==ID_label) | ||
{ | ||
assert(code_ptr->operands().size()==1); | ||
code_ptr=&to_code(code_ptr->op0()); | ||
} | ||
|
||
// codet &label_op=*code_ptr; | ||
|
||
new_ops.move(code_op); | ||
} | ||
else | ||
new_ops.move(code_op); | ||
if(code_op.is_not_nil()) | ||
new_ops.add(std::move(code_op)); | ||
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. It is nice the code is a lot simpler - but we now don't check the operands size - is this a problem? 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. Type checking of labels is done elsewhere, I'd say this should be done over there. |
||
} | ||
|
||
code.statements().swap(new_ops.statements()); | ||
|
Uh oh!
There was an error while loading. Please reload this page.