Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/srcloc19.C

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