https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80780

--- Comment #4 from lbjonnes at cisco dot com ---
"redi at gcc dot gnu.org" <gcc-bugzi...@gcc.gnu.org> writes:

| https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80780
>
|             Bug ID: 80780
|            Summary: Front-end support needed for
|                     experimental::source_location
|            Product: gcc
|            Version: 8.0
|             Status: UNCONFIRMED
|           Severity: normal
|           Priority: P3
|          Component: c++
|           Assignee: unassigned at gcc dot gnu.org
|           Reporter: redi at gcc dot gnu.org
|   Target Milestone: ---
>
| I've just added a partial implementation of <experimental/source_location> to
| trunk (r248110).
>
| The missing pieces need some FE help.
>
| 1) because the location info returned by source_location::current() should be
| the location of the caller the current implementation uses default arguments:
>
|   struct source_location
|   {
|     // 14.1.2, source_location creation
|     static constexpr source_location
|     current(const char* __file = __builtin_FILE(),
|             const char* __func = __builtin_FUNCTION(),
|             int __line = __builtin_LINE(),
|             int __col = 0) noexcept

btw. adding a __builtin_COLUMN is quite easy, and I had a patch ealier
to do just that. I won't send it though since I have now papers in order
and the likelyhood of me getting said papers are slim.

|     {
|       source_location __loc;
|       __loc._M_file = __file;
|       __loc._M_func = __func;
|       __loc._M_line = __line;
|       __loc._M_col = __col;
|       return __loc;
|     }
>
| This works OK, but means the signature of the function doesn't match the one
in
| the TS (which has no parameters). The standard does allow us to add
parameters
| with default arguments to member functions, but it might be nice if it wasn't
| needed. I'm not sure how best to do that. Maybe make the FE recognise
| std::experimental::fundamentals_v2::source_location::current() as magic, so
| that location info inside the function uses the location of the caller? Maybe
| add a new attribute to perform said magic for any inline function? (If
| current() is called indirectly, e.g. through a function pointer, the result
is
| unspecified so the magic doesn't need to work when the function isn't
inlined).
>
| 2) source_location::current().function_name() uses __func__ which is not very
| descriptive in C++. It would be nice to have a __builtin_PRETTY_FUNCTION to
get
| a better function name than __builtin_FUNCTION provides.
>
| 3) source_location::column().column() always returns zero, because there's no
| "__builtin_column" to get a column number, the way __builtin_LINE gives a
line
| number.
>
>
| I mistakenly though that calling current() in a default member initializer
gave
| the wrong locations, but it does the right thing (giving the location of the
| constructor body that initializes the member).

Reply via email to