From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AGHT+IE5lQLxdGj1axL1jF9w1ea8o5FImpb4r1cWXFA5vHZNK8EjeuR5bpn3N01OCHFwtfA2u2quvA== 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=20Poulhi=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 Content-Transfer-Encoding: 8bit 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 List-Id: 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)); -- 2.43.0