diff options
author | Yannick Moy <moy@adacore.com> | 2020-12-07 16:45:23 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-04-28 05:38:08 -0400 |
commit | 9d5f3b7a694ceb774330d45894b38e34bb90f86a (patch) | |
tree | f9755e604cf4629f136eec728632b29475f8d069 /gcc/ada/errout.ads | |
parent | ae77b299e9717e3a76ac6b7be65145a50aa31ed2 (diff) | |
download | gcc-9d5f3b7a694ceb774330d45894b38e34bb90f86a.zip gcc-9d5f3b7a694ceb774330d45894b38e34bb90f86a.tar.gz gcc-9d5f3b7a694ceb774330d45894b38e34bb90f86a.tar.bz2 |
[Ada] Use spans instead of locations for compiler diagnostics
gcc/ada/
* errout.adb: (Error_Msg_Internal): Use span instead of
location.
(Error_Msg, Error_Msg_NEL): Add versions with span parameter.
(Error_Msg_F, Error_Msg_FE, Error_Msg_N, Error_Msg_NE,
Error_Msg_NW): Retrieve span from node.
(First_Node): Use the new First_And_Last_Nodes.
(First_And_Last_Nodes): Expand on previous First_Node. Apply to
other nodes than expressions.
(First_Sloc): Protect against inconsistent locations.
(Last_Node): New function based on First_And_Last_Nodes.
(Last_Sloc): New function similar to First_Sloc.
(Output_Messages): Update output when -gnatdF is used. Use
character ~ for making the span visible, similar to what is done
in GCC and Clang.
* errout.ads (Error_Msg, Error_Msg_NEL): Add versions with span
parameter.
(First_And_Last_Nodes, Last_Node, Last_Sloc): New subprograms.
* erroutc.adb: Adapt to Sptr field being a span.
* erroutc.ads (Error_Msg_Object): Change field Sptr from
location to span.
* errutil.adb: Adapt to Sptr field being a span.
* freeze.adb: Use Errout reporting procedures for nodes to get
spans.
* par-ch3.adb: Likewise.
* par-prag.adb: Likewise.
* par-util.adb: Likewise.
* sem_case.adb: Likewise.
* sem_ch13.adb: Likewise.
* sem_ch3.adb: Likewise.
* sem_prag.adb: Likewise.
* types.ads: (Source_Span): New type for spans.
(To_Span): Basic constructors for spans.
Diffstat (limited to 'gcc/ada/errout.ads')
-rw-r--r-- | gcc/ada/errout.ads | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads index 02cfdee..f9a8379 100644 --- a/gcc/ada/errout.ads +++ b/gcc/ada/errout.ads @@ -703,10 +703,15 @@ package Errout is procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr); procedure Error_Msg + (Msg : String; Flag_Span : Source_Span); + procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr; N : Node_Id); + procedure Error_Msg + (Msg : String; Flag_Span : Source_Span; N : Node_Id); -- Output a message at specified location. Can be called from the parser -- or the semantic analyzer. If N is set, points to the relevant node for - -- this message. + -- this message. The version with a span is preferred whenever possible, + -- in other cases the version with a location can still be used. procedure Error_Msg (Msg : String; @@ -782,8 +787,13 @@ package Errout is N : Node_Or_Entity_Id; E : Node_Or_Entity_Id; Flag_Location : Source_Ptr); + procedure Error_Msg_NEL + (Msg : String; + N : Node_Or_Entity_Id; + E : Node_Or_Entity_Id; + Flag_Span : Source_Span); -- Exactly the same as Error_Msg_NE, except that the flag is placed at - -- the specified Flag_Location instead of at Sloc (N). + -- the specified Flag_Location/Flag_Span instead of at Sloc (N). procedure Error_Msg_NW (Eflag : Boolean; @@ -801,12 +811,17 @@ package Errout is -- the given text. This text may contain insertion characters in the -- usual manner, and need not be the same length as the original text. + procedure First_And_Last_Nodes + (C : Node_Id; + First_Node, Last_Node : out Node_Id); + -- Given a construct C, finds the first and last node in the construct, + -- i.e. the ones with the lowest and highest Sloc value. This is useful in + -- placing error msgs. Note that this procedure uses Original_Node to look + -- at the original source tree, since that's what we want for placing an + -- error message flag in the right place. + function First_Node (C : Node_Id) return Node_Id; - -- Given a construct C, finds the first node in the construct, i.e. the one - -- with the lowest Sloc value. This is useful in placing error msgs. Note - -- that this procedure uses Original_Node to look at the original source - -- tree, since that's what we want for placing an error message flag in - -- the right place. + -- Return the first output of First_And_Last_Nodes function First_Sloc (N : Node_Id) return Source_Ptr; -- Given the node for an expression, return a source pointer value that @@ -817,6 +832,15 @@ package Errout is function Get_Ignore_Errors return Boolean; -- Return True if all error calls are ignored. + function Last_Node (C : Node_Id) return Node_Id; + -- Return the last output of First_And_Last_Nodes + + function Last_Sloc (N : Node_Id) return Source_Ptr; + -- Given the node for an expression, return a source pointer value that + -- points to the end of the last token in the expression. In the case + -- where the expression is parenthesized, an attempt is made to include + -- the parentheses (i.e. to return the location of the final paren). + procedure Purge_Messages (From : Source_Ptr; To : Source_Ptr) renames Erroutc.Purge_Messages; -- All error messages whose location is in the range From .. To (not |