aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-parse.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-11-28 09:11:49 +0100
committerTristan Gingold <tgingold@free.fr>2021-11-28 09:11:49 +0100
commit53a2fdc7927300233c9aec1a4772bd339f930ef5 (patch)
treeed50016c14c26db183a19beca0daed7cb2bbddcd /src/vhdl/vhdl-parse.adb
parent40fc2c2020ea9ed7e4315d0a5c6fe52e5deaf5ef (diff)
downloadghdl-53a2fdc7927300233c9aec1a4772bd339f930ef5.tar.gz
ghdl-53a2fdc7927300233c9aec1a4772bd339f930ef5.tar.bz2
ghdl-53a2fdc7927300233c9aec1a4772bd339f930ef5.zip
vhdl-parse: improve error message for empty records
Diffstat (limited to 'src/vhdl/vhdl-parse.adb')
-rw-r--r--src/vhdl/vhdl-parse.adb62
1 files changed, 33 insertions, 29 deletions
diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb
index c04df340b..e84f7d726 100644
--- a/src/vhdl/vhdl-parse.adb
+++ b/src/vhdl/vhdl-parse.adb
@@ -2825,45 +2825,49 @@ package body Vhdl.Parse is
-- Skip 'record'
Scan;
- Pos := 0;
- First := Null_Iir;
- loop
- pragma Assert (First = Null_Iir);
- -- Parse identifier_list
+ if Current_Token = Tok_End then
+ Error_Msg_Parse ("empty records are not allowed");
+ else
+ Pos := 0;
+ First := Null_Iir;
loop
- El := Create_Iir (Iir_Kind_Element_Declaration);
- Scan_Identifier (El);
+ pragma Assert (First = Null_Iir);
+ -- Parse identifier_list
+ loop
+ El := Create_Iir (Iir_Kind_Element_Declaration);
+ Scan_Identifier (El);
- Set_Parent (El, Res);
- if First = Null_Iir then
- First := El;
- end if;
+ Set_Parent (El, Res);
+ if First = Null_Iir then
+ First := El;
+ end if;
- Append_Element (El_List, El);
- Set_Element_Position (El, Pos);
- Pos := Pos + 1;
+ Append_Element (El_List, El);
+ Set_Element_Position (El, Pos);
+ Pos := Pos + 1;
- exit when Current_Token /= Tok_Comma;
+ exit when Current_Token /= Tok_Comma;
- Set_Has_Identifier_List (El, True);
+ Set_Has_Identifier_List (El, True);
- -- Skip ','
- Scan;
- end loop;
+ -- Skip ','
+ Scan;
+ end loop;
- -- Scan ':'.
- Expect_Scan (Tok_Colon);
+ -- Scan ':'.
+ Expect_Scan (Tok_Colon);
- -- Parse element subtype indication.
- Subtype_Indication := Parse_Subtype_Indication;
- Set_Subtype_Indication (First, Subtype_Indication);
+ -- Parse element subtype indication.
+ Subtype_Indication := Parse_Subtype_Indication;
+ Set_Subtype_Indication (First, Subtype_Indication);
- First := Null_Iir;
- Scan_Semi_Colon_Declaration ("element declaration");
- exit when Current_Token /= Tok_Identifier;
- end loop;
+ First := Null_Iir;
+ Scan_Semi_Colon_Declaration ("element declaration");
+ exit when Current_Token /= Tok_Identifier;
+ end loop;
- Set_Elements_Declaration_List (Res, List_To_Flist (El_List));
+ Set_Elements_Declaration_List (Res, List_To_Flist (El_List));
+ end if;
if Flag_Elocations then
Create_Elocations (Res);