In case where the node is not a Pragma as expected, don't try to check
its field as it can raise a predicate error.
gcc/ada/ChangeLog:
* vast.adb (Do_Node_Pass_2): Only check aspect/pragma consistency for
pragma nodes.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/vast.adb | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/gcc/ada/vast.adb b/gcc/ada/vast.adb
index 4a26ddb5b84..d511532a3fc 100644
--- a/gcc/ada/vast.adb
+++ b/gcc/ada/vast.adb
@@ -636,10 +636,16 @@ package body VAST is
if Present (Aspect_Rep_Item (N)) then
Assert (Nkind (Aspect_Rep_Item (N)) = N_Pragma,
Check_Corresponding_Aspect);
- Assert (From_Aspect_Specification (Aspect_Rep_Item (N)),
- Check_Corresponding_Aspect);
- Assert (Corresponding_Aspect (Aspect_Rep_Item (N)) = N,
- Check_Corresponding_Aspect);
+
+ -- If the above check fails, the test below may raise predicate
+ -- failures, no need to check for pragma/aspect consistency for
+ -- other nodes.
+ if Nkind (Aspect_Rep_Item (N)) = N_Pragma then
+ Assert (From_Aspect_Specification (Aspect_Rep_Item (N)),
+ Check_Corresponding_Aspect);
+ Assert (Corresponding_Aspect (Aspect_Rep_Item (N)) = N,
+ Check_Corresponding_Aspect);
+ end if;
end if;
end if;
--
2.53.0