public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Better error message for a ** b ** c
@ 2012-03-19 16:42 Arnaud Charlet
  0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2012-03-19 16:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: Robert Dewar

[-- Attachment #1: Type: text/plain, Size: 370 bytes --]

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  <dewar@adacore.com>

	* par-ch4.adb (Check_Bad_Exp): New procedure


[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 2265 bytes --]

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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-03-19 16:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-19 16:42 [Ada] Better error message for a ** b ** c Arnaud Charlet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).