From patchwork Tue Nov 21 10:00: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: 80449 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 008E738618A6 for ; Tue, 21 Nov 2023 10:03:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id 1C3DD3858CDA for ; Tue, 21 Nov 2023 10:01:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C3DD3858CDA 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 1C3DD3858CDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::333 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700560869; cv=none; b=VAfQXSEhFnHHGWcCEkWPETwqjJ82VLcOhbNUvpXA8SHWIXYRPU5rq/qUbA/48VkZm+SOE0gTl6qdAQ8/3z7V9Qe7+286JSziikTVJ6irxEr5a8QR0ckct45mOdkR9u/dy08lkPiH3FyCBrng57gptjPk+zaw5A+O9lM+LPquYxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700560869; c=relaxed/simple; bh=yEDkJbCmtnD2CpVDawDj5uM6QS5jE8osPw8OXrVboTo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=j+wzBH6WR/N+18MLlEnFDTPKPRfe3O8LK4Qet7zKXSSD1NH/9azUj7wh7fv5qWHeRVKyQiq9ClwhwThSHQksLEduu42W0fYY2D+39MjPxpJU/mfMHXzVnx2UwX7Nzx25MgWTJJQB+755pd8KRkWL7la6MB0QImu8jYOK709F1rg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40891d38e3fso20732465e9.1 for ; Tue, 21 Nov 2023 02:01:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1700560860; x=1701165660; 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=FJTrOPtJp0O37Y1ZeIdJuH2rQlveXLh2T7XZET9UeVg=; b=JjFUNQEp/I7XgZXHw+zXfiUp1OwfGFJxfAaQ0QvFgDe7xFKfvimO04Oqb1Cr5VANWt C0yr/PmgNVhde2DQV48Yon7W2s/2222DmzwNZtt3+/JAYrdPocpneZ7AgHjElpqP7/ZA cvAiZepBQVz6CJ813N66RAW7pnDsH5Y2t3HsAZEGw5QAua/u8X7ZJJUOBr/AiBkcnvTI 4/DwB50drpZxkvtCmfzaTab3h6W070Urwzdvdp0bgsK61bWVftgZAuIRkii4drZpoLVt 6DIHY2fC9g5wtAOXLGqSaNk+nX5s5P7xRqb1hXhVioyXRLmRL5N27btMnfy41H2MGLPa kyOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700560860; x=1701165660; 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=FJTrOPtJp0O37Y1ZeIdJuH2rQlveXLh2T7XZET9UeVg=; b=YzHZvcZXtU38wblMakY/U1lJ5DYg8ymhE+wtlAr+9JouTXTXoeJ5zLcm2mBWAgk9WW sE3OPcylUGcUHYohlb7mEE+uoucdE34DH4/K080Tdid2uUkxbn5p5yZ6uv1HvuaQhyN/ SSfDkhBN/H87Syi5XDW4TOjqcRF2DhHpeBlhOht+WnudHMTeGKMgyYZ0gHdUlcdVln+Y R83w2IjpyZwHC0kpVbVP1CzA6NjzEFSNbLLB0v1BDgAzsJTJ+NFiwgQbN/+iHIN2qvew Uk8b/+v2NTgHhdHAC/hoA/+3uz8mug94cxcahI2tl1V4IT9YeSgJMXV4dyGye3dQZ1OI BrNw== X-Gm-Message-State: AOJu0Ywe9w5YyxCT5OgRfNHD8lVo90OiNPZJ9N6AjaRmClt1dKc7MNng Zn4q/aWp3LcCBu2pddsfyg7yyWwXDEHVevnhAP7DYg== X-Google-Smtp-Source: AGHT+IG1mEKCz8+FI7q5N828BhuTHkvVGO1F8KRc+4QZbtfSGOatb+c0ApZswpYye6Z5dY2IfY6muw== X-Received: by 2002:a05:600c:2246:b0:408:3975:e225 with SMTP id a6-20020a05600c224600b004083975e225mr8213509wmm.40.1700560859842; Tue, 21 Nov 2023 02:00:59 -0800 (PST) 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 k42-20020a05600c1caa00b003feae747ff2sm21362856wms.35.2023.11.21.02.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:00:59 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED] ada: Compiler crash on container aggregate with loop_parameter_specifications Date: Tue, 21 Nov 2023 11:00:58 +0100 Message-ID: <20231121100058.1965264-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+patchwork=sourceware.org@gcc.gnu.org From: Gary Dismukes The compiler crashes on a container aggregate with more than one iterated_element_association given by a loop_parameter_specification. In such a case, the tree contains N_Iterated_Component_Association nodes rather than N_Iterated_Element_Association nodes, and the code for handling those needs to obtain the bounds from the Discrete_Choices field of each N_Iterated_Component_Association rather than assuming that the association has a normal list of choices. gcc/ada/ * sem_aggr.adb (Resolve_Container_Aggregate): In the case where Comp is an N_Iterated_Component_Association, pick up Discrete_Choices rather than Choices. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index d3f9a773191..bc03a079f5a 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -3575,7 +3575,23 @@ package body Sem_Aggr is end if; end if; else - Choice := First (Choices (Comp)); + + -- If Nkind is N_Iterated_Component_Association, + -- this corresponds to an iterator_specification + -- with a loop_parameter_specification, and we + -- have to pick up Discrete_Choices. In this case + -- there will be just one "choice", which will + -- typically be a range. + + if Nkind (Comp) = N_Iterated_Component_Association + then + Choice := First (Discrete_Choices (Comp)); + + -- Case where there's a list of choices + + else + Choice := First (Choices (Comp)); + end if; while Present (Choice) loop Get_Index_Bounds (Choice, Lo, Hi);