From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id 62CCF3858417 for ; Mon, 7 Aug 2023 11:16:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 62CCF3858417 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-x32f.google.com with SMTP id 5b1f17b1804b1-3fe2ba3e260so43404535e9.2 for ; Mon, 07 Aug 2023 04:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1691406997; x=1692011797; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eCiS6JJLeXVfQjVLfGrGLvkylzM+aTMG5M//kANx2ms=; b=TkuiWG1fNUhh8hkb8VYq7YZDBPZl8cFazmkJ/TBdRpJbKAtPrJ1TYNsxJRwZF2PShP ozx5g95TK6UoAJ9uPRfWTf3pKVSg7W6nqOWKljqPXDLooqdNJTFWr2mTNBV0nvgfsnZ1 uZwduOr+PDFZCT2fpAUJ2NKZHM+o40rQPXL873ldpPJnXaFklZ4JYqghjmV7OG3hBXcd MDu2xnmY+9ztM6QZ0elikJ9sjVLmZ4Y737FEsIyxznQ9i9bv8dz08qmZSsAQeu/Td+iV jKfdi1c0+mP49H0yd5cEN5gQvfgs6aX3+ZYUoH505FzsIOJULhCJKTMO0bS3L6wbkS9F B10w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406997; x=1692011797; 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=eCiS6JJLeXVfQjVLfGrGLvkylzM+aTMG5M//kANx2ms=; b=czfl3oslYqNQvnJtFdobP6Vk4gXWAsH8mQlHj2nLQ61h7AXciKYom2pCleomZvpoft dZ04wW6sMSw9GXlo++/4yBcqvwfXBV5zeckomTZliaRM1bZ2acPsTjZXrVHb8bRkB7I9 dLeAxr6GQVYLxWHR6G8P7/+V40bLv+LThZtPlRqnCYBRPZAnfLYG5ygE8maHoeDKqeDp lq8C+5O/81C5ECDSbWtsMhRxkfzVPRpKR8Jyx+WophAe/Qy51JyFVMRQHU9dbtNsQEoM 4icVmG9LMAGgCCs+kXAS/Ws/BGaCG6vcyaNNShQt/GctN7nmnV2LBcZLRdqgSh/ews8v z/iw== X-Gm-Message-State: AOJu0Yzgvp3629tsYG8zdwfB81uGCfuHKqXLAxbddQavU1PDU8ttWvGp CVcz3pBE71Mto5GAW6lt/xPjgrjOO+oXGKPN8Ru6wg== X-Google-Smtp-Source: AGHT+IH0IpXNY92N0mmkftLDuGYZFD5wGS5CTvut/fbronSPiLBnzgMYYYN0ke0w1rLlmHiE8wCw7g== X-Received: by 2002:a1c:7906:0:b0:3fe:16c0:6b44 with SMTP id l6-20020a1c7906000000b003fe16c06b44mr6800094wme.12.1691406997015; Mon, 07 Aug 2023 04:16:37 -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 9-20020a05600c228900b003fe13c3ece7sm14874265wmf.10.2023.08.07.04.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:16:36 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED] ada: Spurious error on class-wide preconditions Date: Mon, 7 Aug 2023 13:16:22 +0200 Message-Id: <20230807111622.2854826-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.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 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: Javier Miranda The compiler reports an spurious error when a class-wide precondition expression has a class-wide type conversion. gcc/ada/ * sem_res.adb (Resolve_Type_Conversion): Do not warn on conversion to class-wide type on internally build helpers of class-wide preconditions. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_res.adb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index d3a0192fb09..ac0c60f5f22 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -12455,6 +12455,18 @@ package body Sem_Res is elsif Orig_T = Base_Type (Standard_Long_Long_Integer) then null; + -- Do not warn on conversion to class-wide type on helpers of + -- class-wide preconditions because in this context the warning + -- would be spurious (since the class-wide precondition has been + -- installed in the return statement of the helper, which has a + -- class-wide formal type instead of a regular tagged type). + + elsif Is_Class_Wide_Type (Orig_T) + and then Is_Subprogram_Or_Generic_Subprogram (Current_Scope) + and then Present (Class_Preconditions_Subprogram (Current_Scope)) + then + null; + -- Here we give the redundant conversion warning. If it is an -- entity, give the name of the entity in the message. If not, -- just mention the expression. -- 2.40.0