[gcc r11-5336] [Ada] Fix crash on invalid `pragma Profile`

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Wed Nov 25 13:27:35 GMT 2020


https://gcc.gnu.org/g:193040a071b1170e5e22b7371d81b880f69aeae1

commit r11-5336-g193040a071b1170e5e22b7371d81b880f69aeae1
Author: Ghjuvan Lacambre <lacambre@adacore.com>
Date:   Fri Oct 9 16:36:45 2020 +0200

    [Ada] Fix crash on invalid `pragma Profile`
    
    gcc/ada/
    
            * sem_prag.adb (Analyze_Pragma): Emit error on wrong argument
            nkind.

Diff:
---
 gcc/ada/sem_prag.adb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 5a2dffff0f4..eda8898bdb3 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -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


More information about the Gcc-cvs mailing list