Change the internal data structure that stores the compiler diagnostics to store spans instead of locations, where a span is a triplet of a main location, and a first-last pair of locations. Also change the main procedures for reporting an error in Errout to use spans instead of locations whenever possible. As nodes in the AST are associated to a location and not a span, the span is currently reconstructed when reporting an error on a node, by retrieving the span covered by the node subtree. Locations are still used whenever a span cannot be used because the diagnostic is associated with a location (coming from a token during parsing in many cases) rather than a node. There are minimal changes to the compiler output for now, only as a result of changes to First_Node that now applies to some declarations and statements and not only expressions. This has a result to change the location of some diagnostics. The effect of spans is visible when compiling with debug flag -gnatdF to display spans inline with the diagnstics in command-line usage, as used in GNATprove. Tested on x86_64-pc-linux-gnu, committed on trunk 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.