From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eFWxOBADrGo3MxcAWB0awg (envelope-from ) for ; Thu, 17 Sep 2026 11:11:12 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=B1VdJhSW; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id D4F7A1E01F; Thu, 17 Sep 2026 11:11:12 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0D1891E01F for ; Thu, 17 Sep 2026 11:11:12 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 16A5C4BAE7E7 for ; Thu, 17 Sep 2026 15:11:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16A5C4BAE7E7 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=B1VdJhSW Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id B1C8E4BA23C7 for ; Thu, 17 Sep 2026 15:10:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1C8E4BA23C7 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B1C8E4BA23C7 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789657844; cv=none; b=oOZnFc7109MfypF7ZTFfsYG0gHgYpitmSLGnVW/eDdKU+BwOXAhNfaWzwQ3Pii8Jqkbz6iOVlywSN3ZfE8opWgV+YccodMeQgt6gK60/wny1Nw7LBn+WRZqD4GKuyujGJba0tgyqeOPx+3wX8Qcv+3uylY0eeEJZQFRbl6oFZF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1789657844; c=relaxed/simple; bh=iBw6jWo6MC2L5l9wv9If6ljBcRzAry3sZmELMRYqs7k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mTa7GiYc3V7PFeqqzwMg6T3lKC+d+h2brFiqAyONzjllGCj+VIt0SGOeSEJhrKYjHvdbAeU7V7djxoTRuiAIuoRpCZSzapgd8CfkoaNj2DFvMjv6PSYNsDwYG3OfZiZZsR7WvnQUbtMKwAaM+0dxl2ay/CFP0J7Z2x5ik3DqnAY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=B1VdJhSW DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1C8E4BA23C7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1789657844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r8454RpSFKm5oNJHPh9u3itgqTFw37o4PFQM37d3DOM=; b=B1VdJhSWUwzWoGNJ863gjcoAOUQWzkQRkIBlie4F9bhtkm+jYKbmN6zh9CZBaPUDsqhSiP gmlbGApLjdFnpicLd51jTq1JNvFicsbSg6MZ9rPs7d57AVGVTkYPxS8IrotjyufElYaiCm DpfwWi0fKkfDTmRsW2xOv9elk+Dc3l0= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-278-HY_MLGcdOQKL4aUHlc6Jwg-1; Thu, 17 Sep 2026 11:10:41 -0400 X-MC-Unique: HY_MLGcdOQKL4aUHlc6Jwg-1 X-Mimecast-MFC-AGG-ID: HY_MLGcdOQKL4aUHlc6Jwg_1789657841 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49ccfad90f1so7229395e9.0 for ; Thu, 17 Sep 2026 08:10:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789657840; x=1790262640; h=content-transfer-encoding:content-type:mime-version:message-id:date :references:in-reply-to:subject:to:from:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to:content-type; bh=u98RzA15k+g876DpqixTYTf3N8lmElXYbWDrtCTEoM0=; b=CsXxJg0T8YnnaE6PbumRda7M2AATDxOw1f8jvgQV/L3KxN2/zs38yQ6dE4rn274Ik/ U1NesC8Eg0bNYLWh+DTAk7Zw1zLSefB/hXdrf6QZJGJDC0O3+4fYAgqDUNk/qOvYwFii tBbdKoSi68Jq/54lWaps7HQ/UHdNvOkxyI3Wbt+LXGYZrmxdOuUyszmEfRaQKArE1Q5G pGStg3/caxSrPO3JJVW4FN1RtDWTvr0NBaxfToo++SmNCOKIqipinevoepuMWJXME8DT MKljqf5HYI3p7pABtWLzOoM8rX6GesLQmWTbiDfumJ0FFR5AjPh+8Qbqa1nKh9AKP23g PvqQ== X-Forwarded-Encrypted: i=1; AKwUvBz7zcYn9XR9yovrL4S73BIMtqDsXljG6mE/sQCPfmRbT4HWzEOR3/JFZDMsJRWFW9XSsy3dL54D1o+ySg==@sourceware.org X-Gm-Message-State: AFuF++khax1lSVsN/7+jUgzGldLWWBi4mNEH/3M0scqvWRWihbTtgzKG udbuAuYAmAXFKtBQ2n/qRc6OdzYw8MdfEY/H1ekm3FNhVNQIpy1XUaDuT6sR2NaNRXvRoBzsEx2 3St3Tjwp23qBYHEAaqzrQ/l+9dZbfa/TtluOi4Lvj1VGNR0AUGMHNmOWU0P0bLFI= X-Gm-Gg: AYBFou08av3yBl+j384zkaP+zwLwrZmWYgBMTJ+7TrQdivWOdgNJQWK5v198dHnHHql SiezWjdYIiq7m/KXwpcrfxNppgha+8kH+d+c99xf6QyKE4+59wImFaS+FWYkfXmNBQ1bk5aA6+/ X13bBzD81cYW0UHyNgKxqoO89l17EQ/XlkulPjT/JgxygLfWQbmUkcwRUhEMLvuGwB+oJ2oEV/J MDQXTOL6yhzfeACy4+cyqSzVWrRktXj1q2qFUzIScyHONcy5rvN95+h02fTSdu/0wMu0CsIXTW4 1kizVyeWnU6qEFM9vT6s23BhXDeLVQwNmgM+gvxmDy3nWFoPj4PWdI2KSDNIIzNWP6PkpO9A X-Received: by 2002:a05:600c:5493:b0:49d:286:83d5 with SMTP id 5b1f17b1804b1-49eaf5ff401mr84702175e9.13.1789657840576; Thu, 17 Sep 2026 08:10:40 -0700 (PDT) X-Received: by 2002:a05:600c:5493:b0:49d:286:83d5 with SMTP id 5b1f17b1804b1-49eaf5ff401mr84701765e9.13.1789657840158; Thu, 17 Sep 2026 08:10:40 -0700 (PDT) Received: from localhost ([83.216.138.214]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fbf515cfdsm71664115e9.11.2026.09.17.08.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2026 08:10:39 -0700 (PDT) From: Andrew Burgess To: Keith Seitz , gdb-patches@sourceware.org Subject: Re: [PATCH v2] Add infcall support for C++ constructor-style expressions In-Reply-To: References: Date: Thu, 17 Sep 2026 16:10:38 +0100 Message-ID: <875x03c3rl.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: gIZcsaK0kqMttMfpI42xsYjzC0f1tN7tYRow0ipslHA_1789657841 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Keith Seitz writes: > Changes in v2: > - Formatting fixes > - Use c_isspace to skip whitespace in typename_token_for() > - Merged rules for typename_for_ctor to type_exp > [This adds ~20 shift/reduce conflicts.] > - Updated error message when overload-resolution is off > - Handle static constructors and add new tests for this case > - Added test case for when ctor is not found > - Test early return: remove integer return status > =20 > Thanks, > Keith > > --------- I've only got trivial things to add over Kevin's existing review. > > This patch adds an initial try at teaching the expression parser/evaluato= r > 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 constru= ctor > 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) > =E2=9D=8C=EF=B8=8F A syntax error in expression, near `10)'. I suspect a typo here, the error says '10', but the input is '42'. > diff --git a/gdb/NEWS b/gdb/NEWS > index e233906153a..24d26d29ea5 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -75,6 +75,11 @@ > * The Windows native target now supports scheduler-locking. E.g., > "set scheduler-locking on" now works. Previously it gave an error. > =20 > +* In C++ GDB now accepts constructor-style expressions "TYPE (ARGS)" Need a command after 'In C++' here. > diff --git a/gdb/eval.c b/gdb/eval.c > index a00774bda3d..933415ce028 100644 > --- a/gdb/eval.c > +++ b/gdb/eval.c > @@ -1872,6 +1872,66 @@ type_operation::evaluate (struct type *expect_type= , struct expression *exp, > error (_("Attempt to use a type name as an expression")); > } > =20 > +value * > +type_operation::evaluate_funcall (struct type *expect_type, > +=09=09=09=09 struct expression *exp, > +=09=09=09=09 enum noside noside, > +=09=09=09=09 const std::vector &args) > +{ > + struct type *type =3D std::get<0> (m_storage); > + type =3D check_typedef (type); > + > + /* Constructor-style call Type(args) is only for C++ aggregate types. = */ > + gdb_assert (exp->language_defn->la_language =3D=3D language_cplus); > + > + const char *name =3D type->name (); > + if (name =3D=3D nullptr) > + error (_("Cannot call constructor of unnamed type")); > + > + /* Get the constructor name from the type name. */ > + gdb::unique_xmalloc_ptr ctor_name_ptr =3D cp_func_name (name); > + const char *ctor_name =3D This trailing '=3D' should be moved to the start of the next line. Thanks, Andrew