Skip to content

gh-135183: Suppress MSVC warning 5274 locally #135184

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 0 additions & 13 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,6 @@
# include <intrin.h> // __readgsqword()
#endif

// Suppress known warnings in Python header files.
#if defined(_MSC_VER)
// Warning that alignas behaviour has changed. Doesn't affect us, because we
// never relied on the old behaviour.
#pragma warning(push)
#pragma warning(disable: 5274)
#endif

// Include Python header files
#include "pyport.h"
#include "pymacro.h"
Expand Down Expand Up @@ -146,9 +138,4 @@
#include "cpython/pyfpe.h"
#include "cpython/tracemalloc.h"

// Restore warning filter
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif /* !Py_PYTHON_H */
11 changes: 11 additions & 0 deletions Include/cpython/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ static inline Py_UCS4 Py_UNICODE_LOW_SURROGATE(Py_UCS4 ch) {

/* --- Unicode Type ------------------------------------------------------- */

// Suppress known warning with _Py_ALIGN_AS; see gh-135183
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 5274)
#endif

/* ASCII-only strings created through PyUnicode_New use the PyASCIIObject
structure. state.ascii and state.compact are set, and the data
immediately follow the structure. utf8_length can be found
Expand Down Expand Up @@ -162,6 +168,11 @@ typedef struct {
} state;
} PyASCIIObject;

// Restore warning filter
#ifdef _MSC_VER
# pragma warning(pop)
#endif

/* Non-ASCII strings allocated through PyUnicode_New use the
PyCompactUnicodeObject structure. state.compact is set, and the data
immediately follow the structure. */
Expand Down
6 changes: 5 additions & 1 deletion Include/pymacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
#endif


// _Py_ALIGN_AS: this compiler's spelling of `alignas` keyword,
// _Py_ALIGN_AS: this compiler's spelling of `alignas` keyword.
//
// N.B. Applying this to a `struct` member might trigger MSVC warning 5274;
// see gh-135183 in that case.
//
// We currently use alignas for free-threaded builds only; additional compat
// checking would be great before we add it to the default build.
// Standards/compiler support:
Expand Down
Loading