From 1c37d1960adf1c30fa700b89d588182c84f8f22d Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Thu, 12 Aug 2021 10:39:21 -0400 Subject: [Ada] Crash on improper use of GNAT attribute Type_Key gcc/ada/ * sem_attr.adb (Analyze_Attribute, case Type_Key): Attribute can be applied to a formal type. * sem_ch5.adb (Analyze_Case_Statement): If Extensions_Allowed is not enabled, verify that the type of the expression is discrete. --- gcc/ada/sem_ch5.adb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'gcc/ada/sem_ch5.adb') diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 63bb80c..45d2457 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -1681,6 +1681,13 @@ package body Sem_Ch5 is Error_Msg_N ("(Ada 83) case expression cannot be of a generic type", Exp); return; + + elsif not Extensions_Allowed + and then not Is_Discrete_Type (Exp_Type) + then + Error_Msg_N + ("expression in case statement must be of a discrete_Type", Exp); + return; end if; -- If the case expression is a formal object of mode in out, then treat -- cgit v1.1