From patchwork Fri May 26 07:36:29 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: 99368 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp294823vqr; Fri, 26 May 2023 00:52:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FE67m6d9VdncFzwluCYb1ccOJjdJvJGPvhSvDOPvluvzDl2RNJ8IVhrrTyzQNweP9F1/X X-Received: by 2002:aa7:cd75:0:b0:504:b228:878d with SMTP id ca21-20020aa7cd75000000b00504b228878dmr602822edb.25.1685087565614; Fri, 26 May 2023 00:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685087565; cv=none; d=google.com; s=arc-20160816; b=OIDiZBwbiTBZLNLS1sMYQdhLJN/Bqsc++lSmjOCsncGE8QGBWew6i1kIKHiHVgiKsT KZ7kdmmOHhlbGgBBKIyo8DixNSIGh1OaAsVA3ajANMqnMi33FAK4bEEHJ3lnF+3cd259 Y9ADOzznTvmm5QNgI2xSSRy2w0f1ZZj0//XKZ1Zd+GsX8a4rdsVnnkP9+dTEWT1J039i nQ0/aN8cBkhs7krBF9j46NA0hUKlBd+tpB1BF+sm2zpyDaqqJljoCwBhUN5SDsHzc8lj OpXzGyAgvboA2dTMRIOhUkASs1Owf2wTJc/N7OT7bVx1kGjRHKOsyQieRfX+qwJ4/2qP qsMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=MTtcWZdAUIVS1ceuh+fCv1hcZvOKEEx3QCKEc6gibG0=; b=kun/Pnk2XzZYeoQjTYhIyDTt5kvh8F0wHf8ZoWn93zrd1HJCFH/xYB2OryBWHaA6wo jbezxL4AI0m9y6/vAGx9wwkvFludYx/EQVAQCaNMasJMra5hHLorZkToetpVxhiESUjd 4dkEU2T+7q6pNK9ZBzBNvALzqd0MHtcAen7L9rDvZpGYH65C4uO4/lFcjjbGMr/FpSrQ 5OXH7Pnnv+No0ZSaq8qm3svRso/H0/fPfMgxYryxE3zmhBXpOr3dtBvHfByPlO9SGgzZ rNRuSjIXR6cMKqojIkzV/SEf7QD0VY2kjhFdTwf8SJGprHKrBhKSFJtG97Ln6kHTTQGX 5fjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=A398esEf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id z12-20020aa7c64c000000b005067c959debsi1842819edr.603.2023.05.26.00.52.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:52:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=A398esEf; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 71D9239960DE for ; Fri, 26 May 2023 07:43:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71D9239960DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685087012; bh=MTtcWZdAUIVS1ceuh+fCv1hcZvOKEEx3QCKEc6gibG0=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=A398esEf8bbSfpI0r2aFjRgNr7nmd8XHEpgOWdDga83Bt/h0a2pbPlNyHBCWs3BG1 lIJvjTbpcge+srJ4vTBxDkB0TDtOkPdKyqJGs2IXzcnYH8DL6UMajHGwEBTIgqK4an 8B+lZ/tYycetXgKB2x0M12n5yKt59qNwFQMp9Sug= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id C83B3384645D for ; Fri, 26 May 2023 07:36:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C83B3384645D Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f603d4bc5bso4753645e9.3 for ; Fri, 26 May 2023 00:36:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685086590; x=1687678590; 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=MTtcWZdAUIVS1ceuh+fCv1hcZvOKEEx3QCKEc6gibG0=; b=beQ1zS37hSACUgvy4427NkWQfLwjPU5var3LZAcvgGO0RQzg1VkK5vXtIG0z7EmZti XVc3IY6RV5BJgrI/FjkzUtfleCuCYcHVqVrm/c61K/myNfoG9gNEZF8BCu2CICB1cML2 Sa4HTMfuAE9aH3MN4dD+v6Lvj3SiupHAWC2FB21DWajs0Kpyz+Eh3MVEa26BsTpc2eFw lnDhU/tJGXkLxwpA4dEFSiRNsPjPp3TSUjQJ1lkMNKliiBRaxsWiqrKpRO7Za9G4u/QJ sRZ0NehTo3nxoNz9cTGYIZ6+2fPCBVCyS9Syntlu+uj7OOyYrVOrSQy3Kb7VICOMdb3z rU1A== X-Gm-Message-State: AC+VfDxe0EJeNby6aYIkHUe/NffhSUc6zN6eydbvD1bw/9/tbCzIrlBL YRNTkcjA+14triS7WyOn/7s1WFCkKbQKgdJ3O90Y4g== X-Received: by 2002:a1c:7716:0:b0:3f6:1317:ca71 with SMTP id t22-20020a1c7716000000b003f61317ca71mr949767wmi.14.1685086590656; Fri, 26 May 2023 00:36:30 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:777b:eef4:6f79:f26f]) by smtp.gmail.com with ESMTPSA id q21-20020a1ce915000000b003f421979398sm7848832wmc.26.2023.05.26.00.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:36:30 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Fix detection of non-static expressions in records with pragmas Date: Fri, 26 May 2023 09:36:29 +0200 Message-Id: <20230526073629.2069189-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766942379300514414?= X-GMAIL-MSGID: =?utf-8?q?1766942379300514414?= From: Piotr Trojanek When iterating over record components we must ignore pragmas. Minor bug, as pragmas within record components do not appear often. gcc/ada/ * sem_cat.adb (Check_Non_Static_Default_Expr): Detect components inside loop, not in the loop condition itself. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_cat.adb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sem_cat.adb b/gcc/ada/sem_cat.adb index 09560e6179a..13dff3dbdd9 100644 --- a/gcc/ada/sem_cat.adb +++ b/gcc/ada/sem_cat.adb @@ -346,14 +346,13 @@ package body Sem_Cat is if Null_Present (Recdef) then return; - else - Component_Decl := First (Component_Items (Component_List (Recdef))); end if; - while Present (Component_Decl) - and then Nkind (Component_Decl) = N_Component_Declaration - loop - if Present (Expression (Component_Decl)) + Component_Decl := First (Component_Items (Component_List (Recdef))); + + while Present (Component_Decl) loop + if Nkind (Component_Decl) = N_Component_Declaration + and then Present (Expression (Component_Decl)) and then Nkind (Expression (Component_Decl)) /= N_Null and then not Is_OK_Static_Expression (Expression (Component_Decl))