diff options
author | Justin Squirek <squirek@adacore.com> | 2019-07-09 07:55:33 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2019-07-09 07:55:33 +0000 |
commit | 924e3532dcdabde43f5b49f1ef1a95656f4e37dc (patch) | |
tree | 296054b210f015a73f71c210e04f0945b8623db3 /gcc/ada | |
parent | 18934a8d0feb60be26513cfbb4b9d34a908a7602 (diff) | |
download | gcc-924e3532dcdabde43f5b49f1ef1a95656f4e37dc.zip gcc-924e3532dcdabde43f5b49f1ef1a95656f4e37dc.tar.gz gcc-924e3532dcdabde43f5b49f1ef1a95656f4e37dc.tar.bz2 |
[Ada] Crash on 'Img attribute
This patch fixes and issue whereby applying 'Img to a constant
enumerated character type would result in a compiler crash when
assertions are enabled and infinite recursion when they are not.
2019-07-09 Justin Squirek <squirek@adacore.com>
gcc/ada/
* sem_eval.adb (Expr_Value_E): Add conditional to correctly
handle constant enumerated character types.
gcc/testsuite/
* gnat.dg/image1.adb: New testcase.
From-SVN: r273292
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/ada/sem_eval.adb | 10 |
2 files changed, 14 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index cfbdf89..524adfd 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-07-09 Justin Squirek <squirek@adacore.com> + + * sem_eval.adb (Expr_Value_E): Add conditional to correctly + handle constant enumerated character types. + 2019-07-09 Eric Botcazou <ebotcazou@adacore.com> * libgnarl/s-osinte__mingw.ads (CRITICAL_SECTION): Use proper diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index ff3359f..e140fa7 100644 --- a/gcc/ada/sem_eval.adb +++ b/gcc/ada/sem_eval.adb @@ -4281,7 +4281,15 @@ package body Sem_Eval is return Ent; else pragma Assert (Ekind (Ent) = E_Constant); - return Expr_Value_E (Constant_Value (Ent)); + + -- We may be dealing with a enumerated character type constant, so + -- handle that case here. + + if Nkind (Constant_Value (Ent)) = N_Character_Literal then + return Ent; + else + return Expr_Value_E (Constant_Value (Ent)); + end if; end if; end Expr_Value_E; |