From patchwork Thu Sep 11 09:18:42 2025 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: 120032 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 73EEC3858418 for ; Thu, 11 Sep 2025 09:27:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 8F86C3858D35 for ; Thu, 11 Sep 2025 09:19:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8F86C3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 8F86C3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::329 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582364; cv=none; b=QGvKaBjk2+/RyRdBWPdlX/mXV77RA9tO28ZurjONF0lQuLsokl8RbaYOKWgKJyT9LYVYTAoyDBjSu2k52CC+vV7YkGk0EHO6pAPlpvFTHvSllmvWRZE7DZzEBt59tDgkDjjl4B0xkcRDTJyRBGoM+ZQtmAqHf1yNdA9z3NhJbCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582364; c=relaxed/simple; bh=oYAe3gcAh7Ky3LQ3+uEdHPUkf6nh6kBR4kyNSg5hV7c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=AZvusJqFmJCoZwQKYni6qL3K7kjENZv+ZxuIb6bEzmE4Zn9lS3XqlKGav2oemFP0QOweFoC1VFpCfj6Ou5MctCEyODPk4FnbdEosnN9R+VdFaXX27ydTssRTN3VkIQrL29vXZscFRfKUsCM2B7Hf7mJW6hcY2if6CPKWnge9ie4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F86C3858D35 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Xy3+Xepe Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-45de60d39b7so3612865e9.0 for ; Thu, 11 Sep 2025 02:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582363; x=1758187163; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DDYyuqWNMxvm+CO5noWtiH532oVf0oOjHftW4MB732g=; b=Xy3+XepeWQEeuM9u6HOLinnF3MstXodRGHkT4/S8jZeravFNKqdDW+Hgj4jyCjsCjU 7yLEW40UV770M3PewfKC4Z/ArWCOW7so5PwCyEOiPaeR8mfxaEvVnuICQCQ4SQ/5h/Xa Lq3gWRkCRGkgpL6EaCJNmLlLRyy6uUJz6Nmn/LDCeqoC4D98XYJvWKepjrjoQMCxYJkI /dwVMdKlzeCqqXhkLIuewz/FPDKRBG6GPlJjBok4JjtGbj/9YcvOHmisW7962583EjBE DDVk3l10vQLLXh+x35ZvYqxLruH6vaqokaTS9aGUdKUqzHYAYs6Reekem7JJ6SQ0QFS6 YzCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582363; x=1758187163; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DDYyuqWNMxvm+CO5noWtiH532oV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1fl6LjsfC405+ZVWzA/5JFUZZ0od8jFOeu6cQLEdpMqn3OXfHpEbqcAY113fgXNQ== X-Received: by 2002:a05:600c:1907:b0:45d:f7e4:8969 with SMTP id 5b1f17b1804b1-45df7e489eamr57068495e9.4.1757582363268; Thu, 11 Sep 2025 02:19:23 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:22 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED 10/31] ada: Crash on null aggregate of multidimensional type Date: Thu, 11 Sep 2025 11:18:42 +0200 Message-ID: <20250911091904.1505690-10-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.8 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: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Javier Miranda A compiler built with assertions enabled crashes processing a null aggregate of multidimensional type. gcc/ada/ChangeLog: * sem_aggr.adb (Report_Null_Array_Constraint_Error): Adjust code for reporting the error on enumeration types. (Resolve_Null_Array_Aggregate): On multidimiensional arrays, avoid reporting the same error several times. Flag the node as raising constraint error when the bounds are known and some of them is known to raise constraint error. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index bbd0eaefb98e..baca06800abe 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -1139,7 +1139,8 @@ package body Sem_Aggr is if Is_Modular_Integer_Type (Index_Typ) then Error_Msg_N ("null array aggregate indexed by a modular type<<", N); - else + + elsif Is_Enumeration_Type (Index_Typ) then Error_Msg_N ("null array aggregate indexed by an enumeration type<<", N); end if; @@ -5463,8 +5464,13 @@ package body Sem_Aggr is Hi := New_Copy_Tree (Lo); - Report_Null_Array_Constraint_Error (N, Index_Typ); - Set_Raises_Constraint_Error (N); + -- On multidimiensional arrays, avoid reporting the same error + -- several times. + + if not Raises_Constraint_Error (N) then + Report_Null_Array_Constraint_Error (N, Index_Typ); + Set_Raises_Constraint_Error (N); + end if; else -- The upper bound is the predecessor of the lower bound @@ -5478,6 +5484,15 @@ package body Sem_Aggr is Append (Make_Range (Loc, New_Copy_Tree (Lo), Hi), Constr); Analyze_And_Resolve (Last (Constr), Etype (Index)); + if Known_Bounds + and then + (Nkind (High_Bound (Last (Constr))) = N_Raise_Constraint_Error + or else + Nkind (Low_Bound (Last (Constr))) = N_Raise_Constraint_Error) + then + Set_Raises_Constraint_Error (N); + end if; + Next_Index (Index); end loop;