From: Eli Zaretskii <eliz@gnu.org>
To: Keith Seitz <keiths@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Add infcall support for C++ constructor-style expressions
Date: Fri, 27 Mar 2026 08:50:38 +0300 [thread overview]
Message-ID: <86tsu1vn0x.fsf@gnu.org> (raw)
In-Reply-To: <a65096b4d774c86d53d976b1bb2c39b2c6fc67ce.1774552598.git.keiths@redhat.com> (message from Keith Seitz on Thu, 26 Mar 2026 12:17:20 -0700)
> From: Keith Seitz <keiths@redhat.com>
> Date: Thu, 26 Mar 2026 12:17:20 -0700
>
> This patch adds an initial try at teaching the expression parser/evaluator
> to construct temporary objects requiring construction during an inferior
> function call.
>
> To accomplish this, I've chosen the route of modifying the parser to
> teach it that `Type(args)' is a function call when `Type' names a
> class/struct/union and is immediately followed by '(', that is, via look-
> ahead). A new parser token and grammar rule have been added to deal
> with this new production.
>
> The real work is dispatched to `type_operation::evaluate_funcall',
> allocating memory for the temporary and finding the most suitable constructor
> with `find_overload_match'. It then runs the inferior call, returning
> the newly constructed object.
>
> I've included many tests covering as many corner cases as I could invent,
> and these tests are clang clean. They also introduce no regressions on
> x86-64 Fedora 43 with GCC 15.2.1 and RHEL 9.4 with GCC 11.5.0.
>
> Example:
> Consider a C++ frame where 'struct S { int x; S(int); ... }' is in scope
>
> Before:
> (gdb) print S(42)
> ❌️ A syntax error in expression, near `10)'.
>
> After:
> (gdb) print S(42)
> $1 = {x = 42}
>
> Note that no attempt has been made to deal with templates. Hopefully
> a follow-on patch can address that.
> ---
> gdb/NEWS | 5 +
> gdb/c-exp.y | 86 +++++++++--
> gdb/eval.c | 55 ++++++++
> gdb/expop.h | 5 +
> gdb/testsuite/gdb.cp/infcall-ctors.cc | 128 +++++++++++++++++
> gdb/testsuite/gdb.cp/infcall-ctors.exp | 188 +++++++++++++++++++++++++
> 6 files changed, 457 insertions(+), 10 deletions(-)
> create mode 100644 gdb/testsuite/gdb.cp/infcall-ctors.cc
> create mode 100644 gdb/testsuite/gdb.cp/infcall-ctors.exp
The NEWS part is okay, thanks.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
prev parent reply other threads:[~2026-03-27 5:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 19:17 Keith Seitz
2026-03-27 5:50 ` Eli Zaretskii [this message]
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=86tsu1vn0x.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=keiths@redhat.com \
/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: link
Be 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