From patchwork Tue Nov 7 09:20:45 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: 162342 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp112618vqo; Tue, 7 Nov 2023 01:23:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IF77jtGE5sM5tbM728p+1G2mIJ63c9G+micV/nK4gCdha7wbByx0EHoAapG9hQMGhJdT592 X-Received: by 2002:ac8:7d0d:0:b0:41c:d8b6:27ef with SMTP id g13-20020ac87d0d000000b0041cd8b627efmr36448489qtb.65.1699349034262; Tue, 07 Nov 2023 01:23:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699349034; cv=pass; d=google.com; s=arc-20160816; b=0FcQufaOA6AGerQkpYcL0NRBJYCdK0yBX2hovNU1bs3EUX6zrzAfozmzkTkR9rMcMh mH8nO815kL7QbTRjaZvOqe2LxxShJc41g8sLmaw2Oefg6m4oOCrCzLRoFgDcQ/8XNxSd RmLqYI8lHt29QgVUG3vzOnmS+rjXWyNVdPVmoRDaNRViEpetUxChrcZE+1MYlCs7PW39 X7TCb7fgs6GhxLRtE9C0S6OLKk5C9AVO7zWGZITe0YEViU6qNpcRAiLZleygcelbMOgd 0wnu0Mhv5ZJQgVhXv6lwgRDIgR5Iz2t8zDSKbIZo0sTpRceYA6FT8muKAHsDdc5ldNjw VOJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=3BgeBPNEbIn5tHzBLd0uiYrtP/kHtxvc8K4wgmt/kIQ=; fh=SwZJ83OSkcrddnVqQxMJIeT7CBiRDh1+Xn8c83Fto+4=; b=YjWVrJSEHU6NYk0gCc8nV911tp5CY9c094UKkiy2S+FfJrjINOFTM2m1urLHVChlaQ aykrf3+GZQA+mmU7fwi6qxfs5dQM3s9BCNUHcGuEflKb2v4y+yM/HiU2j9LY9m3Naj+w n/XEcCSiVfEa4tsPFq1o8vrkf0PBM8WszLhMVOpHAlQ4rROtfioBkwIVmvQdrXihoBQO bId8yxX8OCkSMNJPC2RiqaPD8VUwH4AelFttIJPaBcxK4VTpYf+m8qHZJ5Ro6pu7OQLU 891nCTIEMfXFh9WbwDnHwkirVqAlc5vOdLJbHmgPzVAB3c9zSlRgQLq8H03oSz//VcaI jXYg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=GeCN1ZL9; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id t21-20020a05622a181500b00419986f0f8csi6794600qtc.633.2023.11.07.01.23.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:23:54 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=GeCN1ZL9; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DEB2238618B5 for ; Tue, 7 Nov 2023 09:22:50 +0000 (GMT) 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 AAA373871037 for ; Tue, 7 Nov 2023 09:20:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AAA373871037 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AAA373871037 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699348850; cv=none; b=RxC+gcPhpY3vV+RTR62dZ8ScjVIWSyxSd+7aJ0GRbj3HPA/OFvhIheWir906MiAXQqmdC9y79ajsB0hujbozlclFh93MbB6hSocbvUHWVUo0Qzk1PwJYXTSGH8DsGHAa5TWJ7+9Coh3daYcBdKfXg7/KQcQEFZ3bhrvFX4yjqeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699348850; c=relaxed/simple; bh=KkgRjK8ZEtPUZU4JV+WQXlKEir0FB7v/FzS2iXYTI0Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MkAScYrgMRvDLGyz0kBsSKNu2spP2RjNmlOEFGuKRsSAplP699cGoi8VmOdvsflB+W17+p35aTS4YG1QPmOvcvHJR8E1dUVv82IuTegXBzmUXc9pz8czy0cgIslG79dPvKZmjeD2FBCd5IyGHubUUEPmmt2F+mIDShx7CpVbolo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40839652b97so40514605e9.3 for ; Tue, 07 Nov 2023 01:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1699348847; x=1699953647; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3BgeBPNEbIn5tHzBLd0uiYrtP/kHtxvc8K4wgmt/kIQ=; b=GeCN1ZL9wzzIaxjgj+e9uRooldL06dl2KeoJZ9pZ3dDRKslPtZ11aHjPscUPE8agpP ec7cIpPIQvwW1Fx3/fUHlheBmJoKx+uPxND7PE5Dw20uqC8bBgJBRXKdA1uPmczus13P TFDKlE3xqYGHV3E3HXZUAA9sWT9WAJFkIyine9tvDZ99vvnpAPKcSK6d2q32z8T1hQaM 4NLIzPGY1Fo3227pyHywCXlekrhVxgkOZ7yuVw3WiBncUPVDsw1Pm2nuEpSQSEhYKfMA JCeAxSymPbqh9E5HHe8EtVosJvwrut5IEGVaKIr+O3ADyYF59rFsQH1xqZYxyZrvT38P JYdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699348847; x=1699953647; 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=3BgeBPNEbIn5tHzBLd0uiYrtP/kHtxvc8K4wgmt/kIQ=; b=UKMmPlIGROW3EFJH/qcVUij41FQCpaVmmS5pid4z4dVqAvJf33hXYK9Y8ok8AiWXXH iNAuViP+Fmz5tZWa+TNVZk+2u4bgN85kDeaTjsfvUkAXrGfpxZly2W1t/S7Gvp8FTJHc qxpgsvgreHlX2A2Uh+Pl9jgqM0Z5tLxKaz2Pp7lULlB1VTnPHlB/i1WFPem0kBlg+VOC 4U86I5P2vMI+lnr6n80/FsRJeiToqRlZKI995ebencCrsgu0TKTs9HQm63v6bhlCCEKI iDI/zKlLCM1mzNhYl2GCVXP4pIIZlWTDVg6S4Ck/CtKbjf4DwxLJgSk22eM4dRuxCoD+ rPrw== X-Gm-Message-State: AOJu0YxzUnWE+A4Arug0rPpH72K1VtrUr3q0k3Q/VmBPa7hIpCTG/qfT SdYtWYzTfxKVsSjCsnSvnd9tmX0z9ZOaSDCcFJ6NNQ== X-Received: by 2002:a05:600c:198b:b0:3fe:f667:4e4c with SMTP id t11-20020a05600c198b00b003fef6674e4cmr1790254wmq.12.1699348847396; Tue, 07 Nov 2023 01:20:47 -0800 (PST) Received: from localhost.localdomain ([2001:861:3382:1a90:dbc1:a1d1:2e58:4040]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003fee8793911sm15266473wmq.44.2023.11.07.01.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:20:47 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [COMMITTED] ada: Compiler crash on early alignment clause Date: Tue, 7 Nov 2023 10:20:45 +0100 Message-ID: <20231107092045.3906982-1-poulhies@adacore.com> X-Mailer: git-send-email 2.42.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, T_SCC_BODY_TEXT_LINE 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: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781896613098927868 X-GMAIL-MSGID: 1781896613098927868 From: Bob Duff This patch fixes a bug: if "for T'Alignment use..." is followed by "for T use ();" the compiler crashes. A workaround is to move the alignment clause after the enumeration rep clause. gcc/ada/ * sem_ch13.ads (Set_Enum_Esize): Do not set alignment. * sem_ch13.adb (Set_Enum_Esize): Do not set alignment. Archaeology seems to show that this line of code dates from when "Alignment = 0" meant "the Alignment is not known at compile time" and "the Alignment is not yet known at compile time" as well as "the Alignment is zero". In any case, it seems to be unnecessary, and in this case harmful, because gigi would crash. Alignment_Clause is set (because there is one), so gigi would query the Alignment, but Alignment was destroyed. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 2 -- gcc/ada/sem_ch13.ads | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 5747ee9c539..302fab74757 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -17381,8 +17381,6 @@ package body Sem_Ch13 is Sz : Unat; begin - Reinit_Alignment (T); - -- Find the minimum standard size (8,16,32,64,128) that fits Lo := Enumeration_Rep (Entity (Type_Low_Bound (T))); diff --git a/gcc/ada/sem_ch13.ads b/gcc/ada/sem_ch13.ads index 1386096535e..555d302fb10 100644 --- a/gcc/ada/sem_ch13.ads +++ b/gcc/ada/sem_ch13.ads @@ -79,8 +79,7 @@ package Sem_Ch13 is procedure Set_Enum_Esize (T : Entity_Id); -- This routine sets the Esize field for an enumeration type T, based -- on the current representation information available for T. Note that - -- the setting of the RM_Size field is not affected. This routine also - -- initializes the alignment field to zero. + -- the setting of the RM_Size field is not affected. Unknown_Minimum_Size : constant Nonzero_Int := -1;