diff options
author | Yannick Moy <moy@adacore.com> | 2018-05-21 14:50:49 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-05-21 14:50:49 +0000 |
commit | fe44c442e4c83f3280a72e917c418c6e6129cba7 (patch) | |
tree | d147867589f14fae1ab46865b64cd4daac8511ad | |
parent | c77384a44f4e8b30d90c5a1c7f4593cb76c0d67e (diff) | |
download | gcc-fe44c442e4c83f3280a72e917c418c6e6129cba7.zip gcc-fe44c442e4c83f3280a72e917c418c6e6129cba7.tar.gz gcc-fe44c442e4c83f3280a72e917c418c6e6129cba7.tar.bz2 |
[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 <moy@adacore.com>
gcc/ada/
* sem_eval.adb (Static_Length): Take into account case of variable of
subtype string literal.
From-SVN: r260452
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/sem_eval.adb | 7 |
2 files changed, 12 insertions, 0 deletions
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 <moy@adacore.com> + + * sem_eval.adb (Static_Length): Take into account case of variable of + subtype string literal. + 2018-04-04 Olivier Hainque <hainque@adacore.com> * 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 |