From fe44c442e4c83f3280a72e917c418c6e6129cba7 Mon Sep 17 00:00:00 2001 From: Yannick Moy Date: Mon, 21 May 2018 14:50:49 +0000 Subject: [PATCH] [Ada] Crash on incorrect frontend inlining in GNATprove mode 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. 2018-05-21 Yannick Moy gcc/ada/ * sem_eval.adb (Static_Length): Take into account case of variable of subtype string literal. From-SVN: r260452 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/sem_eval.adb | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index faa1154..d8e644e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-04-04 Yannick Moy + + * sem_eval.adb (Static_Length): Take into account case of variable of + subtype string literal. + 2018-04-04 Olivier Hainque * libgnat/s-objrea.ads (Get_Memory_Bounds): Rename as Get_Xcode_Bounds. diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index 93536cb..ca51626 100644 --- a/gcc/ada/sem_eval.adb +++ b/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 -- 2.7.4