Skip to content

Commit c24c892

Browse files
committed
Trying henryiii@ (void) expander idea.
1 parent a5c8f3f commit c24c892

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

include/pybind11/attr.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -518,26 +518,29 @@ template <typename... Args> struct process_attributes {
518518
static void init(const Args&... args, function_record *r) {
519519
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
520520
PYBIND11_WORKAROUND_INCORRECT_ALL_GCC_UNUSED_BUT_SET_PARAMETER(r);
521-
PYBIND11_INT_ARRAY_WORKING_AROUND_MSVC_CLANG_ISSUES(
522-
{0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...});
521+
using expander = int[];
522+
(void) expander{
523+
0, ((void) process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
523524
}
524525
static void init(const Args&... args, type_record *r) {
525526
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r);
526527
PYBIND11_WORKAROUND_INCORRECT_ALL_GCC_UNUSED_BUT_SET_PARAMETER(r);
527-
PYBIND11_INT_ARRAY_WORKING_AROUND_MSVC_CLANG_ISSUES(
528-
{0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...});
528+
using expander = int[];
529+
(void) expander{0,
530+
(process_attribute<typename std::decay<Args>::type>::init(args, r), 0)...};
529531
}
530532
static void precall(function_call &call) {
531533
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call);
532-
PYBIND11_INT_ARRAY_WORKING_AROUND_MSVC_CLANG_ISSUES(
533-
{0, (process_attribute<typename std::decay<Args>::type>::precall(call), 0)...});
534+
using expander = int[];
535+
(void) expander{0,
536+
(process_attribute<typename std::decay<Args>::type>::precall(call), 0)...};
534537
}
535538
static void postcall(function_call &call, handle fn_ret) {
536539
PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call, fn_ret);
537540
PYBIND11_WORKAROUND_INCORRECT_ALL_GCC_UNUSED_BUT_SET_PARAMETER(fn_ret);
538-
PYBIND11_INT_ARRAY_WORKING_AROUND_MSVC_CLANG_ISSUES(
539-
{0,
540-
(process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0)...});
541+
using expander = int[];
542+
(void) expander{
543+
0, (process_attribute<typename std::decay<Args>::type>::postcall(call, fn_ret), 0)...};
541544
}
542545
};
543546

include/pybind11/cast.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,8 @@ class unpacking_collector {
12371237
// Tuples aren't (easily) resizable so a list is needed for collection,
12381238
// but the actual function call strictly requires a tuple.
12391239
auto args_list = list();
1240-
PYBIND11_INT_ARRAY_WORKING_AROUND_MSVC_CLANG_ISSUES(
1241-
{0, (process(args_list, std::forward<Ts>(values)), 0)...});
1240+
using expander = int[];
1241+
(void) expander{0, (process(args_list, std::forward<Ts>(values)), 0)...};
12421242

12431243
m_args = std::move(args_list);
12441244
}

include/pybind11/detail/common.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -955,17 +955,6 @@ inline void silence_unused_warnings(Args &&...) {}
955955
# define PYBIND11_WORKAROUND_INCORRECT_OLD_GCC_UNUSED_BUT_SET_PARAMETER(...)
956956
#endif
957957

958-
// MSVC error C4576: a parenthesized type followed by an initializer list is a
959-
// non-standard explicit type conversion syntax
960-
// clang: expression result unused [-Wunused-value]
961-
#if defined(_MSC_VER) || defined(__clang__) // All versions (as of July 2021).
962-
# define PYBIND11_INT_ARRAY_WORKING_AROUND_MSVC_CLANG_ISSUES(...) \
963-
int dummy[] = __VA_ARGS__; \
964-
detail::silence_unused_warnings(dummy)
965-
#else
966-
# define PYBIND11_INT_ARRAY_WORKING_AROUND_MSVC_CLANG_ISSUES(...) (int[]) __VA_ARGS__
967-
#endif
968-
969958
#if defined(_MSC_VER) // All versions (as of July 2021).
970959

971960
// warning C4127: Conditional expression is constant

0 commit comments

Comments
 (0)