From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id CB0F03858C2B for ; Tue, 23 May 2023 08:08:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB0F03858C2B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f6042d60b5so21226835e9.2 for ; Tue, 23 May 2023 01:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1684829315; x=1687421315; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rue3NxJ2+CbO+2ZewV6uo54zBRLUK42k5A2z1R26NS0=; b=jMn+95QKJNh4tVGsDBqZ1jw3hIdT9cpSqg4bO7KNdrqKVCTYZXUAYehMaLA6p0Jamf MOn2heDaMiOkKHuaxhs+WBbjGKLeQUPH4ebw2b4I6P99bmc4yg/ds0x6hJSP/sSHQCAW d/33OU1/NY2Kco4fgH8pIJ2Hu2RztxK/QTCBLidFaf/JPEcJI8odq19VM8Of2RbR8eVv R/WdPP1VqlrFmPzyP1eein0scNIsYmaQGoKwG/TzvL6xCPwt/mAym2efJGIKQWBqLZek uBlIyVcdUSgsgvkEX7OxlSb5lf7n1uBzd7aIh63DzFJW0cLMIKp9mEKIRIM7GA57UZqd QyVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684829315; x=1687421315; 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=rue3NxJ2+CbO+2ZewV6uo54zBRLUK42k5A2z1R26NS0=; b=jZESxKs+AU0XFAq2q/C8SLTR0517s9p69ih6hMVbXjdaWQdhQQeFZLCGrhpfAIvpqb w8UF71K3GYFB+s9X9s0B+ie0MqRhWJhnf79f805WJeYaChGgK2DkTFoKNYxV9YTzxUX+ Y0ZEYCC5W75sfy+MGa78zUrsRcMBFzqs1hKcKDd0YaTiyOYuOvVPXuI7mSb969yK2eb+ z5FUdA8pAkRETUYmDXcr2eIlu7wgXojlM9gGfUVjpuha8lI6h7u3KOXPpZJrMQajlUTg 62uLt+YDsSgoYpd7fzOqujFofy5qr3Kd4j9DxTT8HyvJ9Ta45HZ84OqWVA8x2o6wtCAn 9k/w== X-Gm-Message-State: AC+VfDwSCUYyQgxlH0P/jsXLqLpwcZs7bTaZq0vyqm7ewUj5uJVG5O9r BGsoU68vNNzroVE18bEQn/NzNpqANAhtkCWrSAfB2Q== X-Google-Smtp-Source: ACHHUZ5qs4Ed+HnUS7Woiop7vXSllnDeBLyqZdkH9eBB2q7d3n8yiHJBLPmqq4x4UOwErOTqjtcVlQ== X-Received: by 2002:adf:fd07:0:b0:309:3b27:9baa with SMTP id e7-20020adffd07000000b003093b279baamr9716540wrr.52.1684829315684; Tue, 23 May 2023 01:08:35 -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 r14-20020adfce8e000000b00306c5900c10sm10309456wrn.9.2023.05.23.01.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 01:08:35 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Steve Baird Subject: [COMMITTED] ada: A discriminant of a variable is not a variable Date: Tue, 23 May 2023 10:08:34 +0200 Message-Id: <20230523080834.1873919-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.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: Steve Baird gcc/ada/ * sem_util.adb (Is_Variable): Correctly return False for a selected component name of the form Some_Object.Some_Discriminant, even if Some_Object is a variable. We don't want to allow such a name as an actual parameter in a call if the corresponding formal parameter's mode is not "in". Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index baf4cefdfb3..7e302897888 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -21196,11 +21196,8 @@ package body Sem_Util is return Is_Variable_Prefix (Prefix (Orig_Node)); when N_Selected_Component => - return (Is_Variable (Selector_Name (Orig_Node)) - and then Is_Variable_Prefix (Prefix (Orig_Node))) - or else - (Nkind (N) = N_Expanded_Name - and then Scope (Entity (N)) = Entity (Prefix (N))); + return Is_Variable (Selector_Name (Orig_Node)) + and then Is_Variable_Prefix (Prefix (Orig_Node)); -- For an explicit dereference, the type of the prefix cannot -- be an access to constant or an access to subprogram. -- 2.40.0