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

PROTON-2773: add PN_FALLTHROUGH macro ready for c++17/c21 #408

Merged
merged 2 commits into from
Oct 20, 2023

Conversation

jiridanek
Copy link
Contributor

No description provided.

@jiridanek jiridanek added this to the v0.40.0 milestone Oct 14, 2023
@jiridanek jiridanek self-assigned this Oct 14, 2023
@jiridanek jiridanek force-pushed the jd_2023_10_14_fallthrough_warning_ branch 2 times, most recently from c205cb4 to 452e250 Compare October 14, 2023 15:38
@jiridanek
Copy link
Contributor Author

The original motivation for this is to be able to have composite CMake build with skupper-router. With skupper-router adding proton as cmake subproject. To do this, both projects need to compile with the same flags, and skupper-router defines -Wimplicit-fallthrough. Therefore, proton should be clean for this warning too.

@jiridanek
Copy link
Contributor Author

See also https://lore.kernel.org/lkml/a588204afbfe4c8dd56d0cb00d8e6e14dc561a62.camel@perches.com/

where Joe Perches who maintains the Linux kernel's patch validator (scripts/checkpatch.pl) wrote a tool to convert all of the Linux kernel's comments into attribute((fallthrough)), but also provided statistics of every possible spelling of fallthrough seen in the kernel, which is useful data for those looking to fix every possible case.

Copy link
Member

@astitcher astitcher left a comment

Choose a reason for hiding this comment

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

Basically lgtm.
My comments are basically stylistic, just my preference for if...else if.. chains in this case.

#endif
#if !defined PN_FALLTHROUGH && defined __has_attribute
Copy link
Member

Choose a reason for hiding this comment

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

again could be #elif

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, because we might be on older c that has a __has_c_attribute but not the [[fallthrough]];, so we would go into

#if !defined PN_FALLTHROUGH && defined __STDC_VERSION__ && defined __has_c_attribute

but not define PN_FALLTHROUGH there

#endif
#if !defined PN_FALLTHROUGH
Copy link
Member

Choose a reason for hiding this comment

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

this could be #else

c/include/proton/annotations.h Show resolved Hide resolved
@jiridanek jiridanek force-pushed the jd_2023_10_14_fallthrough_warning_ branch from 2da6f6e to 68b01f3 Compare October 19, 2023 14:40
@jiridanek
Copy link
Contributor Author

Thanks for looking into this. I changed it to #if#elif where it was straightforward to do.

@jiridanek jiridanek merged commit d2dbfd4 into apache:main Oct 20, 2023
3 of 4 checks passed
@jiridanek jiridanek deleted the jd_2023_10_14_fallthrough_warning_ branch October 20, 2023 13:32
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