From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 09936386075A for ; Tue, 19 Dec 2023 14:31:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 09936386075A 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 09936386075A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996263; cv=none; b=RpDTjTMoU+2GltKgV7O7ecKQFsYhg2Fgfc/da1KUpmqzBByBwJeCyXFgOFw7GsF1EMHi0at8HQY2wxjwxVcfyazSSCFDqiy5Zmx0RWm7aV9xDbUjsNrKJnWt+rtv6RsPCKqAosIBoyhxCCZAXXGROVMv6A3GNOPCuEmjx5D+VQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702996263; c=relaxed/simple; bh=e8UcUpU6KYCWfzqqBdrSGVOpk95BOHHWkTVxjkq6HQE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=nBmkwMrYyMQnqM4Cwhsj/NCxcfji18/j2ghVhly3S/s2ud73RyCwGQUh4g6krx2jMVk/knbmWlUsBRwjXVks7wZmmKA+EqLxGY0xRJsg5Gxc/+ME6MWmDcO9crPoOOq+FH90++9X4Pwgqob8+Ph/zQF1i1kYL15LT1tEff6/v9I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33670b90013so537980f8f.1 for ; Tue, 19 Dec 2023 06:31:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1702996261; x=1703601061; 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=OB03IFzgJ7PDJs7g8h+o0thgzEokORvVzZyZ9PMNsus=; b=JebKv/8QFnyaqCZQwAYuD0QejXMlpN0wObkx0pyCOusMuaPCqZg11XGBkEXt3b5wTw lgG7ud0CsHP4zx0mhR3bU6YvoVQE5ma/rHd8qEyy07zXQ578IBZj356j0X5DMswOw5mi 5Hm4qfENZABd7+gtIyG6Po/8/jSSQFKaKqr+/H7sT/Ld9WORFr7HdfLkm9460P9CUBMG O7jax6SHhK+MPOSLA/EcLdv0Dm4c8ku3TTHwAnkSR3rb8CWR6PnUQ8fVZQYGESZa/Xh7 ZmUm0KsVoF0wh53sHFnpyHzKZr2/hVCJOWuTxWWooCrLh2dMYfUWkcRI+J/H5fH+XOi/ Q5XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702996261; x=1703601061; 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=OB03IFzgJ7PDJs7g8h+o0thgzEokORvVzZyZ9PMNsus=; b=lqD1UDNiFUYRXGxTRtHrvYPKsossKjMD2kJmx5p83lQJPZDi0C9md127NkGnLHYVsP CFUW1LDkOI004fKfYM1Q2VZOSOVCbkJzyVP3dKNOqDQscWvkzHXyS+LYv6gXaGGz2BGp T2XffoC+W6hO9b3YjysS60r/XNrJIA3zgF8SUpwoQT8vL9a0lZS0coNtW08ot0URJ1/Y PKUL/0O1AyPIInCRL/Mr/bVQ9ujsL8QiP5PznCif1vbLVZCadjeuLhCp6dr8+Llts6Ni OvRGMV9kONJPY70JzjehwOuudDcA232z+7TL1Tfhx1BiD6Ae19AjI38cgUY4QcBmNUqq zp8g== X-Gm-Message-State: AOJu0YxSGUmKqLUJFP9NUaD6wF4cJipPotC1ZZiVhIWM1HulotN2N18L b3F2voGO0XMiByP0Y2fEaqbiiLkUHL5QQyMJZJA= X-Google-Smtp-Source: AGHT+IHMrCmfe5Ll0/pf4X1rNmitaPDyy1ZhKfm7EIrMYW4d6Uv0AVO98WTl9Du8T3JOGXpAhnYkNg== X-Received: by 2002:a5d:6e53:0:b0:336:5f0f:323 with SMTP id j19-20020a5d6e53000000b003365f0f0323mr713143wrz.69.1702996260837; Tue, 19 Dec 2023 06:31:00 -0800 (PST) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:fe1e:443:c34f:edaa]) by smtp.gmail.com with ESMTPSA id c9-20020a056000104900b0033667867a66sm5971185wrx.101.2023.12.19.06.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 06:31:00 -0800 (PST) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes Subject: [COMMITTED] ada: Compiler hangs on container aggregate with function call as key expression Date: Tue, 19 Dec 2023 15:30:59 +0100 Message-ID: <20231219143059.455817-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 hangs (or may crash, if assertions are enabled) when compiling an iterated association of a container aggregate that has a key expression given by a function call. The resolution of the call leads to a blowup in Build_Call_Marker, because the temporary copy of the expression that's analyzed has an Empty parent, causing insertion of the call marker to fail. The fix for this is to preanalyze, rather than analyze, the copy of the key expression (Build_Call_Marker will return without creating a call marker in the case of preanalysis). gcc/ada/ * sem_aggr.adb (Resolve_Iterated_Association): Call Preanalyze_And_Resolve instead of Analyze_And_Resolve on a key expression of an iterated association. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index a61326c9ae2..bf249620d04 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -3270,13 +3270,13 @@ package body Sem_Aggr is (Iterator_Specification (Comp))); end if; - -- Key expression must have the type of the key. We analyze + -- Key expression must have the type of the key. We preanalyze -- a copy of the original expression, because it will be -- reanalyzed and copied as needed during expansion of the -- corresponding loop. Key_Expr := Key_Expression (Comp); - Analyze_And_Resolve (New_Copy_Tree (Key_Expr), Key_Type); + Preanalyze_And_Resolve (New_Copy_Tree (Key_Expr), Key_Type); End_Scope; Typ := Key_Type; -- 2.43.0