The source location of an expression may not be the best place to put a message,
in the case of a failed assertion. For example, it gets located on the last
"and" keyword in a chain of boolean expressiond and'ed together. It is best to
put the message on the first character of an assertion, which is done here.
Tested on x86_64-pc-linux-gnu, committed on trunk
2011-11-21 Yannick Moy <[email protected]>
* exp_prag.adb (Expand_Pragma_Check): Place error on first character
of expression.
* sem_res.adb (Resolve_Short_Circuit): Place error on first
character of expression.
Index: exp_prag.adb
===================================================================
--- exp_prag.adb (revision 181574)
+++ exp_prag.adb (working copy)
@@ -270,7 +270,7 @@
procedure Expand_Pragma_Check (N : Node_Id) is
Cond : constant Node_Id := Arg2 (N);
- Loc : constant Source_Ptr := Sloc (Cond);
+ Loc : constant Source_Ptr := Sloc (First_Node (Cond));
Nam : constant Name_Id := Chars (Arg1 (N));
Msg : Node_Id;
Index: sem_res.adb
===================================================================
--- sem_res.adb (revision 181574)
+++ sem_res.adb (working copy)
@@ -8668,7 +8668,7 @@
-- this by making sure that the expanded code points to
-- the Sloc of the expression, not the original pragma.
- Error_Msg_N
+ Error_Msg_F
("?assertion would fail at run time!",
Expression
(First (Pragma_Argument_Associations (Orig))));
@@ -8694,7 +8694,7 @@
then
null;
else
- Error_Msg_N
+ Error_Msg_F
("?check would fail at run time!",
Expression
(Last (Pragma_Argument_Associations (Orig))));