public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/108242] [10/11/12/13 Regression] '__FUNCTION__' was not declared when used inside a generic (templated) lambda declared inside a template function Date: Fri, 03 Feb 2023 18:09:56 +0000 [thread overview] Message-ID: <bug-108242-4-uhfxUGkdge@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108242-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242 --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Makes me wonder why finish_fname returns the IDENTIFIER_NODE rather than the VAR_DECL when processing_template_decl, though if I comment that out it ICEs. When DECL_INITIAL is __FUNCTION__ etc. IDENTIFIER_NODE, it is looked up using lookup_name, which works fine if it is the template function in which __FUNCTION__ has been referenced (ok e.g. when processing DECL_EXPR of fun_name). But for some reason we don't find that VAR_DECL as local specialization and trigger /* This can happen for a variable used in a late-specified return type of a local lambda, or for a local static or constant. Building a new VAR_DECL should be OK in all those cases. */ r = tsubst_decl (t, args, complain); if (local_specializations) /* Avoid infinite recursion (79640). */ register_local_specialization (r, t); if (decl_maybe_constant_var_p (r)) { /* We can't call cp_finish_decl, so handle the initializer by hand. */ tree init = tsubst_init (DECL_INITIAL (t), r, args, complain, in_decl); which then doesn't work, either it finds a different __FUNCTION__ than it should, e.g. for: bool v; template<class F> void my_fun() { auto fun = [&](auto res) { static constexpr char const* fun_name = __FUNCTION__; struct { constexpr const char* operator()() const { return v ? __FUNCTION__ : fun_name; }; } t; t(); }; fun(12); } or it doesn't find it at all.
next prev parent reply other threads:[~2023-02-03 18:09 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-28 16:13 [Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a " n.eugene536 at gmail dot com 2022-12-28 17:50 ` [Bug c++/108242] '__FUNCTION__' was not declared when used inside a generic (templated) " pinskia at gcc dot gnu.org 2022-12-28 17:54 ` [Bug c++/108242] [10/11/12/13 Regression] " pinskia at gcc dot gnu.org 2022-12-29 2:44 ` pinskia at gcc dot gnu.org 2023-01-02 9:27 ` jakub at gcc dot gnu.org 2023-01-09 14:03 ` rguenth at gcc dot gnu.org 2023-02-03 18:09 ` jakub at gcc dot gnu.org [this message] 2023-02-03 18:16 ` mpolacek at gcc dot gnu.org 2023-02-03 18:23 ` jakub at gcc dot gnu.org 2023-03-16 19:15 ` jason at gcc dot gnu.org 2023-03-16 22:11 ` cvs-commit at gcc dot gnu.org 2023-04-18 20:46 ` [Bug c++/108242] [10/11/12 " cvs-commit at gcc dot gnu.org 2023-07-07 10:44 ` [Bug c++/108242] [11 " rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-108242-4-uhfxUGkdge@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).