diff options
author | Justin Squirek <squirek@adacore.com> | 2021-02-27 14:16:32 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-06-16 04:43:01 -0400 |
commit | e66167fb494aa8839a8ef3fc283adc447718d514 (patch) | |
tree | 2a169583ef6612e64e8a4692afb5e48b379e9190 | |
parent | c5dc00ef38d2c3ac647726b0215888f75b0e4d9c (diff) | |
download | gcc-e66167fb494aa8839a8ef3fc283adc447718d514.zip gcc-e66167fb494aa8839a8ef3fc283adc447718d514.tar.gz gcc-e66167fb494aa8839a8ef3fc283adc447718d514.tar.bz2 |
[Ada] Mixing of positional and named entries allowed in enum rep
gcc/ada/
* sem_ch13.adb (Analyze_Enumeration_Representation_Clause): Add
check for the mixing of entries.
-rw-r--r-- | gcc/ada/sem_ch13.adb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 4fa17f1..3c3e351 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -7999,6 +7999,15 @@ package body Sem_Ch13 is ("extra parentheses surrounding aggregate not allowed", Aggr); return; + -- Reject the mixing of named and positional entries in the aggregate + + elsif Present (Expressions (Aggr)) + and then Present (Component_Associations (Aggr)) + then + Error_Msg_N ("cannot mix positional and named entries in " + & "enumeration rep clause", N); + return; + -- All tests passed, so set rep clause in place else @@ -8013,7 +8022,7 @@ package body Sem_Ch13 is Elit := First_Literal (Enumtype); - -- First the positional entries if any + -- Process positional entries if Present (Expressions (Aggr)) then Expr := First (Expressions (Aggr)); @@ -8042,11 +8051,10 @@ package body Sem_Ch13 is Next (Expr); Next (Elit); end loop; - end if; - -- Now process the named entries if present + -- Process named entries - if Present (Component_Associations (Aggr)) then + elsif Present (Component_Associations (Aggr)) then Assoc := First (Component_Associations (Aggr)); while Present (Assoc) loop Choice := First (Choices (Assoc)); |