{"id":2221895,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2221895/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/adjwg9rcHC9SSuiJ@tucnak/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<adjwg9rcHC9SSuiJ@tucnak>","list_archive_url":null,"date":"2026-04-10T12:43:47","name":"c++: Fix up type alias reflection mangling","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"46cf2e077685f4d1493dd789975e4fbe6e9856e8","submitter":{"id":671,"url":"http://patchwork.ozlabs.org/api/1.2/people/671/?format=json","name":"Jakub Jelinek","email":"jakub@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/adjwg9rcHC9SSuiJ@tucnak/mbox/","series":[{"id":499453,"url":"http://patchwork.ozlabs.org/api/1.2/series/499453/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=499453","date":"2026-04-10T12:43:47","name":"c++: Fix up type alias reflection mangling","version":1,"mbox":"http://patchwork.ozlabs.org/series/499453/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221895/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221895/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=al7LeRFW;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=al7LeRFW","sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=redhat.com","sourceware.org; spf=pass smtp.mailfrom=redhat.com","server2.sourceware.org;\n arc=none smtp.remote-ip=170.10.133.124"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsc204BPsz1yGb\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 22:44:23 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 1A38C4BA5439\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 12:44:21 +0000 (GMT)","from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.133.124])\n by sourceware.org (Postfix) with ESMTP id F30014BA5439\n for <gcc-patches@gcc.gnu.org>; Fri, 10 Apr 2026 12:43:53 +0000 (GMT)","from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-mbGFPSfuOmemTXxCSUaHLQ-1; Fri,\n 10 Apr 2026 08:43:52 -0400","from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id 84ED91956054\n for <gcc-patches@gcc.gnu.org>; Fri, 10 Apr 2026 12:43:51 +0000 (UTC)","from tucnak.zalov.cz (unknown [10.44.33.241])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with\n ESMTPS\n id BC8D519560AB; Fri, 10 Apr 2026 12:43:50 +0000 (UTC)","from tucnak.zalov.cz (localhost [127.0.0.1])\n by tucnak.zalov.cz (8.18.1/8.18.1) with ESMTPS id 63AChlbg3951487\n (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT);\n Fri, 10 Apr 2026 14:43:47 +0200","(from jakub@localhost)\n by tucnak.zalov.cz (8.18.1/8.18.1/Submit) id 63AChlPF3951486;\n Fri, 10 Apr 2026 14:43:47 +0200"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 1A38C4BA5439","OpenDKIM Filter v2.11.0 sourceware.org F30014BA5439"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org F30014BA5439","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org F30014BA5439","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1775825034; cv=none;\n b=rSKYMZBrjNnCgKn7X/UkRXxmHbjcfNKt7L5h8YRdzK1lzgGywBtgK75Dn6wYqaC0U1YDF3UaLhLlPgKggGUAxSn0/NbrmyuwOQrxKL+B/zLpBhDIphZRCLs5RwiO5iHeC7VyjZ+Y7cubpMFad4OOJ6AhLby+QkOMSIX3EYcddk8=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1775825034; c=relaxed/simple;\n bh=RPPf83NsLS405VUGxupDpS9zFROR8u6DQOZocXMCeUg=;\n h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version;\n b=vCSWQvBH4RIIEu6glgxMRbhSPAH1E0rEd2enF3A87TBJvgSLCS3QqubzkJqnmEY7tPlEIpVVszZDiv+utexJoG8f2Dnogu7pUMeCNgPZ2A4pVRqEJC5FDhkg7blxdq44otQ5oMu5gnhwXzDghqIVAkKji29kjfg4UQRk7zm4/aI=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775825033;\n h=from:from:reply-to:reply-to:subject:subject:date:date:\n message-id:message-id:to:to:cc:cc:mime-version:mime-version:\n content-type:content-type; bh=hA5wuKY3HbNYRF1r8W4BKXzHIa8PHcwtVWEyPiKKHrE=;\n b=al7LeRFWrYoNlkq7NOpAWoxOUHBnVRSgUeyhWALSDQPft9ASP21lHPWhb6+B3t8STngyd2\n Iv83inQ3S1bhha4uerXoqrlvwtJW2H/8Y8x6lRfhq1l+aO7cmVFr7GSW08nZdX44uMmDUK\n rBKRBffIPB/YWqGmnMybQ3UdL2WXHnw=","X-MC-Unique":"mbGFPSfuOmemTXxCSUaHLQ-1","X-Mimecast-MFC-AGG-ID":"mbGFPSfuOmemTXxCSUaHLQ_1775825031","Date":"Fri, 10 Apr 2026 14:43:47 +0200","From":"Jakub Jelinek <jakub@redhat.com>","To":"Jason Merrill <jason@redhat.com>, Marek Polacek <polacek@redhat.com>","Cc":"gcc-patches@gcc.gnu.org","Subject":"[PATCH] c++: Fix up type alias reflection mangling","Message-ID":"<adjwg9rcHC9SSuiJ@tucnak>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.12","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"C22ChgxgYKez8Jez_pPw3ssiij7Uid6DhMngZ_xX-3I_1775825031","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Reply-To":"Jakub Jelinek <jakub@redhat.com>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"Hi!\n\nAs discussed earlier, including in the\nhttps://github.com/itanium-cxx-abi/cxx-abi/issues/208\nissue, we should include the underlying type in the mangling of\ntype aliases in addition to mangling the name of the type alias,\nbecause in different TUs the type alias could have different underlying\ntypes.\nJust adding write_char ('_'); write_type (DECL_ORIGINAL_TYPE (arg));\nis not enough though, because write_prefix (arg); is subject of\nsubstitutions and we treat the underlying type and type alias as\nsimilar types for substitution purposes.\nSo, I think we have to avoid that, we can remember for substitutions\ndecl_mangling_prefix of the type alias TYPE_DECL, but I think we need\nto then emit the unqualified name and optionally template arguments\nif it is an alias template.\n\nThe following patch implements that.\n\nTested on x86_64-linux and i686-linux, ok for trunk?\n\n2026-04-10  Jakub Jelinek  <jakub@redhat.com>\n\n\t* mangle.cc (write_reflection): Adjust grammar for type alias\n\treflections.  Don't use write_prefix on arg, instead\n\twrite_prefix its mangling context, write_unqualified_name of\n\tthe alias, optionally write_template_args, append underscore\n\tand write_type the original type.\n\n\t* g++.dg/reflect/mangle1.C: Adjust expected mangling of type\n\taliases.\n\n\n\tJakub","diff":"--- gcc/cp/mangle.cc.jj\t2026-04-10 08:45:15.325906730 +0200\n+++ gcc/cp/mangle.cc\t2026-04-10 13:39:15.183584979 +0200\n@@ -4163,7 +4163,8 @@ write_expression (tree expr)\n \t\t  ::= pa [ <nonnegative number> ] _ <encoding>\t# fn param\n \t\t  ::= en <prefix> <unqualified-name>\t# enumerator\n \t\t  ::= an [ <nonnegative number> ] _\t# annotation\n-\t\t  ::= ta <alias prefix>\t\t\t# type alias\n+\t\t  ::= ta <alias prefix> <alias unqualified-name>\n+\t\t      <alias template-args>* _ <type>\t# type alias\n \t\t  ::= ty <type>\t\t\t\t# type\n \t\t  ::= dm <prefix> <unqualified-name>\t# ns data member\n \t\t  ::= un <prefix> [ <nonnegative number> ] _ # unnamed bitfld\n@@ -4218,7 +4219,17 @@ write_reflection (tree refl)\n   else if (strcmp (prefix, \"ta\") == 0)\n     {\n       arg = TYPE_NAME (arg);\n-      write_prefix (arg);\n+      /* Can't use write_prefix (arg) here instead of\n+\t write_prefix + write_unqualified_name + optional\n+\t write_template_args, it shouldn't be\n+\t remembered among substitutions.  */\n+      write_prefix (decl_mangling_context (arg));\n+      write_unqualified_name (arg);\n+      tree template_info = maybe_template_info (arg);\n+      if (template_info)\n+\twrite_template_args (TI_ARGS (template_info));\n+      write_char ('_');\n+      write_type (DECL_ORIGINAL_TYPE (arg));\n     }\n   else if (strcmp (prefix, \"ty\") == 0)\n     write_type (arg);\n--- gcc/testsuite/g++.dg/reflect/mangle1.C.jj\t2026-04-10 08:45:15.361906096 +0200\n+++ gcc/testsuite/g++.dg/reflect/mangle1.C\t2026-04-10 13:58:31.163378726 +0200\n@@ -212,10 +212,10 @@ baz (int x)\n // { dg-final { scan-assembler \"_Z3barILi181ELDmen3NS24Enum1AEEvv\" } }\n // { dg-final { scan-assembler \"_Z3barILi182ELDmen3NS2Uej1C1CEEvv\" } }\n // { dg-final { scan-assembler \"_Z3barILi190ELDman_EEvv\" } }\n-// { dg-final { scan-assembler \"_Z3barILi200ELDmta5AliasEEvv\" } }\n-// { dg-final { scan-assembler \"_Z3barILi201ELDmta3NS25AliasEEvv\" } }\n-// { dg-final { scan-assembler \"_Z3barILi202ELDmta6TAliasILi42EEEEvv\" } }\n-// { dg-final { scan-assembler \"_Z3barILi203ELDmta3NS26TAliasILj0EEEEvv\" } }\n+// { dg-final { scan-assembler \"_Z3barILi200ELDmta5Alias_iEEvv\" } }\n+// { dg-final { scan-assembler \"_Z3barILi201ELDmta3NS25Alias_DmEEvv\" } }\n+// { dg-final { scan-assembler \"_Z3barILi202ELDmta6TAliasILi42EE_4TClsILi42EEEEvv\" } }\n+// { dg-final { scan-assembler \"_Z3barILi203ELDmta3NS26TAliasILj0EE_NS0_4TClsILj0EEEEEvv\" } }\n // { dg-final { scan-assembler \"_Z3barILi210ELDmty1SEEvv\" } }\n // { dg-final { scan-assembler \"_Z3barILi211ELDmtyN3NS21SEEEvv\" } }\n // { dg-final { scan-assembler \"_Z3barILi212ELDmtyKiEEvv\" } }\n","prefixes":[]}