Patchwork [Ada] minor improvement to handling of assertion/check messages

login
register
mail settings
Submitter Arnaud Charlet
Date June 14, 2010, 1:47 p.m.
Message ID <20100614134713.GA12751@adacore.com>
Download mbox | patch
Permalink /patch/55535/
State New
Headers show

Comments

Arnaud Charlet - June 14, 2010, 1:47 p.m.
Following a previous change, the "check/assertion will fail" message is
posted on the expression rather than on the pragma keyword. This patch
makes a similar change for the "check/assertion would fail" message as
shown by the following test:

Compiling: test_assert_warning.adb

     1. procedure test_assert_warning is
     2. begin
     3.    pragma Assert (Integer'Size = 700);
                                       |
        >>> warning: assertion would fail at run-time

     4.    pragma Check (Other_Check, Integer'Size = 700);
                                                   |
        >>> warning: check would fail at run-time

     5.    pragma Assert (False);
     6.    if Integer'Size > 600 then
     7.       pragma Assert (Integer'Size = 700);
     8.       pragma Check (Other_Check, Integer'Size = 700);
     9.       null;
    10.    end if;
    11. end;

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

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

	* sem_res.adb (Resolve_Short_Circuit): Fix sloc of "assertion/check
	would fail" msg.

Patch

Index: sem_res.adb
===================================================================
--- sem_res.adb	(revision 160734)
+++ sem_res.adb	(working copy)
@@ -7846,15 +7846,15 @@  package body Sem_Res is
                   then
                      null;
                   else
-                     --  Issue warning. Note that we don't want to make this
-                     --  an unconditional warning, because if the assert is
-                     --  within deleted code we do not want the warning. But
-                     --  we do not want the deletion of the IF/AND-THEN to
-                     --  take this message with it. We achieve this by making
-                     --  sure that the expanded code points to the Sloc of
-                     --  the expression, not the original pragma.
+                     --  Issue warning. We do not want the deletion of the
+                     --  IF/AND-THEN to take this message with it. We achieve
+                     --  this by making sure that the expanded code points to
+                     --  the Sloc of the expression, not the original pragma.
 
-                     Error_Msg_N ("?assertion would fail at run-time", Orig);
+                     Error_Msg_N
+                       ("?assertion would fail at run-time!",
+                        Expression
+                          (First (Pragma_Argument_Associations (Orig))));
                   end if;
                end;
 
@@ -7877,7 +7877,10 @@  package body Sem_Res is
                   then
                      null;
                   else
-                     Error_Msg_N ("?check would fail at run-time", Orig);
+                     Error_Msg_N
+                       ("?check would fail at run-time!",
+                        Expression
+                          (Last (Pragma_Argument_Associations (Orig))));
                   end if;
                end;
             end if;