From patchwork Tue Dec 19 14:31:04 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: 181020 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1982450dyi; Tue, 19 Dec 2023 06:38:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpljxGEx61GQ1lUSKPPbieoEjoyF56dNN3A8JXtkC3zvYg+TvSXupF1iDd+6rccllaCns6 X-Received: by 2002:a05:6214:1d2c:b0:67f:47fd:79f6 with SMTP id f12-20020a0562141d2c00b0067f47fd79f6mr4457158qvd.95.1702996720418; Tue, 19 Dec 2023 06:38:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702996720; cv=pass; d=google.com; s=arc-20160816; b=sz8gVJ1HZYLk14ATPx8Gl9+7srLGg/5YtsWxCe2CEgTe0eTF4u3eUJs05qurl1irPV P8YoKdeceLti276dzhww9aSkF4p5CpGWw64045oX8MqWadjfEZSk9IX1GdidLuPSOwWU NwG0O/GQEoN4p2FxK62xQOklzpQ+NqfJxc+vNdrZA3tfRSRAdXMkeO/pEhTBV9gW4BLe NWbERt0cQniqmg5ZUIYeWi7CnrX7xwuvQ4GsU3IuhU2Lrgh/OIMGq0b8FOCCAEf++Z3y Z7xeA8rVspGEJr+i9uhqlR8kBmtt8ya1JD4MqGuBRL9AFgY7GlPLSZ1frDhHeuxMxbIr yKVw== 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=ccS6ECBRLsQaevwi0BwFxCFTybgGj8pup3PklyObswU=; fh=2OQ2D33Mj5i184RAM+HipkBHQbq3Jto2o2pTnCBu17E=; b=TMHPA7fxzsyTxYo07GxlNsxUS6XDISYeWDbJ7w4Kk5H0OJtUJPfdM29fDdPJ4nhXgG gm/rKWCsGfkScyproYq0FwK1DVY9mbQqFF1qxg9QOUTMCOWDsloC9z+GjLgy9CZvaXlY yS7Xboyi0Rf3YzGmwhkcCFxgd2RStDiHevGB43+tIvvE0auZmxQOb2b21oL8W6XfxEKF KyfJ5C2EiCHm6Hey4oOBx3UxtKZqMu9tVaelwRI9O2iMy6t+Q1VzQ6IgixeU6HgbaYiN T2GUVueHTbImlgSkp5yzQ4GN3pBsGlyvY7jOEB44DN+3L8r35UrTSGM9is0SySrbcsE+ 7nhQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=QJLvSiPX; arc=pass (i=1); 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=adacore.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u10-20020a0cf1ca000000b0067f40e1dbc7si5020902qvl.591.2023.12.19.06.38.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:38:40 -0800 (PST) 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=@adacore.com header.s=google header.b=QJLvSiPX; arc=pass (i=1); 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=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 511AD386C592 for ; Tue, 19 Dec 2023 14:38:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 23C74386F436 for ; Tue, 19 Dec 2023 14:31:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23C74386F436 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 23C74386F436 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996268; cv=none; b=iOjU2j8Qf9cx35nQmxApdwvC/5B52CRvEN6JKvfO/7t1pUDvOaZtYc0iyZey80+O9hgxf9e0SaHTOfg+0fyZkTAk6K1p+PZ/ClUSBc6+/W3hSf6enXRTwH0QMoI8ZWL7v3sgueEKS9ht73vNxm+P2Q6Lpz0eS0V5oiq4xPTWbq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996268; c=relaxed/simple; bh=dh9R/ZB78zHYDyx/8sAKXiordJN/csAzzmZ1S/iZDZQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gxHB+xA4dgr6NNgEFlSYSAgxt5pdHvw7qMZhPLs6e9W9zoAcdcBHFxeh9SS1xfed6KpeYNR4IZtOoZ/bJ8PbrrMc4vKfAC5Kig3fNax3I6bRngDcXLrciT47/xoYJTkLluAO3inY4nw4idvzwnTk2KKzGTN67l32pfxrdj+WIKU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40c29f7b068so51108095e9.0 for ; Tue, 19 Dec 2023 06:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1702996266; x=1703601066; 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=ccS6ECBRLsQaevwi0BwFxCFTybgGj8pup3PklyObswU=; b=QJLvSiPX8D9aZ4QNSfMoOKxnMel0Qw7E3C0ZDYC6ts7znDTHO2fNpHgon1+2ZXE2Ka 0KenYzDXfsyDvxbxY28+sU2opE0GVB6q2+CZ0M79LSPDTs+2TYpkXu2ywDUB6nMBPK+q dDaJHDz9l1wvmybxdNXHxpROBOl4aqaaj57I285iVbpRFKjNYye2SX2pMqc3rBhYKVL4 cEx8LwFSZTIu1aLqR0uHaxmsAgtpZAW6lDX4xjKPXuYtfq8xHWqL2tT6GrQlCBXf5xWj wSSThZ/3IMhAk5lHpnPgZgp9rOnpLh/6ABfjW5GML6VVfRdqJ1epe9ULKeix4LMxb1qP SgWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702996266; x=1703601066; 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=ccS6ECBRLsQaevwi0BwFxCFTybgGj8pup3PklyObswU=; b=GkNoC7nDDXeTcWC2V4R1kLS8dBZ1c/4jZomwCzYc8gkhFBplGgO5TYf3ApSKJ84jC3 eCBzlxReUK9Ohii4fIM/ep9429TQfw44i3X5Wacea0md+QolFs6hFDg/I5JAEkUPmLSK nj8/nyAl5d5tzJCXUGRg7UTY23saEDfiJb+yIsk9rwTSb/cCCT1dqbWuHQJGyyfnlHpu y6fMzAku2IHSm6h6MEuo+jbvbAJvaaZZQ02Dj1mW1q7J2kbF/BIukokbgyHg3+8uBQeW gB3NBZpSRv+x+QOAhm/Igq0oLnBt93meGEjEMyGf/Y59VNAxzQyGCmYPsxGRbE+152j/ F8ng== X-Gm-Message-State: AOJu0YzmjbmC1EM1Tj6g/0gQap66zEpEgtQOjCbsmHVY3saGgKeOThiZ JJS5exMPjC+yf764hw2imBaTZtMg7fH/FjzGmvg= X-Received: by 2002:a05:600c:2e94:b0:40c:1c2b:e4ae with SMTP id p20-20020a05600c2e9400b0040c1c2be4aemr8508036wmn.105.1702996265945; Tue, 19 Dec 2023 06:31:05 -0800 (PST) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:fe1e:443:c34f:edaa]) by smtp.gmail.com with ESMTPSA id l9-20020a5d6749000000b00336759019a5sm1137375wrw.42.2023.12.19.06.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:31:05 -0800 (PST) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED] ada: Missing error on positional container aggregates for types with Add_Named Date: Tue, 19 Dec 2023 15:31:04 +0100 Message-ID: <20231219143104.456009-1-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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: 1785721489048633685 X-GMAIL-MSGID: 1785721489048633685 From: Gary Dismukes The compiler fails to reject a container aggregate written using positional notation when the container type specifies an Add_Named operation in its Aggregate aspect. Container aggregates for such types must be written using named associations. The compiler ignores the positional associations and produces an empty aggregate object. An error check is added to catch such illegal container aggregates. gcc/ada/ * sem_aggr.adb (Resolve_Container_Aggregate): In the Add_Named case, issue an error if the container aggregate is written as a positional aggregate, since such an aggregate must have named associations. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index bf249620d04..1027acf20b5 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -3436,11 +3436,25 @@ package body Sem_Aggr is Key_Type : constant Entity_Id := Etype (Next_Formal (Container)); Elmt_Type : constant Entity_Id := Etype (Next_Formal (Next_Formal (Container))); - Comp : Node_Id; - Choice : Node_Id; + + Comp_Assocs : constant List_Id := Component_Associations (N); + Comp : Node_Id; + Choice : Node_Id; begin - Comp := First (Component_Associations (N)); + -- In the Add_Named case, the aggregate must consist of named + -- associations (Add_Unnnamed is not allowed), so we issue an + -- error if there are positional associations. + + if not Present (Comp_Assocs) + and then Present (Expressions (N)) + then + Error_Msg_N ("container aggregate must be " + & "named, not positional", N); + return; + end if; + + Comp := First (Comp_Assocs); while Present (Comp) loop if Nkind (Comp) = N_Component_Association then Choice := First (Choices (Comp));