Patchwork [Ada] Fix casing of identifiers in error messages

login
register
mail settings
Submitter Arnaud Charlet
Date June 22, 2010, 12:34 p.m.
Message ID <20100622123420.GA23054@adacore.com>
Download mbox | patch
Permalink /patch/56471/
State New
Headers show

Comments

Arnaud Charlet - June 22, 2010, 12:34 p.m.
There are many cases in which we could give the casing from
the actual source program in an error message and instead we
give default casing, this is due to a one-token error in errout.

Here is an example (compiled with -gnatj60)

> Compiling: bad_casing.adb
>
>      1. package body Bad_Casing is
>      2.   procedure yy_Traverse_BU( yyt: access yy0_Environ ) is
>      3.     begin
>      4.       if (yyt = No_Ident_Table) then return; end if;
>                       |
>         >>> invalid operand types for operator "=", left
>             operand has type access to "yy0_Environ"
>             defined at bad_casing.ads:7, right operand has
>             type "Ident_Table" defined at bad_casing.ads:3
>
>      5.     end yy_Traverse_BU;
>      6. end Bad_Casing;
>
> Compiling: bad_casing.ads
>
>      1. package Bad_Casing is
>      2.   type yyt_Node is abstract tagged null record;
>      3.   type Ident_Table is access all yyt_Node'Class;
>      4.   procedure yy_Traverse_BU ( yyt: access yyt_Node ) is abstract;
>      5.   No_Ident_Table: constant Ident_Table := null;
>      6.   type yy0_Environ is new yyt_Node with null record;
>      7.   procedure yy_Traverse_BU (yyt:access yy0_Environ );
>      8. end Bad_Casing;

Prior to this patch we had Yy0_Environ rather than yy0_Environ in
the error message, we prefer the latter since it is the way the
programmer spelled it in the source.
Yy0_Environ

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

2010-06-22  Robert Dewar  <dewar@adacore.com>

	* errout.adb (Set_Msg_Node): Fix incorrect reference to node.

Patch

Index: errout.adb
===================================================================
--- errout.adb	(revision 161169)
+++ errout.adb	(working copy)
@@ -2499,7 +2499,7 @@  package body Errout is
       --  in case, which is the case when we can copy from the source.
 
       declare
-         Src_Loc : constant Source_Ptr := Sloc (Error_Msg_Node_1);
+         Src_Loc : constant Source_Ptr := Sloc (Node);
          Sbuffer : Source_Buffer_Ptr;
          Ref_Ptr : Integer;
          Src_Ptr : Source_Ptr;