From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 091073858CDB for ; Thu, 13 Jul 2023 13:20:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 091073858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689254422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RMOKAmx1Ufra5YgEkXglDKuS1HTgKcSrkHL0oErUeKU=; b=gfuxMJqUbHBAyUMtsw/nXuwZEcqMykj7m4seABE7T+iKlA/ivU96rP78wjbytj3zoz3hDM jXYsWCmppGzOOP4bepcF7tPDog4UeLtlOQIfH/hSIq6v3YHEQ4+2UY7mBw30v3bzyCbGvU WgBFbhEZgse8iLHUv6aD1k+O/aS6roc= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-34-0v9_Lq74MZGWUtyor4Wq2Q-1; Thu, 13 Jul 2023 09:20:21 -0400 X-MC-Unique: 0v9_Lq74MZGWUtyor4Wq2Q-1 Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-560ce5f7646so1043845eaf.3 for ; Thu, 13 Jul 2023 06:20:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689254420; x=1691846420; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RMOKAmx1Ufra5YgEkXglDKuS1HTgKcSrkHL0oErUeKU=; b=BKupYCmGZMuVcUxcR254RITUmYGRdlNWHnm4U6eYdKwtRNsvjSoWNceRXfWmrpSP4n +pY/mqxofY3L+sR7A+DYa63ESgWKxZIyUrcIMpDatpvi3zG4RDnmolyb9/yaOBwP9uyv CRwpSawG/VrL5R8XNuFozmgp7R1tYED5q3ZVJQtuUZoxFDoWYmO5xUm0Xsh6gxvHIYS8 mv26p8fxXDbhycg+Hc+12MQ5gqBufYC7EZF5AN7E9XfLO3SXVlI40gPOFee/jcIrc43v 7kLvIyvZLVJ02wF3i9a6CfLW7gBRNkyEN/+qWGMJFfiKnUHMSRf0Dp9+B69+nrV+tMmW 13aw== X-Gm-Message-State: ABy/qLZTUSzei128nyrNavL0lf59uYh0P+CfcJa3R/TbBzVOoSOSQlTz 4BsJLh3z4VMl37cZdFBmF8L3h2EWYu4sAOMZ6QzhnleDxmBwjq3nkY6fPg3sU2+cJqrJGI2BZCn fMJhfhrZQVYIHuC9WxmBjyJNszMwd9Q4a7KTXpL8/dU6elvCLWmPbFoCmBuUD0dlOaLiKszWstD U= X-Received: by 2002:aca:f1c6:0:b0:3a4:298f:b2e0 with SMTP id p189-20020acaf1c6000000b003a4298fb2e0mr1715851oih.26.1689254420422; Thu, 13 Jul 2023 06:20:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGCGBjN/H+lQaQ58SJaBDx3GDREWezKNJT0yqwAPt3FdpqnVXzwbCqYC4/oxHp+RvZlvVQg5w== X-Received: by 2002:aca:f1c6:0:b0:3a4:298f:b2e0 with SMTP id p189-20020acaf1c6000000b003a4298fb2e0mr1715833oih.26.1689254420094; Thu, 13 Jul 2023 06:20:20 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id a8-20020ac84348000000b003e69c51cf53sm3079518qtn.72.2023.07.13.06.20.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 06:20:19 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: mangling template-id of unknown template [PR110524] Date: Thu, 13 Jul 2023 09:20:17 -0400 Message-ID: <20230713132017.3289546-1-ppalka@redhat.com> X-Mailer: git-send-email 2.41.0.327.gaa9166bcc0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk and perhaps 13? -- >8 -- This fixes a crash when mangling an ADL-enabled call to a template-id naming an unknown template (as per P0846R0). PR c++/110524 gcc/cp/ChangeLog: * mangle.cc (write_expression): Handle TEMPLATE_ID_EXPR whose template is already an IDENTIFIER_NODE. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/fn-template26.C: New test. --- gcc/cp/mangle.cc | 3 ++- gcc/testsuite/g++.dg/cpp2a/fn-template26.C | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/fn-template26.C diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc index 7dab4e62bc9..bef0fda6d22 100644 --- a/gcc/cp/mangle.cc +++ b/gcc/cp/mangle.cc @@ -3312,7 +3312,8 @@ write_expression (tree expr) else if (TREE_CODE (expr) == TEMPLATE_ID_EXPR) { tree fn = TREE_OPERAND (expr, 0); - fn = OVL_NAME (fn); + if (!identifier_p (fn)) + fn = OVL_NAME (fn); if (IDENTIFIER_ANY_OP_P (fn)) write_string ("on"); write_unqualified_id (fn); diff --git a/gcc/testsuite/g++.dg/cpp2a/fn-template26.C b/gcc/testsuite/g++.dg/cpp2a/fn-template26.C new file mode 100644 index 00000000000..d4a17eb9bd1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/fn-template26.C @@ -0,0 +1,16 @@ +// PR c++/110524 +// { dg-do compile { target c++20 } } + +template +auto f(T t) -> decltype(g(t)); + +namespace N { + struct A { }; + template void g(T); +}; + +int main() { + f(N::A{}); +} + +// { dg-final { scan-assembler "_Z1fIN1N1AEEDTcl1gIT_Efp_EES2_" } } -- 2.41.0.327.gaa9166bcc0