aboutsummaryrefslogtreecommitdiffstats
path: root/sem_expr.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2013-12-31 19:01:48 +0100
committerTristan Gingold <tgingold@free.fr>2013-12-31 19:01:48 +0100
commit5f41fdc72fccd7169dc812c8690e82222ae1aca1 (patch)
tree2e2cddb257b071ec30b79c0672e2320f5421468d /sem_expr.adb
parent2fe0a5359e1bdf6dfdab20bea121db8f4e54ffe9 (diff)
downloadghdl-5f41fdc72fccd7169dc812c8690e82222ae1aca1.tar.gz
ghdl-5f41fdc72fccd7169dc812c8690e82222ae1aca1.tar.bz2
ghdl-5f41fdc72fccd7169dc812c8690e82222ae1aca1.zip
Fix bug21274.
WIP for VHDL08.
Diffstat (limited to 'sem_expr.adb')
-rw-r--r--sem_expr.adb50
1 files changed, 50 insertions, 0 deletions
diff --git a/sem_expr.adb b/sem_expr.adb
index 4ee643665..a9e592b86 100644
--- a/sem_expr.adb
+++ b/sem_expr.adb
@@ -4116,4 +4116,54 @@ package body Sem_Expr is
return Sem_Expression_Ov (Expr1, Res);
end Sem_Case_Expression;
+ function Sem_Condition (Cond : Iir) return Iir
+ is
+ Res : Iir;
+ Op : Iir;
+ begin
+ if Vhdl_Std < Vhdl_08 then
+ Res := Sem_Expression (Cond, Boolean_Type_Definition);
+
+ Check_Read (Res);
+ return Res;
+ else
+ -- LRM08 9.2.9
+ -- If, without overload resolution (see 12.5), the expression is
+ -- of type BOOLEAN defined in package STANDARD, or if, assuming a
+ -- rule requiring the expression to be of type BOOLEAN defined in
+ -- package STANDARD, overload resolution can determine at least one
+ -- interpretation of each constituent of the innermost complete
+ -- context including the expression, then the condition operator is
+ -- not applied.
+
+ -- GHDL: what does the second alternative mean ? Any example ?
+
+ Res := Sem_Expression_Ov (Cond, Null_Iir);
+
+ if Res = Null_Iir then
+ return Res;
+ end if;
+
+ if not Is_Overloaded (Res)
+ and then Get_Type (Res) = Boolean_Type_Definition
+ then
+ Check_Read (Res);
+ return Res;
+ end if;
+
+ -- LRM08 9.2.9
+ -- Otherwise, the condition operator is implicitely applied, and the
+ -- type of the expresion with the implicit application shall be
+ -- BOOLEAN defined in package STANDARD.
+
+ Op := Create_Iir (Iir_Kind_Condition_Operator);
+ Location_Copy (Op, Res);
+ Set_Operand (Op, Res);
+
+ Res := Sem_Operator (Op, Boolean_Type_Definition, 1);
+ Check_Read (Res);
+ return Res;
+ end if;
+ end Sem_Condition;
+
end Sem_Expr;