From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 74BFA385770A for ; Tue, 5 Sep 2023 11:08:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 74BFA385770A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2b962535808so36819201fa.0 for ; Tue, 05 Sep 2023 04:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1693912104; x=1694516904; 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=dZRmQkN6kLdzLEYtG67PBXQj+DaYbg+gYJSZwLChW2E=; b=IsZuhhM0YdjUnZbhZ8L9gLJH6e169ib/68wzMBA7kFKV4s6VlxWeMj0ZyPEW5xBqTh autD8Dm7wgUrKocxFqTUgd0TBw95frAORhiXQaWIv2IJbmjnRpUC0mfE+bsf+BDIbUgb KnPNUfPJkvp69fuPEoRjUrKpmPenH2Q0kCMiec6IZJSGqYQP49lcdYvCnzZdfG1gIimx jBqHrffxkFK01swUu70f00BveXoJY0B0G91HLPEnNMiJyMdPWWP2D6pdPmKdcobFkcun 6137ZMIAwpvRP5Iib+Ri4wJZT2RrkydkTMQ0EzRQGYltBN0wmhkzSFf2WIC1LV00fQ1d tu0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693912104; x=1694516904; 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=dZRmQkN6kLdzLEYtG67PBXQj+DaYbg+gYJSZwLChW2E=; b=Pi9AMzs14IonTLrP458Vu+Cx/KD3cdxzdDNpHpphN1MD5ghehSlam6ydCSrePLWgJy Jd+OFf3HMUSSG6RAmjnQ5T6u1rCo8cjPTd6xi0fwCE6cIQNm6Do99CtqWj1/wP9juUB6 GVxwYqDe8cxkuL4a2SBJFN0jM3V9QEtxC5GqWLD2PFCRKHoy5YwygJx7UzN2eHh9MYP9 DQXduBG6no0IyDx4ZKy6EAUNwTZCH8Kr2J7wUzcFJ/hQeBLsbfMIpIU3PTapUuUEl9KR cEgt45+o3nwaHj3S3CVf/Qb+6kwo70lMnmJQLIuzj7pNAlRuh3mBMmIfR9MmmuRLHR+l sCUw== X-Gm-Message-State: AOJu0YzVKKtVMVyKo32VHTejyf4xs/YkoBR/g3b8HAGIOrrNadx2J5NZ IboKi2eXKbg3i5oGsxbcL+YOY4YKpLITMjjfKpT+Gg== X-Google-Smtp-Source: AGHT+IGAOotc85xxYGpS6u2HyQV1+qiHFJK26YnGDyyVTEmUJBoZhw2WKRHRZLlmAe0HJCRkEcp5+g== X-Received: by 2002:a2e:9595:0:b0:2bd:ddf:8aa9 with SMTP id w21-20020a2e9595000000b002bd0ddf8aa9mr8490051ljh.24.1693912104013; Tue, 05 Sep 2023 04:08:24 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:20fc:79e4:455c:1075]) by smtp.gmail.com with ESMTPSA id m13-20020a7bce0d000000b003fed630f560sm16695678wmc.36.2023.09.05.04.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 04:08:23 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix assertion failure on very peculiar enumeration type Date: Tue, 5 Sep 2023 13:08:22 +0200 Message-Id: <20230905110822.563115-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 List-Id: From: Eric Botcazou The compiler currently does not support the combination of a representation clause on an enumeration type with a size clause whose value is greater than the size of the largest machine scalar supported by the target. Given that such a type would have little practical value, this change causes the compiler to give a proper error message instead of aborting. gcc/ada/ * freeze.adb (Freeze_Enumeration_Type): Give an error on a type with both representation clause and too large size. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/freeze.adb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 38aeb2456ff..0fc33a420c2 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -8023,6 +8023,20 @@ package body Freeze is Adjust_Esize_For_Alignment (Typ); end if; + + -- Reject a very large size on a type with a non-standard representation + -- because Expand_Freeze_Enumeration_Type cannot deal with it. + + if Has_Non_Standard_Rep (Typ) + and then Known_Esize (Typ) + and then Esize (Typ) > System_Max_Integer_Size + then + Error_Msg_N + ("enumeration type with representation clause too large", Typ); + Error_Msg_Uint_1 := UI_From_Int (System_Max_Integer_Size); + Error_Msg_N + ("\the size of such a type cannot exceed ^ bits", Typ); + end if; end Freeze_Enumeration_Type; ----------------------- -- 2.40.0