diff mbox

[Ada] Improve error message for extra "," in choice list

Message ID 20110801132352.GA9256@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Aug. 1, 2011, 1:23 p.m. UTC
The new error messages should be:
 c.adb:4:16: extra "," ignored
 c.adb:9:16: "," should be "|"

for the following test case:

procedure c (X : Boolean) is
begin
   case X is
      when True,
        | False => null;
   end case;

   case X is
      when True, False => null;
   end case;
end c;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-01  Geert Bosch  <bosch@adacore.com>

	* par-ch3.adb (P_Discrete_Choice_List): Improve error message for extra
	"," in choice list.
diff mbox

Patch

Index: par-ch3.adb
===================================================================
--- par-ch3.adb	(revision 176998)
+++ par-ch3.adb	(working copy)
@@ -3714,13 +3714,23 @@ 
          end if;
 
          if Token = Tok_Comma then
-            Error_Msg_SC -- CODEFIX
-              (""","" should be ""'|""");
+            Scan; -- past comma
+
+            if Token = Tok_Vertical_Bar then
+               Error_Msg_SP -- CODEFIX
+                 ("|extra "","" ignored");
+               Scan; -- past |
+
+            else
+               Error_Msg_SP -- CODEFIX
+                 (""","" should be ""'|""");
+            end if;
+
          else
             exit when Token /= Tok_Vertical_Bar;
+            Scan; -- past |
          end if;
 
-         Scan; -- past | or comma
       end loop;
 
       return Choices;