diff options
author | Arsen Arsenović <arsen@aarsen.me> | 2024-07-25 16:13:24 +0200 |
---|---|---|
committer | Arsen Arsenovic <arsen@gcc.gnu.org> | 2024-07-30 13:02:07 +0200 |
commit | 265aa32062167a5b299c2ffb616edce5997b64bf (patch) | |
tree | 83497c53a8ed05346f0eb4f5ae0f541a9c4f0a79 /gcc/cp | |
parent | 136f364e26d9ad4f05e0005e480813cdc8f56c96 (diff) | |
download | gcc-265aa32062167a5b299c2ffb616edce5997b64bf.zip gcc-265aa32062167a5b299c2ffb616edce5997b64bf.tar.gz gcc-265aa32062167a5b299c2ffb616edce5997b64bf.tar.bz2 |
c++: make source_location follow DECL_RAMP_FN
This fixes the value of current_function in compiler generated coroutine
code.
PR c++/110855 - std::source_location doesn't work with C++20 coroutine
gcc/cp/ChangeLog:
PR c++/110855
* cp-gimplify.cc (fold_builtin_source_location): Use the name of
the DECL_RAMP_FN of the current function if present.
gcc/testsuite/ChangeLog:
PR c++/110855
* g++.dg/coroutines/pr110855.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/cp-gimplify.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index 6a5e4cf..b88c3b7 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -3933,7 +3933,14 @@ fold_builtin_source_location (const_tree t) const char *name = ""; if (current_function_decl) - name = cxx_printable_name (current_function_decl, 2); + { + /* If this is a coroutine, we should get the name of the user + function rather than the actor we generate. */ + if (tree ramp = DECL_RAMP_FN (current_function_decl)) + name = cxx_printable_name (ramp, 2); + else + name = cxx_printable_name (current_function_decl, 2); + } val = build_string_literal (name); } |