From patchwork Fri Sep 15 14:20:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 140466 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1086636vqi; Fri, 15 Sep 2023 07:26:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJ6FKEYqfF1iHwdqOS+wLccnA74BipBokI5/aGFPGA/l1NkrgJJ9RDlkOobL8ehSY+Gf1y X-Received: by 2002:a05:6402:742:b0:52e:5f85:b692 with SMTP id p2-20020a056402074200b0052e5f85b692mr1312174edy.42.1694787989450; Fri, 15 Sep 2023 07:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694787989; cv=none; d=google.com; s=arc-20160816; b=pqn3iVQmY597LZEPlFPWEICKgnzNzh5kcGID2Dpt6gi7TLx+/NGwa/X0vPkFlo9g9y B3LRpM16/EawQQVyUhHquPQwpWrvD/1DMwI8vwUNi+HxHVdIinmzzq2XfOzWEHVaxyNN Ma788mIlPDvR/Y7w3k26eUOOiBeIezGqYnp47je19osNmAc2EWzJmZp+jXgOF2DPd7rp fFPU0zrcjHhufx6UOv30vjdJh3V/wjBch2BsDrsVkBgr4jfe928yWqIVMPDqSYrA5Obq dttlGh/dG9xRj/7XdxhBV3Q+JOLsIr5OPU1+w/cvOzL1bSmRbx75Pdhz/RwpxoO1rUJL i/ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=KwBm4HKocIRXeEAj/DFpsY5c9Yjf/GTsmpgjVbKnshc=; fh=hOhsC1930eHatDPYd2EALQ9Ry/g++vvN4vxlQkRuX+0=; b=DHFSROFE18zC1yBls8rFMJKfNd6ZSkXv6t86K7ed1mjPpK3nX7oepqTCyZbvzKNUlJ c1vErQ7fePABdfSRKnzmveWrjmUIDsQ5PzwmKt8+zmLaJS7wjf1dyr8sThJZn/FUjVP5 lloXmIj8Qn1efHjGT9MFSjvNu8sH0PUSiEKP7i3UpKcdbVolWalRT6b4/m8XlN159GgY Cm/QAfmiQPhP81JDV9IducIEqd2P1VQ5sPuwLDkeDuDTMs54OL/892F0dbZrlkPU4V95 19lPlEOTJWEcVYhnrJX8FNza8vuAQjjLZXpw2SBKW4Kh8DxwWRBydXtkLiYLvcOQ0z+m VKUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rhOEcSBz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f3-20020a05640214c300b0052e8d878e95si3449739edx.476.2023.09.15.07.26.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 07:26:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=rhOEcSBz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A3002387444B for ; Fri, 15 Sep 2023 14:24:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3002387444B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694787877; bh=KwBm4HKocIRXeEAj/DFpsY5c9Yjf/GTsmpgjVbKnshc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=rhOEcSBz1WU2rvyBxV35OKVcsHMmo4aEr0WcKsGM+rH7hRm02yv4opAoZo+72nq1G 5lL2ST0h8AjBz2tJmLvIQBoPN4wXLQmgzvEEHWRceZTwax0l9iVPKsK1Mf1+2DCD6l K2IeElVNGeV9NPAVNwJaMzE8a9UD7VJSg7ZtZqyM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 437C63858C2B for ; Fri, 15 Sep 2023 14:21:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 437C63858C2B Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-403004a96eeso23826065e9.3 for ; Fri, 15 Sep 2023 07:21:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694787659; x=1695392459; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KwBm4HKocIRXeEAj/DFpsY5c9Yjf/GTsmpgjVbKnshc=; b=L7mXg9K3a7RHwANZbFot6s2nXdzdTbIcTVjluLxKOt3n5hsMw7b2JY/1+BHwnhSK/S ca8ZB/7dvR3ws8lQCpVV/RDKTHmYMb2C/yS7i+BrgiFe5AXQopscQFuT4g6womPdYpHo Q6D2XibnJOSYu+IBU3yWuI+vgR2L3gzsCb6YtwXNws4B7U6TvIq/SGSpHVkZfpF9+tM9 779KtQFsFdzAiohz0MmfQGI4qS2aejOSNXJG398GMz1ZoYbcd0o0MAOBkz7RDfAM3ngn ktJl2r3LJ7fhdSZIrjN8EDgm3uP9p5ZBjdpPcdu2ZXtcrnqkUEfa9xNwQKp35HWTr9IC nmUg== X-Gm-Message-State: AOJu0YzVeOC8tuBcbfp5p2dRn1+4ExP7NWx/HtjQAsfXBk/WgIYmdcBp fwmNfOy7iDMFlqe1Ep0Y9jMCkb+0g6NWI5GoKdltbg== X-Received: by 2002:a05:600c:2614:b0:402:f517:9c07 with SMTP id h20-20020a05600c261400b00402f5179c07mr1694293wma.0.1694787659550; Fri, 15 Sep 2023 07:20:59 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:a63c:a2c3:ab34:f429]) by smtp.gmail.com with ESMTPSA id k11-20020a7bc40b000000b003fefca26c72sm4786848wmi.23.2023.09.15.07.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 07:20:59 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix internal error on misaligned component with variable nominal size Date: Fri, 15 Sep 2023 16:20:58 +0200 Message-Id: <20230915142058.2100998-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777114010841714549 X-GMAIL-MSGID: 1777114010841714549 From: Eric Botcazou The back-end cannot handle this kind of components even when they are small. gcc/ada/ * exp_util.adb (Component_May_Be_Bit_Aligned): Do not return false for a small component of a record type with a variant part. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_util.adb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index b2542d4ae59..2e6a1cf892e 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -4989,12 +4989,15 @@ package body Exp_Util is return False; -- If we know that we have a small (at most the maximum integer size) - -- record or bit-packed array, then everything is fine, since the back - -- end can handle these cases correctly, except if a slice is involved. + -- bit-packed array or record without variant part, then everything is + -- fine, since the back end can handle these cases correctly, except if + -- a slice is involved. elsif Known_Esize (Comp) and then Esize (Comp) <= System_Max_Integer_Size - and then (Is_Record_Type (UT) or else Is_Bit_Packed_Array (UT)) + and then (Is_Bit_Packed_Array (UT) + or else (Is_Record_Type (UT) + and then not Has_Variant_Part (UT))) and then not For_Slice then return False;