From patchwork Fri May 26 07:36:53 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: 70140 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 5A98A38114F0 for ; Fri, 26 May 2023 07:43:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A98A38114F0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685086985; bh=KGHoP0eoRIBk25RmGKrxWkaLDid9uwVUEy43Wz7hgBw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=OSqR1HfSVykGZJWdKhzv/a51uZ+ob7I7aFLdSoYDDKP3zGz1m/rPN1M6UtOCnPNzx TX5quwbo7g7x4k8VwaSUdMN0olJKBwmmr/f+WZJxvigwdA6bzJCihf1c/NRfe1KIaC EMsUDCIlCHi9VuavSIxAcU4/GnwhPLzELkLb3DoE= 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 EBC383857357 for ; Fri, 26 May 2023 07:36:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EBC383857357 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f6094cb2ebso2736845e9.3 for ; Fri, 26 May 2023 00:36:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685086615; x=1687678615; 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=KGHoP0eoRIBk25RmGKrxWkaLDid9uwVUEy43Wz7hgBw=; b=ffiiNZJZRrX9+6aBEHrhj9Yp+8oNVUOxLfFZZQcIwNJg+uAclvulhs6Lqfv3yvX8Zb Jb9/hF9fFP2AqA4RbToQr2vf27VqdxwA+MuKzPcu5Ut8JmFiFOPDUr9eu3AZ2hfexwHA +iq1T4cYWj7xJh96bgc66tJI/dU9gjJQ1pi3Mn8EfZUdYm1BXNbt6crBPRLE+DyQfjeT I9nlAZZzwQhSbFxXnJhl3jPXS06ZH++4Ufhq8boaUWPrW9lykWm7wQSGzAWGQRgKnB5X Q1YNDn+L53vSUpkotDcik3gw90HIoFi75Fo02rMx5MZf4sZZemXrMa/SVkEmLmmscxKo bjjw== X-Gm-Message-State: AC+VfDxzUcolgwaysktewVkaUqBdjnR8v6V9xnY2pfEhwfRYUs8OaYIv kuB1zWal3yYl9iwKBk2H6zXMeA5J5+ZOc48PsY3jGg== X-Google-Smtp-Source: ACHHUZ6X08PNX8C/cJWcuTNvEK5pH5iPbzDgAqScs20oG47mQsQW6t8Sp5h6+L1ZGzH/nuLDoXYe5A== X-Received: by 2002:a05:600c:228c:b0:3f5:39:240c with SMTP id 12-20020a05600c228c00b003f50039240cmr772852wmf.27.1685086614906; Fri, 26 May 2023 00:36:54 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:777b:eef4:6f79:f26f]) by smtp.gmail.com with ESMTPSA id o10-20020a1c750a000000b003f4248dcfcbsm7962767wmc.30.2023.05.26.00.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:36:54 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [COMMITTED] ada: Default initialize entity to avoid CodePeer message Date: Fri, 26 May 2023 09:36:53 +0200 Message-Id: <20230526073653.2069851-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.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.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: Yannick Moy CodePeer issues a false alarm when reading local entity Component later if not initialized by default. Fix this. gcc/ada/ * sem_aggr.adb (Resolve_Record_Aggregate): Add dummy initialization and assertion that clarifies when we reassigned to a useful value. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_aggr.adb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index 858ae635fc2..fd0779e66d7 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -6004,6 +6004,7 @@ package body Sem_Aggr is end if; while Present (Selectr) loop + Component := Empty; New_Assoc := First (New_Assoc_List); while Present (New_Assoc) loop Component := First (Choices (New_Assoc)); @@ -6019,6 +6020,11 @@ package body Sem_Aggr is Next (New_Assoc); end loop; + -- If we found an association, then this is a legal component + -- of the type in question. + + pragma Assert (if Present (New_Assoc) then Present (Component)); + -- If no association, this is not a legal component of the type -- in question, unless its association is provided with a box.