Add Chain Check to VAST for Entity Consistency
Adds a check to ensure entity chains in VAST are consistent, specifically for entities used as Scope.
This change adds a check to the VAST (Very Abstract Syntax Tree) to ensure that the Next_Entity and Prev_Entity links are consistent within entity chains. The check is currently limited to entities used as Scope. Calls to Copy_And_Swap can create incorrect chains where the new node has its Prev/Next/First/Last links copied from the original node, but back links are not changed, leading to inconsistencies when traversing the chain.
In Details
VAST in GNAT represents the program's syntax tree after semantic analysis. Entity chains link declarations and definitions. This commit adds Check_Entity_Chain to vast.adb, called by Check_Scope, to verify the consistency of Next_Entity and Prev_Entity links. A toolchain developer outside the GNAT might miss this due to its Ada-specific AST representation.
For Context
The Very Abstract Syntax Tree (VAST) represents source code in a structured way that the compiler can easily analyze. This commit focuses on the Ada front-end of GCC, specifically how the compiler keeps track of related elements in the code via 'entity chains'. It adds a check to ensure that these chains are consistently linked, which helps to prevent errors during compilation related to how the compiler understands the structure of your code.