aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-sem_expr.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-06-12 08:33:24 +0200
committerTristan Gingold <tgingold@free.fr>2020-06-12 22:16:43 +0200
commit80b888c83fd39c3312061ff908892af140e4b800 (patch)
tree6c7df7388fe1ef1fbca73d79b1643ecd8d551df7 /src/vhdl/vhdl-sem_expr.adb
parent8a002fd0af7530f2fe91d6b663362c02e34950b8 (diff)
downloadghdl-80b888c83fd39c3312061ff908892af140e4b800.tar.gz
ghdl-80b888c83fd39c3312061ff908892af140e4b800.tar.bz2
ghdl-80b888c83fd39c3312061ff908892af140e4b800.zip
vhdl-sem_expr: use -frelaxed for parentheses aggregates. For #1364
Diffstat (limited to 'src/vhdl/vhdl-sem_expr.adb')
-rw-r--r--src/vhdl/vhdl-sem_expr.adb53
1 files changed, 39 insertions, 14 deletions
diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb
index a801afdbe..f80a8bc2e 100644
--- a/src/vhdl/vhdl-sem_expr.adb
+++ b/src/vhdl/vhdl-sem_expr.adb
@@ -4624,6 +4624,21 @@ package body Vhdl.Sem_Expr is
end if;
end Sem_Dyadic_Operator;
+ function Sem_Parenthesis_Expression (Expr : Iir; Atype: Iir) return Iir
+ is
+ Sub_Expr : Iir;
+ begin
+ Sub_Expr := Get_Expression (Expr);
+ Sub_Expr := Sem_Expression_Ov (Sub_Expr, Atype);
+ if Sub_Expr = Null_Iir then
+ return Null_Iir;
+ end if;
+ Set_Expression (Expr, Sub_Expr);
+ Set_Type (Expr, Get_Type (Sub_Expr));
+ Set_Expr_Staticness (Expr, Get_Expr_Staticness (Sub_Expr));
+ return Expr;
+ end Sem_Parenthesis_Expression;
+
-- Set semantic to EXPR.
-- Replace simple_name with the referenced node,
-- Set type to nodes,
@@ -4800,19 +4815,7 @@ package body Vhdl.Sem_Expr is
end if;
when Iir_Kind_Parenthesis_Expression =>
- declare
- Sub_Expr : Iir;
- begin
- Sub_Expr := Get_Expression (Expr);
- Sub_Expr := Sem_Expression_Ov (Sub_Expr, A_Type1);
- if Sub_Expr = Null_Iir then
- return Null_Iir;
- end if;
- Set_Expression (Expr, Sub_Expr);
- Set_Type (Expr, Get_Type (Sub_Expr));
- Set_Expr_Staticness (Expr, Get_Expr_Staticness (Sub_Expr));
- return Expr;
- end;
+ return Sem_Parenthesis_Expression (Expr, A_Type1);
when Iir_Kind_Qualified_Expression =>
return Sem_Qualified_Expression (Expr, A_Type);
@@ -5144,7 +5147,7 @@ package body Vhdl.Sem_Expr is
Ntype : Iir;
begin
Sub_Expr := Get_Expression (Expr);
- if Atype_Defined then
+ if Atype_Defined and then not Flag_Relaxed_Rules then
-- Very important: loose the subtype due to
-- LRM93 7.3.2.2 Array aggregate.
Ntype := Get_Base_Type (Atype);
@@ -5305,6 +5308,28 @@ package body Vhdl.Sem_Expr is
Sem_String_Literal (Expr);
return Expr;
end if;
+ when Iir_Kind_Parenthesis_Expression =>
+ if Flag_Relaxed_Rules then
+ -- With -frelaxed, consider parentheses as a no-op.
+ -- The difference is significant for aggregates with 'others'
+ -- choice.
+ declare
+ Sub_Expr : Iir;
+ begin
+ Sub_Expr := Get_Expression (Expr);
+ Sub_Expr := Sem_Expression (Sub_Expr, A_Type);
+ if Sub_Expr = Null_Iir then
+ return Null_Iir;
+ end if;
+ Set_Expression (Expr, Sub_Expr);
+ Set_Type (Expr, Get_Type (Sub_Expr));
+ Set_Expr_Staticness (Expr, Get_Expr_Staticness (Sub_Expr));
+ return Expr;
+ end;
+ else
+ -- Loose the subtype, use the type.
+ Res := Sem_Parenthesis_Expression (Expr, A_Type1);
+ end if;
when others =>
Res := Sem_Expression_Ov (Expr, A_Type1);
end case;