From patchwork Tue Jul 18 13:13:36 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: 122033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1741961vqt; Tue, 18 Jul 2023 06:22:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlE4PTa5mAhnITzoULT/VOOKTUzl+wiMwLDF46hea6O0jlXy8xb9BysFsNTpkdSJYqhPBPB2 X-Received: by 2002:a05:6512:1047:b0:4f8:70b0:eec6 with SMTP id c7-20020a056512104700b004f870b0eec6mr11643211lfb.28.1689686552238; Tue, 18 Jul 2023 06:22:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689686552; cv=none; d=google.com; s=arc-20160816; b=i85AOASySNpqyd8j8RuLwfnWsgTGZl8/MhVigUvjr9c8dHcytVbHnb6G8CB8hNTKqN IVPBQbucfhfgSYEo+Pa9ByEFQrcBMa/om0VlxcMoydXzU8oOU6rG7x0IGZkPULiDPlOi YzNCpn2sB4k1ssFn4O2cLZbAMe9AyEzBfqbQ8qFyVLFKBIPTGL5ou/O13XgUInKVg4Nq ZsGeW51csPnYRTB/gQqcJLFqIVHqODk633oEbAL5BUpiOw8WzxzuaRwba6dKFkaPXVl0 4aDNbpxNrNDKAa1dKgSLEhldBh1Yu7mFRVnR7Q04vnOn5/qw+22MQqYA5owALFFodQ4b wAVg== 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=ftloBKoiN1zamwZAZ4+pnvUZmlSXUZczeqoClVGxTTQ=; fh=/3KX5nH+f3PGIzCwnuf//1E+cbLgxv/xavy4NboKqC4=; b=klaihXNwIl+/I14V8FP47ilXtIglzmYGpjifp9ShtS2yButUVgosH6T8G+Iowbr+DV ROiyTuFZUGCb+T3ocpU6frSNEqjdUaCP5NyCNH70BSNS0F0+lWmvWk3HKYZssfHVUHn9 ghhDdqbnwTKrc05AK8hPTanQgLGVaU6VHewQhYBWCix/NtmpP4A9jG974/EqNwDMJyHP uQPKiZefPGz90MLxfdUa5pycdMWXc6BqdR6xEbkKqGrIVK0dn/w7HOLyjzD6SiikpzDW EDLs6mfeAj8t/HrJppse9XvO/9RHLNFwjhZkqly4Tje7V3egvH83kHchdefpJtwEwUMl lzIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=w+NZ0sVK; 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id w13-20020aa7d28d000000b0051bf8df2a07si1254569edq.364.2023.07.18.06.22.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 06:22:32 -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=w+NZ0sVK; 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 A7496380F718 for ; Tue, 18 Jul 2023 13:17:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7496380F718 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689686236; bh=ftloBKoiN1zamwZAZ4+pnvUZmlSXUZczeqoClVGxTTQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=w+NZ0sVKpm9RF9RVpVN9DZYpk4g4jVsCJfRZ5+agIgDe0quGgx4iiLBQHs34HkErq bdHc3lrRZgRaZ0f9Rt/eueUcacAeCqKxBc+g6FO2Tgsfq+CRCZ+XSj5c9ULbUQrdu8 RBTK+KiOFTUD0LtcDBuW6jiPxxLhnxEcJLXgRWzw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 26600385AFBE for ; Tue, 18 Jul 2023 13:13:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 26600385AFBE Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-316eabffaa6so4958415f8f.2 for ; Tue, 18 Jul 2023 06:13:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689686018; x=1690290818; 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=ftloBKoiN1zamwZAZ4+pnvUZmlSXUZczeqoClVGxTTQ=; b=FwxdBUcMYV5gHuO6LlKDR3Q10oWvJplMRKPCMm7hpmdqHRdTlrCWVmF5FWpQfbAQVg uoK9oVwnz3fUv+ID5lRis3YpFHDNC9lVAPzjH+B4MrAysIqKZFVMjAV5m4L6znE7Hp1H DjUVDh2j6/3mC/Qq1Yyi/CUGRH5jWgXOusXT+ijoCV6iA2goc/gAV9Dax7Ab8oKq+Ly9 22/p97ktceiUlLDeNYpvajYBoQLCo6bOdes0wcgFfFXp/jq41m6RZ7HNjsl75tVQ5Vh+ 1j/Vcv1YQSbRAXmItKO5f9lhUV8YoblbmiBkTcZlCQoU0XcRm2haKfV1a/oGQIgngqlZ vfJw== X-Gm-Message-State: ABy/qLb9dGxKWZy6ucNhrtywYyLs3kZyw6RExRUI5NIJAc8liIa5Sn8/ 6Gj0xKrhBOIoiiOwr6xitZC4E3Z+BqAVjH4oG6/e9w== X-Received: by 2002:adf:f386:0:b0:314:77a:c2b2 with SMTP id m6-20020adff386000000b00314077ac2b2mr12803816wro.32.1689686018087; Tue, 18 Jul 2023 06:13:38 -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 x10-20020a05600c2a4a00b003fc0505be19sm2100782wme.37.2023.07.18.06.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 06:13:37 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Improve error message for ambiguous subprogram call Date: Tue, 18 Jul 2023 15:13:36 +0200 Message-Id: <20230718131336.81291-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771764766227163374 X-GMAIL-MSGID: 1771764766227163374 From: Eric Botcazou This restores the full listing of the types for the interpretations. gcc/ada/ * sem_util.ads (Wrong_Type): Add Multiple parameter defaulting to False and document it. * sem_util.adb (Wrong_Type): Do not return early if an error has already been posted on Expr and Multiple is True. * sem_ch4.adb (Analyze_One_Call): Pass All_Errors_Mode as the actual parameter for Multiple to Wrong_Type. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch4.adb | 6 +++++- gcc/ada/sem_util.adb | 15 ++++++++++----- gcc/ada/sem_util.ads | 8 ++++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index fafb7e63110..8543f0d578b 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -4099,7 +4099,11 @@ package body Sem_Ch4 is Actual, Etype (Etype (Formal))); end if; - Wrong_Type (Actual, Etype (Formal)); + -- If we are going to output a secondary error message + -- below, we need to have Wrong_Type output the main one. + + Wrong_Type + (Actual, Etype (Formal), Multiple => All_Errors_Mode); if Nkind (Actual) = N_Op_Eq and then Nkind (Left_Opnd (Actual)) = N_Identifier diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 222fd72a061..35ec296ab93 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -29398,7 +29398,11 @@ package body Sem_Util is -- Wrong_Type -- ---------------- - procedure Wrong_Type (Expr : Node_Id; Expected_Type : Entity_Id) is + procedure Wrong_Type + (Expr : Node_Id; + Expected_Type : Entity_Id; + Multiple : Boolean := False) + is Found_Type : constant Entity_Id := First_Subtype (Etype (Expr)); Expec_Type : constant Entity_Id := First_Subtype (Expected_Type); @@ -29485,13 +29489,14 @@ package body Sem_Util is begin -- Don't output message if either type is Any_Type, or if a message - -- has already been posted for this node. We need to do the latter - -- check explicitly (it is ordinarily done in Errout), because we - -- are using ! to force the output of the error messages. + -- has already been posted for this node and we do not want multiple + -- error messages. We need to do the latter check explicitly (it is + -- ordinarily done in Errout) because we are using '!' to force the + -- output of the error messages. if Expec_Type = Any_Type or else Found_Type = Any_Type - or else Error_Posted (Expr) + or else (Error_Posted (Expr) and then not Multiple) then return; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 7fc77de2b8a..b56a235c022 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -3362,12 +3362,16 @@ package Sem_Util is -- is potentially issued: it is the visible entity in the former case, and -- the use_clause in the latter case. - procedure Wrong_Type (Expr : Node_Id; Expected_Type : Entity_Id); + procedure Wrong_Type + (Expr : Node_Id; + Expected_Type : Entity_Id; + Multiple : Boolean := False); -- Output error message for incorrectly typed expression. Expr is the node -- for the incorrectly typed construct (Etype (Expr) is the type found), -- and Expected_Type is the entity for the expected type. Note that Expr -- does not have to be a subexpression, anything with an Etype field may - -- be used. + -- be used. If Multiple is False, do not output the message if an error + -- has already been posted for Expr. function Yields_Synchronized_Object (Typ : Entity_Id) return Boolean; -- Determine whether type Typ "yields synchronized object" as specified by