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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 91863397249A for ; Thu, 7 Jan 2021 21:13:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 91863397249A Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-310-uupeT-p1OTipqFQ6wAWHmw-1; Thu, 07 Jan 2021 16:13:00 -0500 X-MC-Unique: uupeT-p1OTipqFQ6wAWHmw-1 Received: by mail-qt1-f200.google.com with SMTP id j1so6447252qtd.13 for ; Thu, 07 Jan 2021 13:13:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PlxO1AenJUVGSpRd8P11dglM4r3UJ9CYdXKqfZlOyXI=; b=DhErbS6Y80vjsTpUWns6C2Z8cbqmOD6/PxxQ5idyKdsXor7NEpshe9XBZAE+Q8Qhnh YH3IqlhH41hDow5owXDqsAw0uBCMCHjrm4UlaDK9kybk4e0S5GhQvS0iLHQP0Z5aF+dp QQZNpBCMqMP5/RZz/t0/qNBev3C4/tBBTDkv6JHErpxewngfrzvd+Hw7EHn/3S70HHi5 QeKlNHSq+syBYSrf0cH3P4qBPmahaC1T/oZL0K3LPcK88UJp+sGobfZkfhccYsxdNLhH iOtxLF100GgB2PUXlnMn/6DucrDhUoAT24QeC7LlLyf+Gy1BMxiiYk7XUstrpRmJgmVS i6Gg== X-Gm-Message-State: AOAM533Z3BKXpzxVhLMBkTIqSG0rxwe6e/OuHCS9bcKhM6VTAB2ehMFB 1gJsTGQtjMcz8bqbM/0LG6quveNai+aIVFknYylRkH4S5Ed6JbspvwPrjoMAwfLtGqbxQ9Nne7o HoBKNwUMpBOPTqjFOn6pZuxBWxZDZNAhgPBM931pcggvOvFFgxGt2yKxnZZd3jVCj2A== X-Received: by 2002:ac8:220a:: with SMTP id o10mr549598qto.280.1610053978909; Thu, 07 Jan 2021 13:12:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyq3/1YKrZC+encd99TzCtL/weSR7iGksZDNU5Qs5FxvKQKPzf/cBygUzjAy7U3dloybvkgVg== X-Received: by 2002:ac8:220a:: with SMTP id o10mr549571qto.280.1610053978573; Thu, 07 Jan 2021 13:12:58 -0800 (PST) Received: from [192.168.1.148] (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id x185sm3945228qkb.87.2021.01.07.13.12.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Jan 2021 13:12:57 -0800 (PST) Subject: Re: [PATCH] c++: Fix thinko in auto return type checking [PR98441] To: Marek Polacek , GCC Patches References: <20210106003132.1304027-1-polacek@redhat.com> From: Jason Merrill Message-ID: Date: Thu, 7 Jan 2021 16:12:56 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <20210106003132.1304027-1-polacek@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-16.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jan 2021 21:13:02 -0000 On 1/5/21 7:31 PM, Marek Polacek wrote: > This fixes a thinko in my r11-2085 patch: when I said "But only give the > !late_return_type errors when funcdecl_p, to accept e.g. auto (*fp)() = f; > in C++11" I should've done this, otherwise we give bogus errors mentioning > "function with trailing return type" when there is none. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? OK. > gcc/cp/ChangeLog: > > PR c++/98441 > * decl.c (grokdeclarator): Move the !funcdecl_p check inside the > !late_return_type block. > > gcc/testsuite/ChangeLog: > > PR c++/98441 > * g++.dg/cpp0x/auto55.C: New test. > --- > gcc/cp/decl.c | 8 +++++--- > gcc/testsuite/g++.dg/cpp0x/auto55.C | 13 +++++++++++++ > 2 files changed, 18 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/auto55.C > > diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c > index bf6f12c26a0..1a114a2e2d0 100644 > --- a/gcc/cp/decl.c > +++ b/gcc/cp/decl.c > @@ -12241,10 +12241,12 @@ grokdeclarator (const cp_declarator *declarator, > tree late_return_type = declarator->u.function.late_return_type; > if (tree auto_node = type_uses_auto (type)) > { > - if (!late_return_type && funcdecl_p) > + if (!late_return_type) > { > - if (current_class_type > - && LAMBDA_TYPE_P (current_class_type)) > + if (!funcdecl_p) > + /* auto (*fp)() = f; is OK. */; > + else if (current_class_type > + && LAMBDA_TYPE_P (current_class_type)) > /* OK for C++11 lambdas. */; > else if (cxx_dialect < cxx14) > { > diff --git a/gcc/testsuite/g++.dg/cpp0x/auto55.C b/gcc/testsuite/g++.dg/cpp0x/auto55.C > new file mode 100644 > index 00000000000..5bd32ac890d > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/auto55.C > @@ -0,0 +1,13 @@ > +// PR c++/98441 > +// { dg-do compile { target c++11 } } > + > +struct a { > + int& mfn(); > +}; > + > +void fn() > +{ > + int& (a::*myvar1)(void) = &a::mfn; > + auto& (a::*myvar2)(void) = &a::mfn; > + auto (a::*myvar3)(void) = &a::mfn; > +} > > base-commit: ad92bf4b165935b58195825dc8f089f53fd2710b >