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
+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
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;
+2019-07-09 Justin Squirek <squirek@adacore.com>
+
+ * gnat.dg/image1.adb: New testcase.
+
2019-07-09 Javier Miranda <miranda@adacore.com>
* gnat.dg/rep_clause8.adb: New testcase.
--- /dev/null
+-- { dg-do run }
+
+with Ada.Text_IO; use Ada.Text_IO;
+with Ada.Characters.Latin_1;
+
+procedure Image1 is
+ Str : String := Ada.Characters.Latin_1.LF'Img;
+begin
+ if Str /= "LF" then
+ raise Program_Error;
+ end if;
+end Image1;