From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14774 invoked by alias); 18 Apr 2014 18:11:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 14765 invoked by uid 89); 18 Apr 2014 18:11:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Apr 2014 18:11:12 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s3IIBB8Z020569 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 18 Apr 2014 14:11:11 -0400 Received: from [10.10.116.17] ([10.10.116.17]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s3IIBAul014263 for ; Fri, 18 Apr 2014 14:11:11 -0400 Message-ID: <53516ABE.6070809@redhat.com> Date: Fri, 18 Apr 2014 18:13:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/60872 (bogus error converting pointer to restricted pointer) Content-Type: multipart/mixed; boundary="------------050707040404080308070102" X-SW-Source: 2014-04/txt/msg01103.txt.bz2 This is a multi-part message in MIME format. --------------050707040404080308070102 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 181 When building up the internal representation of a conversion, G++ was trying to apply 'restrict' to void, which doesn't make sense. Tested x86_64-pc-linux-gnu, applying to trunk. --------------050707040404080308070102 Content-Type: text/x-patch; name="60872.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="60872.patch" Content-length: 1216 commit 53c6cb04ee081b959788da69d36b8d4db1e3d442 Author: Jason Merrill Date: Thu Apr 17 09:22:15 2014 -0400 PR c++/60872 * call.c (standard_conversion): Don't try to apply restrict to void. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 7dbe935..fbd2f83 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1196,9 +1196,10 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, && TREE_CODE (TREE_TYPE (from)) != FUNCTION_TYPE) { tree nfrom = TREE_TYPE (from); + /* Don't try to apply restrict to void. */ + int quals = cp_type_quals (nfrom) & ~TYPE_QUAL_RESTRICT; from = build_pointer_type - (cp_build_qualified_type (void_type_node, - cp_type_quals (nfrom))); + (cp_build_qualified_type (void_type_node, quals)); conv = build_conv (ck_ptr, from, conv); } else if (TYPE_PTRDATAMEM_P (from)) diff --git a/gcc/testsuite/g++.dg/ext/restrict2.C b/gcc/testsuite/g++.dg/ext/restrict2.C new file mode 100644 index 0000000..f053210 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/restrict2.C @@ -0,0 +1,8 @@ +// PR c++/60872 +// { dg-options "" } + +typedef double *__restrict T; +void f(T* p) +{ + void *p2 = p; +} --------------050707040404080308070102--