From patchwork Wed Apr 28 05:45:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 1470977 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=PLLCEgT/; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FVSKl20V4z9sX2 for ; Wed, 28 Apr 2021 15:46:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5B37388CC1E; Wed, 28 Apr 2021 05:45:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5B37388CC1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1619588755; bh=D1ZmdAFy1hVNTPckWrdS7Yvxl2QPBfNhzTMnoC6trAM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=PLLCEgT/J4CicdyaEhV1w7X6JAiYTqnutZsf7s3B0655V6E//bquqIn6lxEJzpRaH DrQ9GGstpx0te+cttenegmO5/nQvSAhGCfTlM2NXneHVj2oA0pOvLtloLM2FHTwWE2 gQlrmmfUMgBasz8QVOFL/EfUHgvwB/WBRT5PW0bI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 11328385782A for ; Wed, 28 Apr 2021 05:45:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 11328385782A Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 13S5X9mO010607 for ; Wed, 28 Apr 2021 01:45:52 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 3871hk0by3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 28 Apr 2021 01:45:52 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 13S5cQ17028757 for ; Wed, 28 Apr 2021 05:45:50 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 384ay8hp91-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 28 Apr 2021 05:45:50 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 13S5jljG29032880 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 28 Apr 2021 05:45:47 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9EBF5A4055 for ; Wed, 28 Apr 2021 05:45:47 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7618EA404D for ; Wed, 28 Apr 2021 05:45:47 +0000 (GMT) Received: from li-23497a81-5215-11cb-9bae-a81330ecc14b.fritz.box (unknown [9.171.22.57]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP for ; Wed, 28 Apr 2021 05:45:47 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/1] PR100281 Fix SImode pointer handling Date: Wed, 28 Apr 2021 07:45:47 +0200 Message-Id: <20210428054547.9550-1-krebbel@linux.ibm.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: LYxS3D8zzSnS9TWYLKDjBAcss7xBuGSX X-Proofpoint-GUID: LYxS3D8zzSnS9TWYLKDjBAcss7xBuGSX X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.761 definitions=2021-04-28_03:2021-04-27, 2021-04-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 mlxscore=0 suspectscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104060000 definitions=main-2104280035 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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-Patchwork-Original-From: Andreas Krebbel via Gcc-patches From: Andreas Krebbel Reply-To: Andreas Krebbel Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The problem appears to be triggered by two locations in the front-end where non-POINTER_SIZE pointers aren't handled right now. 1. An assertion in strip_typedefs is triggered because the alignment of the types don't match. This in turn is caused by creating the new type with build_pointer_type instead of taking the type of the original pointer into account. 2. An assertion in cp_convert_to_pointer is triggered which expects the target type to always have POINTER_SIZE. Ok for mainline? gcc/cp/ChangeLog: PR c++/100281 * cvt.c (cp_convert_to_pointer): Use the size of the target pointer type. * tree.c (strip_typedefs): Use build_pointer_type_for_mode for non-POINTER_SIZE pointers. gcc/testsuite/ChangeLog: PR c++/100281 * g++.target/s390/pr100281.C: New test. --- gcc/cp/cvt.c | 2 +- gcc/cp/tree.c | 5 ++++- gcc/testsuite/g++.target/s390/pr100281.C | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.target/s390/pr100281.C diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index f1687e804d1..7fa6e8df52b 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -232,7 +232,7 @@ cp_convert_to_pointer (tree type, tree expr, bool dofold, { if (TYPE_PRECISION (intype) == POINTER_SIZE) return build1 (CONVERT_EXPR, type, expr); - expr = cp_convert (c_common_type_for_size (POINTER_SIZE, 0), expr, + expr = cp_convert (c_common_type_for_size (TYPE_PRECISION (type), 0), expr, complain); /* Modes may be different but sizes should be the same. There is supposed to be some integral type that is the same width diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index a8bfd5fc053..6f6b732c9c9 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1556,7 +1556,10 @@ strip_typedefs (tree t, bool *remove_attributes, unsigned int flags) { case POINTER_TYPE: type = strip_typedefs (TREE_TYPE (t), remove_attributes, flags); - result = build_pointer_type (type); + if (TYPE_PRECISION (t) == POINTER_SIZE) + result = build_pointer_type (type); + else + result = build_pointer_type_for_mode (type, TYPE_MODE (t), false); break; case REFERENCE_TYPE: type = strip_typedefs (TREE_TYPE (t), remove_attributes, flags); diff --git a/gcc/testsuite/g++.target/s390/pr100281.C b/gcc/testsuite/g++.target/s390/pr100281.C new file mode 100644 index 00000000000..f45798c3879 --- /dev/null +++ b/gcc/testsuite/g++.target/s390/pr100281.C @@ -0,0 +1,10 @@ +// PR C++/100281 +// { dg-do compile } + +typedef void * __attribute__((mode (SI))) __ptr32_t; + +void foo(){ + unsigned int b = 100; + __ptr32_t a; + a = b; /* { dg-error "invalid conversion from 'unsigned int' to '__ptr32_t'.*" } */ +}