From patchwork Tue Oct 5 08:26:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1536521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Ob0ohVbD; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HNrKY50vmz9sPB for ; Tue, 5 Oct 2021 19:26:56 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6590B3857416 for ; Tue, 5 Oct 2021 08:26:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6590B3857416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633422413; bh=vd56gjuOqIdikqKZleCxciEl9AIpkpIv6aFFLq6e934=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Ob0ohVbDX7YCqIIUrTcuIeSYM3xC3wyS7Hx9L1JU6BtmcOjiNyuuWCFN3njAnOELV +JKnPR0OlC8IYAQJ8LwwgzfRMIc8Q4+dDqZqgmTjb0Tk2lWhPAIQA8qHCrLa1QTodi Ptmm8RWfr+llQ+kDCGdZx3QgkWelEop9gDd036A0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id B4F363858402 for ; Tue, 5 Oct 2021 08:26:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B4F363858402 Received: by mail-lf1-x12d.google.com with SMTP id i24so33306279lfj.13 for ; Tue, 05 Oct 2021 01:26:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=vd56gjuOqIdikqKZleCxciEl9AIpkpIv6aFFLq6e934=; b=eDdRxoxWvoD0dJJCk5hAKUzUGYR7LfI2IuoCqrIOBn+QqcOWdfWo5CgHA123tZSGXB psBovkDMHqwEQmEgrvpype3FbOYPr/1VOHsZTUvk04p8O3CCCkqJ5wKlJp60OmWo5y0T 7TsuMR9RfAok+28w0Fa29DEgH/I6xyyGc3YlX0tUzP0Ae0kOHlprGE7Rry9RVTrlPElt gU0oGa9gLAZwFwpdLHN7O+fr6vVy+SOqNmrqyVg4G43KekP/g2Eli18cDKnG84T0VwAf d5EqZk4djpYfksBcy4fyEr9LL1KAfk/5nM1EbMGRvbjhKLDrgUgPgg+1YVxWxEX7Q/Ng XM3w== X-Gm-Message-State: AOAM5319IOM1cag/aypo7f0o+ICgo9BDUKj+wwikPNnYmBKvCgNPjFXw sK5zxGasLrVgnk93wBP6twTaUNVDgq7qmQ== X-Google-Smtp-Source: ABdhPJzKgyCbbJ5yXMXYmjI96Cw4Pi4AxgTCFY+GRV1+1yuy65lzVQRefetVxmJok9Qo3iXsvpEslA== X-Received: by 2002:a2e:9e0b:: with SMTP id e11mr110007ljk.283.1633422392389; Tue, 05 Oct 2021 01:26:32 -0700 (PDT) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id l9sm1898538ljg.44.2021.10.05.01.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 01:26:31 -0700 (PDT) Date: Tue, 5 Oct 2021 08:26:30 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Improve error message on missing all/for in quantified expression Message-ID: <20211005082630.GA2693517@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.1 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Yannick Moy Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" When "for" or "some" keyword is missing from a quantified expression, it is interpreted as an iterated component association by GNAT, leading to misleading error messages such as: badquant.ads:4:07: error: expected type "Standard.Boolean" badquant.ads:4:07: error: found a composite type Recognize this case specially to issue a better error message: badquant.ads:4:11: error: missing "all" or "some" in quantified expression Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve): Recognize specially that case. diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -3098,6 +3098,24 @@ package body Sem_Res is Error_Msg_N ("\use -gnatf for details", N); end if; + -- Recognize the case of a quantified expression being mistaken + -- for an iterated component association because the user + -- forgot the "all" or "some" keyword after "for". Because the + -- error message starts with "missing ALL", we automatically + -- benefit from the associated CODEFIX, which requires that + -- the message is located on the identifier following "for" + -- in order for the CODEFIX to insert "all" in the right place. + + elsif Nkind (N) = N_Aggregate + and then List_Length (Component_Associations (N)) = 1 + and then Nkind (First (Component_Associations (N))) + = N_Iterated_Component_Association + and then Is_Boolean_Type (Typ) + then + Error_Msg_N -- CODEFIX + ("missing ALL or SOME in quantified expression", + Defining_Identifier (First (Component_Associations (N)))); + else Wrong_Type (N, Typ); end if;