aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-06-13 08:35:53 +0200
committerTristan Gingold <tgingold@free.fr>2020-06-13 09:27:06 +0200
commit3defa9315e4414f6b28832aa2677a269a47e4acd (patch)
treedadfb6af0884b0843b78725e37d806a7afe80d5f /src
parent7cf6e5aca65df5e9f5238ac2ce65d44c06165fd2 (diff)
downloadghdl-3defa9315e4414f6b28832aa2677a269a47e4acd.tar.gz
ghdl-3defa9315e4414f6b28832aa2677a269a47e4acd.tar.bz2
ghdl-3defa9315e4414f6b28832aa2677a269a47e4acd.zip
vhdl-parse: always keep parentheses in case expression. For #1364
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/vhdl-parse.adb21
-rw-r--r--src/vhdl/vhdl-sem_stmts.adb4
2 files changed, 22 insertions, 3 deletions
diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb
index f799f380f..9e4a930a9 100644
--- a/src/vhdl/vhdl-parse.adb
+++ b/src/vhdl/vhdl-parse.adb
@@ -6810,6 +6810,21 @@ package body Vhdl.Parse is
return Res;
end Parse_Concurrent_Conditional_Signal_Assignment;
+ -- Like Parse_Expression, but keep parentheses.
+ -- Parentheses are significant in case expressions, because of
+ -- LRM02 8.8 Case Statement.
+ function Parse_Case_Expression return Iir
+ is
+ Prev_Flag : constant Boolean := Flag_Parse_Parenthesis;
+ Res : Iir;
+ begin
+ Flag_Parse_Parenthesis := True;
+ Res := Parse_Expression;
+ Flag_Parse_Parenthesis := Prev_Flag;
+
+ return Res;
+ end Parse_Case_Expression;
+
-- precond : WITH
-- postcond: next token
--
@@ -6836,7 +6851,7 @@ package body Vhdl.Parse is
Res := Create_Iir (Iir_Kind_Concurrent_Selected_Signal_Assignment);
Set_Location (Res);
- Set_Expression (Res, Parse_Expression);
+ Set_Expression (Res, Parse_Case_Expression);
Expect_Scan (Tok_Select, "'select' expected after expression");
@@ -7428,7 +7443,7 @@ package body Vhdl.Parse is
-- Skip 'case'.
Scan;
- Set_Expression (Stmt, Parse_Expression);
+ Set_Expression (Stmt, Parse_Case_Expression);
-- Skip 'is'.
Expect_Scan (Tok_Is);
@@ -9135,7 +9150,7 @@ package body Vhdl.Parse is
-- Skip 'case'.
Scan;
- Expr := Parse_Expression;
+ Expr := Parse_Case_Expression;
if Current_Token = Tok_Use then
if not AMS_Vhdl then
diff --git a/src/vhdl/vhdl-sem_stmts.adb b/src/vhdl/vhdl-sem_stmts.adb
index 691c532cf..829bf2d20 100644
--- a/src/vhdl/vhdl-sem_stmts.adb
+++ b/src/vhdl/vhdl-sem_stmts.adb
@@ -1087,6 +1087,10 @@ package body Vhdl.Sem_Stmts is
when Iir_Kind_Simple_Name
| Iir_Kind_Selected_Name =>
return Check_Odcat_Expression (Get_Named_Entity (Expr));
+ when Iir_Kind_Parenthesis_Expression =>
+ -- GHDL: not part of the list but expected to be allowed by
+ -- IR2080 and too commonly used!
+ return Check_Odcat_Expression (Get_Expression (Expr));
when others =>
Error_Msg_Sem
(+Choice, "bad form of case expression (refer to LRM 8.8)");