This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ debug PATCH] [PR88534] accept VAR_DECL in class literal template parms
- From: Marek Polacek <polacek at redhat dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, jason at redhat dot com, nathan at acm dot org, ccoutant at gmail dot com
- Date: Thu, 14 Mar 2019 16:20:34 -0400
- Subject: Re: [C++ debug PATCH] [PR88534] accept VAR_DECL in class literal template parms
- References: <or8sxhkybq.fsf@lxoliva.fsfla.org>
On Thu, Mar 14, 2019 at 05:14:49PM -0300, Alexandre Oliva wrote:
> P0732R2 / C++ 2a introduce class literals as template parameters. The
> front-end uses VAR_DECLs constructed from such literals to bind the
> template PARM_DECLs, but dwarf2out.c used to reject such VAR_DECLs.
>
> Taking DECL_INITIAL from such VAR_DECLs enables the generation of
> DW_AT_const_value for them, at least when the class literal can
> actually be represented as such.
>
> Regstrapped on x86_64- and i686-linux-gnu. Ok to install?
>
>
> for gcc/ChangeLog
>
> PR c++/88534
> PR c++/88537
> * dwarf2out.c (generic_parameter_die): Follow DECL_INITIAL of
> VAR_DECL args.
>
> for gcc/ChangeLog
>
> PR c++/88534
> PR c++/88537
> * g++.dg/cpp2a/pr88534.C: New.
> * g++.dg/cpp2a/pr88537.C: New.
> ---
> gcc/dwarf2out.c | 7 ++++
> gcc/testsuite/g++.dg/cpp2a/pr88534.C | 65 ++++++++++++++++++++++++++++++++++
> gcc/testsuite/g++.dg/cpp2a/pr88537.C | 16 ++++++++
> 3 files changed, 88 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/cpp2a/pr88534.C
> create mode 100644 gcc/testsuite/g++.dg/cpp2a/pr88537.C
>
> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> index 8305555681447..478d9b9b289b1 100644
> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -13601,6 +13601,13 @@ generic_parameter_die (tree parm, tree arg,
> dw_die_ref tmpl_die = NULL;
> const char *name = NULL;
>
> + /* C++2a accepts class literals as template parameters, and var
> + decls with initializers represent them. The VAR_DECLs would be
> + rejected, but we can take the DECL_INITIAL constructor and
> + attempt to expand it. */
> + if (TREE_CODE (arg) == VAR_DECL)
You can use VAR_P for this.
Marek