Skip to content

GH-131296: move suppression of "unused label" warning for clang-cl on Windows #131900

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 2 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PCbuild/pyproject-clangcl.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
Please see GH-131691 for details.
-->
<ExceptionHandling>Async</ExceptionHandling>
<AdditionalOptions>-Wno-deprecated-non-prototype -Wno-unused-label -Wno-pointer-sign -Wno-incompatible-pointer-types-discards-qualifiers -Wno-unused-function %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>-Wno-pointer-sign -Wno-incompatible-pointer-types-discards-qualifiers -Wno-unused-function %(AdditionalOptions)</AdditionalOptions>
Copy link
Member Author

Choose a reason for hiding this comment

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

-Wno-unused-label is moved to ceval.c.

-Wno-deprecated-non-prototype is removed, because it does not "fire" for the whole code base.

<AdditionalOptions Condition="'$(Platform)' == 'Win32'">-m32 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Platform)' == 'x64'">-m64 %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="$(Configuration) != 'Debug'">-flto=thin %(AdditionalOptions)</AdditionalOptions>
Expand Down
4 changes: 2 additions & 2 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ extern void _PyUOpPrint(const _PyUOpInstruction *uop);
if computed gotos aren't used. */

/* TBD - what about other compilers? */
#if defined(__GNUC__)
#if defined(__GNUC__) || defined(__clang__)
Copy link
Member Author

@chris-eibl chris-eibl Mar 30, 2025

Choose a reason for hiding this comment

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

On Windows, clang-cl does not define __GNUC__ (in contrast to Linux), so let's add __clang__ here.

Slightly further down, for MSVC the same warning (4102) is suppressed using #pragma warning(disable:4102), which clang-cl unfortunately does not understand (yet).

The only occurrences of this warning in the whole code base stem from "generated_cases.c.h", so this is a better place to suppress it in case of clang-cl, instead of doing it globally via pyproject-clangcl.props.

# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-label"
#elif defined(_MSC_VER) /* MS_WINDOWS */
Expand Down Expand Up @@ -1168,7 +1168,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
# pragma optimize("", on)
#endif

#if defined(__GNUC__)
#if defined(__GNUC__) || defined(__clang__)
# pragma GCC diagnostic pop
#elif defined(_MSC_VER) /* MS_WINDOWS */
# pragma warning(pop)
Expand Down
Loading