In some cases, the inlining performed in GNATprove mode leads to a crash,
when inlining a call where a return statement of the inlined function
returns a string literal. Now fixed.
Tested on x86_64-pc-linux-gnu, committed on trunk
2018-05-21 Yannick Moy <m...@adacore.com>
gcc/ada/
* sem_eval.adb (Static_Length): Take into account case of variable of
subtype string literal.
--- gcc/ada/sem_eval.adb
+++ gcc/ada/sem_eval.adb
@@ -3403,6 +3403,13 @@ package body Sem_Eval is
if Nkind (Expr) = N_String_Literal then
return UI_From_Int (String_Length (Strval (Expr)));
+ -- With frontend inlining as performed in GNATprove mode, a variable
+ -- may be inserted that has a string literal subtype. Deal with this
+ -- specially as for the previous case.
+
+ elsif Ekind (Etype (Expr)) = E_String_Literal_Subtype then
+ return String_Literal_Length (Etype (Expr));
+
-- Second easy case, not constrained subtype, so no length
elsif not Is_Constrained (Etype (Expr)) then