From patchwork Wed Sep 6 10:09:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 810492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461578-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="rWyyQ0+c"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xnK7q4btDz9sBd for ; Wed, 6 Sep 2017 20:09:42 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=eGEVV8gkNBNpKrJ33nzVQZh36Tybm7gwttRCsStiXrKiMRgZpp v7mv/rX1PRS4aHHu+9aNoMUTp5Glschb48Mh3T8d87RUPpB/eZCqvfgMfU1pHnwJ gvPhcbAUFBivX/y1uU8vHR04BmxQcifIS8y822aO1cuRMbMBrZbGsQ3Lw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=yDrQYdGxHufskYaMC1RbWktKWbM=; b=rWyyQ0+cTmAn0eFQiHp1 NdmTLrG0FrjQOvjiTjaOuXWPj5gKjcURHC05ZZcRrIqnkPbERZT8BACWLXN9NcaB d4vuTCgOtQb3co1ecu08W2EqPdxJr8iM9g8ngi5caZTZvpAT9/NaTebZ1LF/T24m fmIWQysfw/LAvOex3jYHHZU= Received: (qmail 61532 invoked by alias); 6 Sep 2017 10:09:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 61521 invoked by uid 89); 6 Sep 2017 10:09:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=harm X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Sep 2017 10:09:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 95EEC56137; Wed, 6 Sep 2017 06:09:30 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id aqplbgUEFvmr; Wed, 6 Sep 2017 06:09:30 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 83A085606C; Wed, 6 Sep 2017 06:09:30 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 7FE1D4FC; Wed, 6 Sep 2017 06:09:30 -0400 (EDT) Date: Wed, 6 Sep 2017 06:09:30 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Yannick Moy Subject: [Ada] Improve error message when function is used in a call statement Message-ID: <20170906100930.GA54943@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) A typical error for new users of Ada is to call functions in a call statement. Improve the error message for these users, to better indicate what the error is in that case. The following compilation raises the new message. $ gcc -c main.adb 1. procedure Main is 2. function Lol return Integer is (0); 3. begin 4. Lol; | >>> cannot use call to function "Lol" as a statement >>> return value of a function call cannot be ignored 5. end Main; Tested on x86_64-pc-linux-gnu, committed on trunk 2017-09-06 Yannick Moy * sem_res.adb (Resolve): Update message for function call as statement. Index: sem_res.adb =================================================================== --- sem_res.adb (revision 251755) +++ sem_res.adb (working copy) @@ -2533,8 +2533,11 @@ and then Ekind (Entity (Name (N))) = E_Function then Error_Msg_NE - ("cannot use function & in a procedure call", + ("cannot use call to function & as a statement", Name (N), Entity (Name (N))); + Error_Msg_N + ("\return value of a function call cannot be ignored", + Name (N)); -- Otherwise give general message (not clear what cases this -- covers, but no harm in providing for them).