Hi!

On Fri, Nov 15, 2019 at 01:28:17PM +0100, Jakub Jelinek wrote:
> On Thu, Nov 14, 2019 at 08:34:26PM +0100, Jakub Jelinek wrote:
> > The following WIP patch implements __builtin_source_location (),
> > which returns const void pointer to a std::source_location::__impl
> > struct that is required to contain __file, __function, __line and __column
> > fields, the first two with const char * type, the latter some integral type.
> 
> Here is hopefully final version, with the hashing implemented,
> __file renamed to __file_name and __function to __function_name to match
> how the standard names the methods and with testsuite coverage.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

I'd like to ping this patch.
I know David and Jonathan had comments on the patch and can try to
incorporate them, but more importantly I'd like to ask whether we want to
add this at all or wait till GCC 11 and add something else.
Yet another option would be make it clear that the builtin is a temporary
thing until we implement something different and then would be removed,
say by reporting error if the builtin is used anywhere but in default
argument of std::source_location::current or something similar; I mean if
the ABI is sound, but we might have __builtin_constexpr_force_static or
whatever else or some new expression form one day and replace the builtin
uses with that.

> 2019-11-15  Jakub Jelinek  <ja...@redhat.com>
> 
>       * cp-tree.h (enum cp_tree_index): Add CPTI_SOURCE_LOCATION_IMPL.
>       (source_location_impl): Define.
>       (enum cp_built_in_function): Add CP_BUILT_IN_SOURCE_LOCATION.
>       (fold_builtin_source_location): Declare.
>       * cp-gimplify.c: Include output.h, file-prefix-map.h and cgraph.h.
>       (cp_gimplify_expr, cp_fold): Handle CP_BUILT_IN_SOURCE_LOCATION.
>       Formatting fix.
>       (get_source_location_impl): New function.
>       (struct source_location_table_entry,
>       struct source_location_table_entry_hash): New types.
>       (source_location_table, source_location_id): New variables.
>       (fold_builtin_source_location): New function.
>       * constexpr.c (cxx_eval_builtin_function_call): Handle
>       CP_BUILT_IN_SOURCE_LOCATION.
>       * tree.c (builtin_valid_in_constant_expr_p): Likewise.  Formatting
>       fix.
>       * decl.c (cxx_init_decl_processing): Register
>       __builtin_source_location.
>       * name-lookup.c (get_std_name_hint): Add source_location entry.
> 
>       * g++.dg/cpp2a/srcloc1.C: New test.
>       * g++.dg/cpp2a/srcloc2.C: New test.
>       * g++.dg/cpp2a/srcloc3.C: New test.
>       * g++.dg/cpp2a/srcloc4.C: New test.
>       * g++.dg/cpp2a/srcloc5.C: New test.
>       * g++.dg/cpp2a/srcloc6.C: New test.
>       * g++.dg/cpp2a/srcloc7.C: New test.
>       * g++.dg/cpp2a/srcloc8.C: New test.
>       * g++.dg/cpp2a/srcloc9.C: New test.
>       * g++.dg/cpp2a/srcloc10.C: New test.
>       * g++.dg/cpp2a/srcloc11.C: New test.
>       * g++.dg/cpp2a/srcloc12.C: New test.
>       * g++.dg/cpp2a/srcloc13.C: New test.
>       * g++.dg/cpp2a/srcloc14.C: New test.

        Jakub

Reply via email to