Skip to content
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

Enable implicit fall-through errors #3324

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

amomchilov
Copy link
Contributor

This PR enables -Wimplicit-fallthrough to catch any potentially unintended fall-through between case bodies.

The exiting /* fallthrough */ comments are now formalized with a new PRISM_FALLTHROUGH macro which:

  • Uses C23's standardized [[fallthrough]] attribute, if available,
  • Uses __attribute__((fallthrough)) on GCC and Clang
  • Uses to __fallthrough on MSVC

@amomchilov amomchilov changed the title Enable implicit fallt-through errors Enable implicit fall-through errors Dec 18, 2024
@amomchilov amomchilov force-pushed the detect-implicit-fallthrough branch from b81662a to 2389d0c Compare December 18, 2024 18:43
@amomchilov amomchilov force-pushed the detect-implicit-fallthrough branch from 2389d0c to 03797b8 Compare December 18, 2024 18:46
@@ -21893,6 +21893,7 @@ parse_expression(pm_parser_t *parser, pm_binding_power_t binding_power, bool acc
if (pm_symbol_node_label_p(node)) {
return node;
}
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one had an implicit fall-through that wasn't annotated.

Since the default case it falls into only does a break, I just added its own break instead of PRISM_FALLTHROUGH.

@tenderlove tenderlove merged commit 4507b6d into ruby:main Dec 19, 2024
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants