From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1059) id 641D03858C20; Tue, 11 Oct 2022 11:40:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 641D03858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665488404; bh=fPgOYIB7HJjkLvhQVIylXIURxTJO14U2Ui0ZWlL26ro=; h=From:To:Subject:Date:From; b=i5jmp8pzfQBAubt5Hg4u0DV9ctDax0Ij2ECYSVRk3U6x47DuFFr0CvGYnv+jUDEc1 Y9yUImvchNLTqIl8paTnp0u+pgSCG313z8px566Vpx9HZh5EmjsRt1tl0Rbp+M+0z9 +5HxXIsNnkX7DlFXR9f8oXrVAxiHOjmdky86IAco= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Nathan Sidwell To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3227] libiberty: Demangling 'M' prefixes X-Act-Checkin: gcc X-Git-Author: Nathan Sidwell X-Git-Refname: refs/heads/master X-Git-Oldrev: ee467644c53ee2f7d633a8e1f53603feafab4351 X-Git-Newrev: 0fa35c7e2974a22b2107fa378895c3069fe07ff3 Message-Id: <20221011114004.641D03858C20@sourceware.org> Date: Tue, 11 Oct 2022 11:40:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0fa35c7e2974a22b2107fa378895c3069fe07ff3 commit r13-3227-g0fa35c7e2974a22b2107fa378895c3069fe07ff3 Author: Nathan Sidwell Date: Fri Sep 30 09:43:30 2022 -0700 libiberty: Demangling 'M' prefixes The grammar for a lambda context can include 'M', and we were adding the component that generated to the substitution table twice. Just ignore the 'M' completely -- we'll already have done the checks we need when we saw its predecessor. A prefix cannot be the last component of a nested name, so we do not need to check for that case (although we could if we wanted to be more lenient). libiberty/ * cp-demangle.c (d_prefix): 'M' components are not (re-)added to the substitution table. * testsuite/demangle-expected: Add tests. Diff: --- libiberty/cp-demangle.c | 8 +++----- libiberty/testsuite/demangle-expected | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index 303bfbf709e..4beb4d257bb 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -1609,12 +1609,10 @@ d_prefix (struct d_info *di, int substable) } else if (peek == 'M') { - /* Initializer scope for a lambda. We don't need to represent - this; the normal code will just treat the variable as a type - scope, which gives appropriate output. */ - if (ret == NULL) - return NULL; + /* Initializer scope for a lambda. We already added it as a + substitution candidate, don't do that again. */ d_advance (di, 1); + continue; } else { diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index 90dd4a13945..bd92b12076b 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -1581,3 +1581,24 @@ void L1()::{lambda((auto:1)...)#1}::operator()(int, int*) const _ZZ2L1vENKUlDpT_E_clIJiPiEEEDaS0_ auto L1()::{lambda((auto:1)...)#1}::operator()(int, int*) const +_Z7captureIN4gvarMUlvE_EE7WrapperIT_EOS3_ +Wrapper capture(gvar::{lambda()#1}&&) + +_ZNK2L2MUlT_T0_E_clIifEEvS_S0_ +void L2::{lambda(auto:1, auto:2)#1}::operator()(L2, int) const + +_ZNK1C1fMUlT_E_clIMS_iEEDaS1_ +auto C::f::{lambda(auto:1)#1}::operator()(int C::*) const + +_ZNK2L2MUlT_T0_E_clIifEEvS0_S1_ +void L2::{lambda(auto:1, auto:2)#1}::operator()(int, float) const + +_ZNK1B2L3MUlT_T0_E_clIjdEEvS1_S2_ +void B::L3::{lambda(auto:1, auto:2)#1}::operator()(unsigned int, double) const + +_Z3fooIN1qMUlvE_ENS0_UlvE0_EEiOT_OT0_ +int foo(q::{lambda()#1}&&, q::{lambda()#2}&&) + +_ZNK2L1MUlDpT_E_clIJiPiEEEvS1_ +void L1::{lambda((auto:1)...)#1}::operator()(int, int*) const +