This fixes an error recovery issue, whereby the compilation of a string
concatenation with an illegal character constant hangs.
gcc/ada/
PR ada/120854
* sem_eval.adb (Get_String_Val): Be prepared for an integer literal
after a serious error is detected, and raise PE on other nodes.
gcc/testsuite/
* gnat.dg/concat6.adb: New test.
begin
if Nkind (N) in N_String_Literal | N_Character_Literal then
return N;
- else
- pragma Assert (Is_Entity_Name (N));
+ elsif Is_Entity_Name (N) then
return Get_String_Val (Constant_Value (Entity (N)));
+ elsif Nkind (N) = N_Integer_Literal then
+ pragma Assert (Serious_Errors_Detected /= 0);
+ return
+ Make_Character_Literal (Sloc (N),
+ Chars => Error_Name,
+ Char_Literal_Value => Intval (N));
+ else
+ raise Program_Error;
end if;
end Get_String_Val;
--- /dev/null
+-- { dg-do compile }
+
+with Ada.Text_IO; use Ada.Text_IO;
+
+procedure Concat6 is
+ C : constant character := 16#00#; -- { dg-error "expected type|found type" }
+begin
+ Put_Line ("Test " & C);
+end;