Message ID | 20220124152740.3735632-1-ppalka@redhat.com |
---|---|
State | Committed |
Commit | b1aa2a3cf1ba233ccd5a49fde85a2ca7e5f620e9 |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8DEAD3858004 for <patchwork@sourceware.org>; Mon, 24 Jan 2022 15:28:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DEAD3858004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643038103; bh=O+7MRU78fcwM8SS2I2YrJ+e4VgiC4JGXp4C8dHO3+2A=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=SlamHmbWKbtSLCbzpkqUuVI9+tbIhdz1f8TbOZxnwDKbjU4XrBVtNpF+scI6BQ6X3 ULZnlOOrRxVGcapvyDpfFuRXPBbs6rVzuuEKEwr0XmlvUwLqsFp9Dgg4OWKU/aIsPg aJZkp4gEniAtrSSZxpd5EVUaL6R2LSH1AACFOgPU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 DADB33858D39 for <gcc-patches@gcc.gnu.org>; Mon, 24 Jan 2022 15:27:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DADB33858D39 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-58-ZLtjWWuSObSssxqekUxIew-1; Mon, 24 Jan 2022 10:27:51 -0500 X-MC-Unique: ZLtjWWuSObSssxqekUxIew-1 Received: by mail-qt1-f200.google.com with SMTP id g18-20020ac84b72000000b002cf274754c5so2249669qts.14 for <gcc-patches@gcc.gnu.org>; Mon, 24 Jan 2022 07:27:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=O+7MRU78fcwM8SS2I2YrJ+e4VgiC4JGXp4C8dHO3+2A=; b=Waca6bWpTfPa3oO4iskufL14rwjUx9MuUQZBMkZjLYvTcUdn3Ypp4EIxV57qpAjY1G tYx/UzPVtm2c+mzUvSP9DTAN/T4uwgYWeQf09zkFl2tIEf9OJodQOJWvHJEzz+7qg6jZ rA3ASkmbij1v0JxG2JNmBSXYd5Vc2Hhil693bPDRfSOc1O1iCbplun6AjWbzcbsLY4VB 4/cdqmKKiSSikTeCZz1D/GBuJ8EABisLVcsXIMoIpfQ74o3jEKeKcEZ/9fWvt7XRrUo4 e6CwD72d4jFI4HGwvyZug3LuHUB2Urj4nwmueALMloW4sDuY8FPfoWuF0hlbecrLVV2n jHwg== X-Gm-Message-State: AOAM530FtOetjuWfVOzv0+HXY8yGZByqZyrxt8b4PWJF4Khwy/Jda3jx p8MJkqLF/zVYIZeiH6XxjYRjxX0RKKCHUbM0/miOWM1JgC4o8lrQLdfPkLFVJMLsSzrhzDexgG5 gAUMSowtv3t5GUtUo9t5FfXkZ3wzvpQnl0hFUKqC9xfnY/LYl8S7c/qarvfaO8krheYg= X-Received: by 2002:a05:6214:411c:: with SMTP id kc28mr14777037qvb.35.1643038070167; Mon, 24 Jan 2022 07:27:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYfxdZscvhSV0Ok65H8EveWMruxpMMQmMDYB4YJf53rPjIB890Vh3Kw3bb11zyy7DodHPdjQ== X-Received: by 2002:a05:6214:411c:: with SMTP id kc28mr14777009qvb.35.1643038069831; Mon, 24 Jan 2022 07:27:49 -0800 (PST) Received: from localhost.localdomain (ool-18e40894.dyn.optonline.net. [24.228.8.148]) by smtp.gmail.com with ESMTPSA id bj29sm6997420qkb.109.2022.01.24.07.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jan 2022 07:27:49 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Fix non-portable default argument of make_auto_1 [PR104197] Date: Mon, 24 Jan 2022 10:27:40 -0500 Message-Id: <20220124152740.3735632-1-ppalka@redhat.com> X-Mailer: git-send-email 2.35.0.rc1 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-Spam-Status: No, score=-14.4 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_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <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>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Patrick Palka via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Patrick Palka <ppalka@redhat.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
c++: Fix non-portable default argument of make_auto_1 [PR104197]
|
|
Commit Message
Patrick Palka
Jan. 24, 2022, 3:27 p.m. UTC
Avoid using the macro current_template_depth, which expands to an expression in terms of __FUNCTION__, within the signature of a function. Clang warns about this and MSVC rejects it. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/104197 gcc/cp/ChangeLog: * pt.cc (make_auto_1): Use -1 as a placeholder default argument for level. --- gcc/cp/pt.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Comments
On Mon, Jan 24, 2022 at 10:27:40AM -0500, Patrick Palka via Gcc-patches wrote: > Avoid using the macro current_template_depth, which expands to an > expression in terms of __FUNCTION__, within the signature of a function. > Clang warns about this and MSVC rejects it. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? LGTM. > PR c++/104197 > > gcc/cp/ChangeLog: > > * pt.cc (make_auto_1): Use -1 as a placeholder default argument > for level. > --- > gcc/cp/pt.cc | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index bba62a5800a..8f50b9c4d3c 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -28477,9 +28477,10 @@ make_args_non_dependent (vec<tree, va_gc> *args) > by default. If set_canonical is true, we set TYPE_CANONICAL on it. */ > > static tree > -make_auto_1 (tree name, bool set_canonical, > - int level = current_template_depth + 1) > +make_auto_1 (tree name, bool set_canonical, int level = -1) > { > + if (level == -1) > + level = current_template_depth + 1; > tree au = cxx_make_type (TEMPLATE_TYPE_PARM); > TYPE_NAME (au) = build_decl (input_location, TYPE_DECL, name, au); > TYPE_STUB_DECL (au) = TYPE_NAME (au); > -- > 2.35.0.rc1 > Marek
On 1/24/22 10:27, Patrick Palka wrote: > Avoid using the macro current_template_depth, which expands to an > expression in terms of __FUNCTION__, within the signature of a function. > Clang warns about this and MSVC rejects it. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk? OK. > PR c++/104197 > > gcc/cp/ChangeLog: > > * pt.cc (make_auto_1): Use -1 as a placeholder default argument > for level. > --- > gcc/cp/pt.cc | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > index bba62a5800a..8f50b9c4d3c 100644 > --- a/gcc/cp/pt.cc > +++ b/gcc/cp/pt.cc > @@ -28477,9 +28477,10 @@ make_args_non_dependent (vec<tree, va_gc> *args) > by default. If set_canonical is true, we set TYPE_CANONICAL on it. */ > > static tree > -make_auto_1 (tree name, bool set_canonical, > - int level = current_template_depth + 1) > +make_auto_1 (tree name, bool set_canonical, int level = -1) > { > + if (level == -1) > + level = current_template_depth + 1; > tree au = cxx_make_type (TEMPLATE_TYPE_PARM); > TYPE_NAME (au) = build_decl (input_location, TYPE_DECL, name, au); > TYPE_STUB_DECL (au) = TYPE_NAME (au);
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index bba62a5800a..8f50b9c4d3c 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -28477,9 +28477,10 @@ make_args_non_dependent (vec<tree, va_gc> *args) by default. If set_canonical is true, we set TYPE_CANONICAL on it. */ static tree -make_auto_1 (tree name, bool set_canonical, - int level = current_template_depth + 1) +make_auto_1 (tree name, bool set_canonical, int level = -1) { + if (level == -1) + level = current_template_depth + 1; tree au = cxx_make_type (TEMPLATE_TYPE_PARM); TYPE_NAME (au) = build_decl (input_location, TYPE_DECL, name, au); TYPE_STUB_DECL (au) = TYPE_NAME (au);