69-no-builtin_source_location_clang14.patch 1.1 KB

1234567891011121314151617181920212223242526272829
  1. diff --git a/include/source_location b/include/source_location
  2. index d16e3c4..958c16f 100644
  3. --- a/include/source_location
  4. +++ b/include/source_location
  5. @@ -52,12 +52,23 @@ class source_location {
  6. // in constant evaluation, so we don't want to use `void*` as the argument
  7. // type unless the builtin returned that, anyhow, and the invalid cast is
  8. // unavoidable.
  9. +# if __has_builtin(__builtin_source_location)
  10. using __bsl_ty = decltype(__builtin_source_location());
  11. +# else
  12. + using __bsl_ty = __impl*;
  13. +# endif
  14. public:
  15. // The defaulted __ptr argument is necessary so that the builtin is evaluated
  16. // in the context of the caller. An explicit value should never be provided.
  17. - static consteval source_location current(__bsl_ty __ptr = __builtin_source_location()) noexcept {
  18. + static consteval source_location
  19. + current(__bsl_ty __ptr =
  20. +# if __has_builtin(__builtin_source_location)
  21. + __builtin_source_location()
  22. +# else
  23. + nullptr
  24. +# endif
  25. + ) noexcept {
  26. source_location __sl;
  27. __sl.__ptr_ = static_cast<const __impl*>(__ptr);
  28. return __sl;