From patchwork Thu May 25 08:06:22 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: 70044 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 8DBE33949096 for ; Thu, 25 May 2023 08:15:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DBE33949096 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685002537; bh=5HEl2nk2LDQFaMcyoI0fjC7ZNB20NmNgXjwUKblG3Ls=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=AF3EYQKIoZE6QIAewpJo7aoYa0466++1gnANgaZ7K8UJA9Bk2FLH8N49xuRDkccaw 2C2fOqBEsWwpiYQLjfnHE9R0ewsrn0jZjpMd7CtrxW+1WRIj5J76E2YkzG7kkDgxxz bdgbCJkEY3bGPeEHJCAsGaQ5GOfTCUa8RqOd1xx8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id C9B86385382B for ; Thu, 25 May 2023 08:06:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9B86385382B Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-30959c0dfd6so1722180f8f.3 for ; Thu, 25 May 2023 01:06:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685001983; x=1687593983; 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=5HEl2nk2LDQFaMcyoI0fjC7ZNB20NmNgXjwUKblG3Ls=; b=WH6bXl3pqntk0wNLJDuWViA2j0T2fuFNZ/HmahCBq/2LDBlptG4iLtpK4etJqyy1vh oFUu99GmOo6QZLYaGTPz4CacR0HH1klGkWEgc0B8voWMoykB635UepW2CUWpu2NomA9M dhAYuVzPjwndLm5SVuYsCrs7WDuagHd0NwRFr888UMhIST7aYN8IEmSeo0+GC1LFqFre IZsHGXVfIFp9PoMVVulp1rDtSOR9lrkLCM004tnqvwlOwKIjsajCLoMtZwSIwhsIlNY3 bE8ej+N+drmHAW1I3pmQd26kSSe+J8BTD17fa13eh6cJbuZQIsoZElkQIca99fSCed+0 yBHw== X-Gm-Message-State: AC+VfDyz4jig5EGAPkztZFs3uMXMyD9Cyyunzbmr777eTZ+e8xxj90Fy aqztueVZcAGhZZ6uFBtkFOJVz0eco/oJQ4Z2mpXMHA== X-Google-Smtp-Source: ACHHUZ5MUI/dg6Qaq6OwvM/U3u4WPCVRZiRmdI5zGsjUbH84VXuqMZDGh9na4xeBDgp+3CfpRH5FMQ== X-Received: by 2002:a05:6000:189:b0:306:27db:16c3 with SMTP id p9-20020a056000018900b0030627db16c3mr1674386wrx.50.1685001983565; Thu, 25 May 2023 01:06: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 17-20020a05600c231100b003f31d44f0cbsm4816978wmo.29.2023.05.25.01.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 01:06:23 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED] ada: Crash on empty aggregate using the Ada 2022 notation Date: Thu, 25 May 2023 10:06:22 +0200 Message-Id: <20230525080622.1957738-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Javier Miranda The compiler crashes processing an empty aggregate initializing a component of a discriminated record type using the Ada 2022 notation (that is, []). gcc/ada/ * exp_aggr.adb (Build_Record_Aggr_Code): Protect access to aggregate components when the aggregate is empty. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index f3ad8a9e1ae..de4d5a785fc 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -4061,7 +4061,9 @@ package body Exp_Aggr is Decl : Node_Id; begin - if Nkind (First (Choices (Assoc))) = N_Others_Choice + if Present (Assoc) + and then + Nkind (First (Choices (Assoc))) = N_Others_Choice then Decl := Build_Actual_Subtype_Of_Component