Apparently clang trunk implemented __builtin_source_location(), but the
using __builtin_ret_type = decltype(__builtin_source_location());
which has been added for it isn't enough, they also need the
std::source_location::__impl class to be defined (but incomplete seems
to be good enough) before the builtin is used.
The following has been tested on godbolt with clang trunk (old version
fails with
error: 'std::source_location::__impl' was not found; it must be defined before '__builtin_source_location' is called
and some follow-up errors), getting back to just void * instead of
__builtin_ret_type and commenting out using doesn't work either and
just struct __impl; before using __builtin_ret_type doesn't work too.
2022-04-02 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/105128
* include/std/source_location (std::source_location::__impl): Move
definition before using __builtin_ret_type.
{
private:
using uint_least32_t = __UINT_LEAST32_TYPE__;
+ struct __impl
+ {
+ const char* _M_file_name;
+ const char* _M_function_name;
+ unsigned _M_line;
+ unsigned _M_column;
+ };
using __builtin_ret_type = decltype(__builtin_source_location());
public:
{ return _M_impl ? _M_impl->_M_function_name : ""; }
private:
- struct __impl
- {
- const char* _M_file_name;
- const char* _M_function_name;
- unsigned _M_line;
- unsigned _M_column;
- };
-
const __impl* _M_impl = nullptr;
};