From patchwork Thu May 21 20:50:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 475219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BDA6E140781 for ; Fri, 22 May 2015 06:51:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=JnDUR2+/; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=s3xadvK5qZkPH1i0TVWmUBfBgx62RgRELmhimg2efMW w6RJqJgu5AQkOzeAM9ua/yq5UFMNKQkhuaRdG/9qvKENEq8uf+eweELpuBpqKxb9 DdFLbxdBnP8x6urmE8E6yULM6GH2uuDnYnqgQ1tvQrC5Lgu8n7ZjDkKWfWseP59w = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=V21owUnSi1m2NFxViqXMV08L8xM=; b=JnDUR2+/HNnjUe/rY AGXAer6aM3aYAPCP1X6BaVHS4PIKy1O12DRwvqD0G72/CFyRr9fa/IJxu5x9mhka VrgE4te2wW9Bdt6QGdFDIxptM6DBpnAlpI3Ld4ROJ16MtCpCnHOR8CgXqRwOkvmz 5yE942bk88PH4Utq0rbi+dliOg= Received: (qmail 123895 invoked by alias); 21 May 2015 20:50:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 123886 invoked by uid 89); 21 May 2015 20:50:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-qg0-f41.google.com Received: from mail-qg0-f41.google.com (HELO mail-qg0-f41.google.com) (209.85.192.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 21 May 2015 20:50:52 +0000 Received: by qgew3 with SMTP id w3so48474744qge.2 for ; Thu, 21 May 2015 13:50:50 -0700 (PDT) X-Received: by 10.140.38.19 with SMTP id s19mr6716502qgs.14.1432241450148; Thu, 21 May 2015 13:50:50 -0700 (PDT) Received: from ?IPv6:2601:6:8380:343:a2a8:cdff:fe3e:b48? ([2601:6:8380:343:a2a8:cdff:fe3e:b48]) by mx.google.com with ESMTPSA id i7sm9069272qge.32.2015.05.21.13.50.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 May 2015 13:50:49 -0700 (PDT) Message-ID: <555E4528.6060506@acm.org> Date: Thu, 21 May 2015 16:50:48 -0400 From: Nathan Sidwell User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: GCC Patches CC: Jason Merrill Subject: [C++ PATCH] Fix return deduction and ref-quals I've committed this obvious patch to fix PR 60943. When deducing an auto return type we failed to propagate any reference qualification on the function type. built & tested on x86_64-linux. nathan 2015-05-21 Nathan Sidwell cp/ PR c++/60943 * decl2.c (change_return_type): Propagate FUNCTION_REF_QUALIFIED. testsuite/ * g++.dg/cpp1y/pr60943.C: New. Index: cp/decl2.c =================================================================== --- cp/decl2.c (revision 223463) +++ cp/decl2.c (working copy) @@ -195,6 +195,8 @@ change_return_type (tree new_ret, tree f else newtype = build_method_type_directly (class_of_this_parm (fntype), new_ret, TREE_CHAIN (args)); + if (FUNCTION_REF_QUALIFIED (fntype)) + newtype = build_ref_qualified_type (newtype, type_memfn_rqual (fntype)); if (raises) newtype = build_exception_variant (newtype, raises); if (attrs) Index: testsuite/g++.dg/cpp1y/pr60943.C =================================================================== --- testsuite/g++.dg/cpp1y/pr60943.C (revision 0) +++ testsuite/g++.dg/cpp1y/pr60943.C (working copy) @@ -0,0 +1,16 @@ +// { dg-options "-std=c++14" } + +struct A { + auto f() & {} + auto f() && {} +}; + +void Foo (A &a) +{ + a.f(); +} + +void Bar (A &&a) +{ + a.f (); +}