-
Notifications
You must be signed in to change notification settings - Fork 274
C front-end: reject code containing duplicate labels #6496
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
Conversation
77e7ae0
to
79057fa
Compare
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.
Solid, thanks for that!
if(!labels_defined.emplace(code.get_label(), code.source_location()).second) | ||
{ | ||
error().source_location = code.source_location(); | ||
error() << "duplicate label '" << code.get_label() << "'" << eom; |
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 this be substituted for a throw
of an invalid_source_file_exceptiont
from src/utils/exception_utils.h
? That would be great!
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.
An upcoming change will enforce per-function unique labels, as mandated by the C standard. We were sometimes sloppy about this with __CPROVER_ASYNC_* pseudo-labels as they don't actually indicate jump targets.
Whitespace changes only.
We previously silently accepted such code, maintaining the labels and attaching them to multiple instructions. `goto` resolved to the first such occurrence of the label. GCC firmly rejects such code.
79057fa
to
00f71da
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6496 +/- ##
===========================================
+ Coverage 76.06% 76.27% +0.20%
===========================================
Files 1546 1546
Lines 165584 165624 +40
===========================================
+ Hits 125951 126325 +374
+ Misses 39633 39299 -334
Continue to review full report at Codecov.
|
We previously silently accepted such code, maintaining the labels and
attaching them to multiple instructions.
goto
resolved to the firstsuch occurrence of the label.
GCC firmly rejects such code.