aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-parse.adb
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/vhdl/vhdl-parse.adb
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/vhdl/vhdl-parse.adb')
-rw-r--r--src/vhdl/vhdl-parse.adb21
1 files changed, 18 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