Skip to content

Commit 17b6143

Browse files
authored
clang 17 compatibility fixes (#4767)
* Copy clang 17 compatibility fixes from PR #4762 to a separate PR. * Add gcc:13 C++20 * Add silkeh/clang:16-bullseye C++20
1 parent f3e0602 commit 17b6143

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ jobs:
302302
- clang: 15
303303
std: 20
304304
container_suffix: "-bullseye"
305+
- clang: 16
306+
std: 20
307+
container_suffix: "-bullseye"
305308

306309
name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64"
307310
container: "silkeh/clang:${{ matrix.clang }}${{ matrix.container_suffix }}"
@@ -465,6 +468,7 @@ jobs:
465468
- { gcc: 10, std: 17 }
466469
- { gcc: 11, std: 20 }
467470
- { gcc: 12, std: 20 }
471+
- { gcc: 13, std: 20 }
468472

469473
name: "🐍 3 • GCC ${{ matrix.gcc }} • C++${{ matrix.std }}• x64"
470474
container: "gcc:${{ matrix.gcc }}"

include/pybind11/cast.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,15 @@ inline namespace literals {
13771377
/** \rst
13781378
String literal version of `arg`
13791379
\endrst */
1380-
constexpr arg operator"" _a(const char *name, size_t) { return arg(name); }
1380+
constexpr arg
1381+
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 5
1382+
operator"" _a // gcc 4.8.5 insists on having a space (hard error).
1383+
#else
1384+
operator""_a // clang 17 generates a deprecation warning if there is a space.
1385+
#endif
1386+
(const char *name, size_t) {
1387+
return arg(name);
1388+
}
13811389
} // namespace literals
13821390

13831391
PYBIND11_NAMESPACE_BEGIN(detail)

include/pybind11/pytypes.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,15 @@ inline namespace literals {
16121612
/** \rst
16131613
String literal version of `str`
16141614
\endrst */
1615-
inline str operator"" _s(const char *s, size_t size) { return {s, size}; }
1615+
inline str
1616+
#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 5
1617+
operator"" _s // gcc 4.8.5 insists on having a space (hard error).
1618+
#else
1619+
operator""_s // clang 17 generates a deprecation warning if there is a space.
1620+
#endif
1621+
(const char *s, size_t size) {
1622+
return {s, size};
1623+
}
16161624
} // namespace literals
16171625

16181626
/// \addtogroup pytypes

0 commit comments

Comments
 (0)