From patchwork Mon Mar 19 16:41:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 147579 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 3A9A8B6FBC for ; Tue, 20 Mar 2012 03:42:35 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1332780156; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=vAR8dUBuvnpH1Bh4AR2G xu2Uz60=; b=DGh0QazvGemcKUO0iYUsUhbO2s0SX97fDe3O8l5y2LxL/xVs0Y7U 2Jvv1jsd3Zao4wag4a5wHTPcFZrgr5fCjAhouIqwGhOn2PfYwnS81k1bOWKoStSJ t1sNO9aqpOohwFrX2lcmrZ8rahJUi5FTLvrXXZrm3dHWpfm6sf5B96Y= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=sLdBSD1dbVERAMlD/M0fPH/2SefitTWm95HS5xDzjEgOSt8F6mir7FDnXdd5+n g6zkyCpOVu/ml9kuQlQAvoAjTQWva9p3017cWIqHaJjBeqN8EPDq1eBTt+zgLuBL rKuI8K6fvF9ZikddCoq6Uq/YHUyrPsms9jkhUJjPp5aIQ=; Received: (qmail 22973 invoked by alias); 19 Mar 2012 16:42:29 -0000 Received: (qmail 22949 invoked by uid 22791); 19 Mar 2012 16:42:27 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Mar 2012 16:41:46 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 04A3C1C689A; Mon, 19 Mar 2012 12:41:46 -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 sxTnp74Tm08b; Mon, 19 Mar 2012 12:41:45 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id BAF931C6885; Mon, 19 Mar 2012 12:41:45 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id B8D423FEE8; Mon, 19 Mar 2012 12:41:45 -0400 (EDT) Date: Mon, 19 Mar 2012 12:41:45 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Robert Dewar Subject: [Ada] Better error message for a ** b ** c Message-ID: <20120319164145.GA24652@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 This patch gives better error recovery and message for a ** b ** c 1. package ParenExp is 2. a : Integer := 2 ** 3 ** 4; | >>> parenthesization required for ** 3. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-03-19 Robert Dewar * par-ch4.adb (Check_Bad_Exp): New procedure Index: par-ch4.adb =================================================================== --- par-ch4.adb (revision 185520) +++ par-ch4.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -81,6 +81,9 @@ -- Called to place complaint about bad range attribute at the given -- source location. Terminates by raising Error_Resync. + procedure Check_Bad_Exp; + -- Called after scanning a**b, posts error if ** detected + procedure P_Membership_Test (N : Node_Id); -- N is the node for a N_In or N_Not_In node whose right operand has not -- yet been processed. It is called just after scanning out the IN keyword. @@ -107,6 +110,20 @@ Resync_Expression; end Bad_Range_Attribute; + ------------------- + -- Check_Bad_Exp -- + ------------------- + + procedure Check_Bad_Exp is + begin + if Token = Tok_Double_Asterisk then + Error_Msg_SC ("parenthesization required for '*'*"); + Scan; -- past ** + Discard_Junk_Node (P_Primary); + Check_Bad_Exp; + end if; + end Check_Bad_Exp; + -------------------------- -- 4.1 Name (also 6.4) -- -------------------------- @@ -1933,6 +1950,7 @@ Scan; -- past ** Set_Left_Opnd (Node2, Node1); Set_Right_Opnd (Node2, P_Primary); + Check_Bad_Exp; Node1 := Node2; end if; @@ -2320,6 +2338,7 @@ Scan; -- past ** Set_Left_Opnd (Node2, Node1); Set_Right_Opnd (Node2, P_Primary); + Check_Bad_Exp; return Node2; else return Node1;