testsuite: update mangling
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / srcloc20.C
blobe99f1dcf7c45ea2f09aee5e34f34fdc630949d5b
1 // { dg-do compile { target c++20 } }
3 namespace std {
4   struct source_location {
5     struct __impl {
6       const char *_M_file_name;
7       const char *_M_function_name;
8       unsigned int _M_line, _M_column;
9     };
10     const __impl *__ptr;
11     constexpr source_location () : __ptr (nullptr) {}
12     static consteval source_location
13     current (const void *__p = __builtin_source_location ()) {
14       source_location __ret;
15       __ret.__ptr = static_cast <const __impl *> (__p);
16       return __ret;
17     }
18     constexpr const char *file_name () const {
19       return __ptr ? __ptr->_M_file_name : "";
20     }
21     constexpr const char *function_name () const {
22       return __ptr ? __ptr->_M_function_name : "";
23     }
24     constexpr unsigned line () const {
25       return __ptr ? __ptr->_M_line : 0;
26     }
27     constexpr unsigned column () const {
28       return __ptr ? __ptr->_M_column : 0;
29     }
30   };
33 using namespace std;
35 auto a = source_location::current;              // { dg-error "taking address of an immediate function" }
36 constexpr auto b = &source_location::current;   // { dg-error "constant evaluation returns address of immediate function" }
38 void
39 foo ()
41   auto c = &source_location::current;           // { dg-error "taking address of an immediate function" }
42   constexpr auto d = source_location::current;  // { dg-error "constant evaluation returns address of immediate function" }
43   static auto e = source_location::current;     // { dg-error "taking address of an immediate function" }