[Ada] Fix crash on invalid `pragma Profile`
authorGhjuvan Lacambre <lacambre@adacore.com>
Fri, 9 Oct 2020 14:36:45 +0000 (16:36 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 25 Nov 2020 13:22:24 +0000 (08:22 -0500)
gcc/ada/

* sem_prag.adb (Analyze_Pragma): Emit error on wrong argument
nkind.

gcc/ada/sem_prag.adb

index 5a2dffff0f444f9392ee70d16987af012fa48b05..eda8898bdb3c3905f549c095b85e4579919f6ae2 100644 (file)
@@ -21494,7 +21494,11 @@ package body Sem_Prag is
                Argx : constant Node_Id := Get_Pragma_Arg (Arg1);
 
             begin
-               if Chars (Argx) = Name_Ravenscar then
+               if Nkind (Argx) /= N_Identifier then
+                  Error_Msg_N
+                    ("argument of pragma Profile must be an identifier", N);
+
+               elsif Chars (Argx) = Name_Ravenscar then
                   Set_Ravenscar_Profile (Ravenscar, N);
 
                elsif Chars (Argx) = Name_Jorvik then