blob: b7e8c37a6c8172564e1fb4e90074f929c19db049 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// PR c++/99672
// { dg-do compile { target c++20 } }
namespace std {
struct source_location {
struct __impl {
const char *_M_file_name;
const char *_M_function_name;
unsigned int _M_line, _M_column;
};
const __impl *__ptr;
constexpr source_location () : __ptr (nullptr) {}
static consteval source_location
current (const void *__p = __builtin_source_location ()) {
source_location __ret;
__ret.__ptr = static_cast <const __impl *> (__p);
return __ret;
}
constexpr const char *file_name () const {
return __ptr ? __ptr->_M_file_name : "";
}
constexpr const char *function_name () const {
return __ptr ? __ptr->_M_function_name : "";
}
constexpr unsigned line () const {
return __ptr ? __ptr->_M_line : 0;
}
constexpr unsigned column () const {
return __ptr ? __ptr->_M_column : 0;
}
};
}
constexpr int g(auto...) {
return std::source_location::current().column();
}
constexpr int f() {
return std::source_location::current().column();
}
constexpr int a = g();
constexpr int b = f();
static_assert (a == b);
|