mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-45476: Add _Py_RVALUE() macro (GH-29860)
Add a new _Py_RVALUE() macro to prevent using an expression as an l-value. Replace a "(void)" cast with the _Py_RVALUE() macro in the following macros: * PyCell_SET() * PyList_SET_ITEM() * PyTuple_SET_ITEM() * _PyGCHead_SET_FINALIZED() * _PyGCHead_SET_NEXT() * asdl_seq_SET() * asdl_seq_SET_UNTYPED() Add also parentheses around macro arguments in PyCell_SET() and PyTuple_SET_ITEM() macros.
This commit is contained in:
parent
f97ec09baf
commit
c19c3a0961
6 changed files with 11 additions and 7 deletions
|
@ -129,4 +129,8 @@
|
|||
Py_FatalError("Unreachable C code path reached")
|
||||
#endif
|
||||
|
||||
// Prevent using an expression as a l-value.
|
||||
// For example, "int x; _Py_RVALUE(x) = 1;" fails with a compiler error.
|
||||
#define _Py_RVALUE(EXPR) ((void)0, (EXPR))
|
||||
|
||||
#endif /* Py_PYMACRO_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue