From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53684 invoked by alias); 23 Apr 2015 15:49:49 -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 53614 invoked by uid 89); 23 Apr 2015 15:49:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 23 Apr 2015 15:49:48 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3NFnkUE023477 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 23 Apr 2015 11:49:46 -0400 Received: from [10.10.116.45] ([10.10.116.45]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3NFnkJM009993; Thu, 23 Apr 2015 11:49:46 -0400 Message-ID: <55391495.8040103@redhat.com> Date: Thu, 23 Apr 2015 15:49:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Richard Biener CC: gcc-patches List Subject: RFA (tree.c): PATCH for may_alias vs. TYPE_CANONICAL, related to c++/50800 Content-Type: multipart/mixed; boundary="------------050904010902080502040801" X-SW-Source: 2015-04/txt/msg01428.txt.bz2 This is a multi-part message in MIME format. --------------050904010902080502040801 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 592 In general, TYPE_CANONICAL of a type strips all attributes. An exception to this seems to be that TYPE_REF_CAN_ALIAS_ALL remains set on the TYPE_CANONICAL of a pointer/reference type even though its TREE_TYPE no longer has the may_alias attribute, and is inconsistent with "affects_type_identity" being false for may_alias. This seems to have been a mistake in the patch that first introduced TYPE_CANONICAL, rather than a deliberate choice. I'm also planning to fix 50800 in the front end, but this patch still seems like an improvement. Tested x86-64-pc-linux-gnu, OK for trunk? --------------050904010902080502040801 Content-Type: text/x-patch; name="50800.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="50800.patch" Content-length: 2415 commit 724a66ba837560ba233b00cddf5d5d93ec5888f4 Author: Jason Merrill Date: Thu Apr 16 13:57:11 2015 -0400 PR c++/50800 gcc/ * tree.c (build_reference_type_for_mode): Don't pass can_alias_all down when building TYPE_CANONICAL. (build_pointer_type_for_mode): Likewise. gcc/cp/ * typeck.c (structural_comptypes): Don't check TYPE_REF_CAN_ALIAS_ALL. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index e9d4cae..7646225 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1310,7 +1310,6 @@ structural_comptypes (tree t1, tree t2, int strict) case POINTER_TYPE: if (TYPE_MODE (t1) != TYPE_MODE (t2) - || TYPE_REF_CAN_ALIAS_ALL (t1) != TYPE_REF_CAN_ALIAS_ALL (t2) || !same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))) return false; break; diff --git a/gcc/testsuite/g++.dg/ext/alias-canon2.C b/gcc/testsuite/g++.dg/ext/alias-canon2.C index 4833db8..3806cb4 100644 --- a/gcc/testsuite/g++.dg/ext/alias-canon2.C +++ b/gcc/testsuite/g++.dg/ext/alias-canon2.C @@ -31,6 +31,3 @@ out_long (ui64 longVal) } } } - -void f(ui32 *) { } -void f(ui32a *) { } diff --git a/gcc/testsuite/g++.dg/ext/attrib50.C b/gcc/testsuite/g++.dg/ext/attrib50.C new file mode 100644 index 0000000..a46c9f7 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib50.C @@ -0,0 +1,11 @@ +// PR c++/50800 + +template struct B; +template struct B { + typedef T type; +}; +struct A { + typedef int TA __attribute__((__may_alias__)); +}; +void d() { B b; } +int main() { B b; } diff --git a/gcc/tree.c b/gcc/tree.c index 151e3e2..43c4a36 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -7704,7 +7704,7 @@ build_pointer_type_for_mode (tree to_type, machine_mode mode, else if (TYPE_CANONICAL (to_type) != to_type) TYPE_CANONICAL (t) = build_pointer_type_for_mode (TYPE_CANONICAL (to_type), - mode, can_alias_all); + mode, false); /* Lay out the type. This function has many callers that are concerned with expression-construction, and this simplifies them all. */ @@ -7771,7 +7771,7 @@ build_reference_type_for_mode (tree to_type, machine_mode mode, else if (TYPE_CANONICAL (to_type) != to_type) TYPE_CANONICAL (t) = build_reference_type_for_mode (TYPE_CANONICAL (to_type), - mode, can_alias_all); + mode, false); layout_type (t); --------------050904010902080502040801--