Skip to content

Commit 3d2cb7c

Browse files
committed
Trying henryiii@ (void) expander idea.
1 parent 1dfd35f commit 3d2cb7c

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
@@ -1236,8 +1236,8 @@ class unpacking_collector {
12361236
// Tuples aren't (easily) resizable so a list is needed for collection,
12371237
// but the actual function call strictly requires a tuple.
12381238
auto args_list = list();
1239-
PYBIND11_INT_ARRAY_WORKING_AROUND_MSVC_CLANG_ISSUES(
1240-
{0, (process(args_list, std::forward<Ts>(values)), 0)...});
1239+
using expander = int[];
1240+
(void) expander{0, (process(args_list, std::forward<Ts>(values)), 0)...};
12411241

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

include/pybind11/detail/common.h

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

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

970959
// warning C4127: Conditional expression is constant

0 commit comments

Comments
 (0)