Skip to content

Commit d0ed035

Browse files
authored
fix: AppleClang 12 warnings (#2510)
* fix: AppleClang 12 new warning * Fix: AppleClang X.X.0 will not trigger this warning
1 parent 4a288ab commit d0ed035

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

include/pybind11/cast.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ class unpacking_collector {
20922092
}
20932093

20942094
void process(list &args_list, detail::args_proxy ap) {
2095-
for (const auto &a : ap)
2095+
for (auto a : ap)
20962096
args_list.append(a);
20972097
}
20982098

@@ -2124,7 +2124,7 @@ class unpacking_collector {
21242124
void process(list &/*args_list*/, detail::kwargs_proxy kp) {
21252125
if (!kp)
21262126
return;
2127-
for (const auto &k : reinterpret_borrow<dict>(kp)) {
2127+
for (auto k : reinterpret_borrow<dict>(kp)) {
21282128
if (m_kwargs.contains(k.first)) {
21292129
#if defined(NDEBUG)
21302130
multiple_values_error();

include/pybind11/pybind11.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ struct enum_base {
14941494
handle type = type::handle_of(arg);
14951495
object type_name = type.attr("__name__");
14961496
dict entries = type.attr("__entries");
1497-
for (const auto &kv : entries) {
1497+
for (auto kv : entries) {
14981498
object other = kv.second[int_(0)];
14991499
if (other.equal(arg))
15001500
return pybind11::str("{}.{}").format(type_name, kv.first);
@@ -1506,7 +1506,7 @@ struct enum_base {
15061506
m_base.attr("name") = property(cpp_function(
15071507
[](handle arg) -> str {
15081508
dict entries = type::handle_of(arg).attr("__entries");
1509-
for (const auto &kv : entries) {
1509+
for (auto kv : entries) {
15101510
if (handle(kv.second[int_(0)]).equal(arg))
15111511
return pybind11::str(kv.first);
15121512
}
@@ -1521,7 +1521,7 @@ struct enum_base {
15211521
if (((PyTypeObject *) arg.ptr())->tp_doc)
15221522
docstring += std::string(((PyTypeObject *) arg.ptr())->tp_doc) + "\n\n";
15231523
docstring += "Members:";
1524-
for (const auto &kv : entries) {
1524+
for (auto kv : entries) {
15251525
auto key = std::string(pybind11::str(kv.first));
15261526
auto comment = kv.second[int_(1)];
15271527
docstring += "\n\n " + key;
@@ -1535,7 +1535,7 @@ struct enum_base {
15351535
m_base.attr("__members__") = static_property(cpp_function(
15361536
[](handle arg) -> dict {
15371537
dict entries = arg.attr("__entries"), m;
1538-
for (const auto &kv : entries)
1538+
for (auto kv : entries)
15391539
m[kv.first] = kv.second[int_(0)];
15401540
return m;
15411541
}, name("__members__")), none(), none(), ""
@@ -1623,7 +1623,7 @@ struct enum_base {
16231623

16241624
PYBIND11_NOINLINE void export_values() {
16251625
dict entries = m_base.attr("__entries");
1626-
for (const auto &kv : entries)
1626+
for (auto kv : entries)
16271627
m_parent.attr(kv.first) = kv.second[int_(0)];
16281628
}
16291629

tests/test_operator_overloading.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ std::string abs(const Vector2&) {
8989
// Taken from: https://github.com/RobotLocomotion/drake/commit/aaf84b46
9090
// TODO(eric): This could be resolved using a function / functor (e.g. `py::self()`).
9191
#if defined(__APPLE__) && defined(__clang__)
92-
#if (__clang_major__ >= 10) && (__clang_minor__ >= 0) && (__clang_patchlevel__ >= 1)
92+
#if (__clang_major__ >= 10)
9393
#pragma GCC diagnostic ignored "-Wself-assign-overloaded"
9494
#endif
9595
#elif defined(__clang__)

tests/test_pytypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ TEST_SUBMODULE(pytypes, m) {
128128
d["basic_attr"] = o.attr("basic_attr");
129129

130130
auto l = py::list();
131-
for (const auto &item : o.attr("begin_end")) {
131+
for (auto item : o.attr("begin_end")) {
132132
l.append(item);
133133
}
134134
d["begin_end"] = l;

0 commit comments

Comments
 (0)