summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Gingold2014-01-08 21:15:58 +0100
committerTristan Gingold2014-01-08 21:15:58 +0100
commit946b468a8143e94c329ed4a7b1a085221b3f5472 (patch)
treeeda0986769ddab5f3365eaafd0f8d47471fda060
parentd0a2d9ebd5dc8aceb21e5528721cfb31d55ecad1 (diff)
downloadghdl-946b468a8143e94c329ed4a7b1a085221b3f5472.tar.gz
ghdl-946b468a8143e94c329ed4a7b1a085221b3f5472.tar.bz2
ghdl-946b468a8143e94c329ed4a7b1a085221b3f5472.zip
Rework implementation of -frelaxed-rules, add bug20767.
-rw-r--r--sem_decls.adb8
-rw-r--r--sem_names.adb32
-rw-r--r--testsuite/gna/bug20767/aggr.vhdl30
-rwxr-xr-xtestsuite/gna/bug20767/testsuite.sh14
-rw-r--r--testsuite/gna/bug20767/xilname.vhdl11
5 files changed, 77 insertions, 18 deletions
diff --git a/sem_decls.adb b/sem_decls.adb
index ffe80d5..02ca659 100644
--- a/sem_decls.adb
+++ b/sem_decls.adb
@@ -1276,9 +1276,7 @@ package body Sem_Decls is
end if;
if Deferred_Const = Null_Iir then
- if not Flag_Relaxed_Rules then
- Sem_Scopes.Add_Name (Decl);
- end if;
+ Sem_Scopes.Add_Name (Decl);
Xref_Decl (Decl);
else
Xref_Ref (Decl, Deferred_Const);
@@ -1305,10 +1303,6 @@ package body Sem_Decls is
end if;
end if;
- if Deferred_Const = Null_Iir and Flag_Relaxed_Rules then
- Sem_Scopes.Add_Name (Decl);
- end if;
-
Set_Type (Decl, Atype);
Default_Value := Eval_Expr_Check_If_Static (Default_Value, Atype);
Set_Default_Value (Decl, Default_Value);
diff --git a/sem_names.adb b/sem_names.adb
index 31de9a8..23562cb 100644
--- a/sem_names.adb
+++ b/sem_names.adb
@@ -1309,12 +1309,13 @@ package body Sem_Names is
-- If SOFT is TRUE, then no error message is reported in case of failure.
procedure Sem_Simple_Name (Name : Iir; Keep_Alias : Boolean; Soft : Boolean)
is
+ Id : constant Name_Id := Get_Identifier (Name);
Interpretation: Name_Interpretation_Type;
Res: Iir;
Res_List : Iir_List;
N : Natural;
begin
- Interpretation := Get_Interpretation (Get_Identifier (Name));
+ Interpretation := Get_Interpretation (Id);
if not Valid_Interpretation (Interpretation) then
if not Soft then
@@ -1326,21 +1327,30 @@ package body Sem_Names is
then
-- not overloaded.
Res := Get_Declaration (Interpretation);
+
+ if not Get_Visible_Flag (Res) then
+ if Flag_Relaxed_Rules
+ and then Get_Kind (Res) in Iir_Kinds_Object_Declaration
+ and then Valid_Interpretation (Get_Under_Interpretation (Id))
+ then
+ Res := Get_Declaration (Get_Under_Interpretation (Id));
+ else
+ if not Soft then
+ Error_Msg_Sem
+ (Disp_Node (Res) & " is not visible here", Name);
+ end if;
+ -- Even if a named entity was found, return an error_mark.
+ -- Indeed, the named entity found is certainly the one being
+ -- semantized, and the semantization may be uncomplete.
+ Res := Error_Mark;
+ end if;
+ end if;
+
if not Keep_Alias
and then Get_Kind (Res) = Iir_Kind_Non_Object_Alias_Declaration
then
Res := Get_Name (Res);
end if;
-
- if not Get_Visible_Flag (Res) then
- if not Soft then
- Error_Msg_Sem (Disp_Node (Res) & " is not visible here", Name);
- end if;
- -- Even if a named entity was found, return an error_mark.
- -- Indeed, the named entity found is certainly the one being
- -- semantized, and the semantization may be uncomplete.
- Res := Error_Mark;
- end if;
else
Res_List := Create_Iir_List;
N := 0;
diff --git a/testsuite/gna/bug20767/aggr.vhdl b/testsuite/gna/bug20767/aggr.vhdl
new file mode 100644
index 0000000..2fb3202
--- /dev/null
+++ b/testsuite/gna/bug20767/aggr.vhdl
@@ -0,0 +1,30 @@
+package pkg1 is
+ type int_arr is array (natural range <>) of integer;
+end pkg1;
+
+use work.pkg1.all;
+
+package pkg2 is
+ function func (a : int_arr) return natural;
+end pkg2;
+
+package body pkg2 is
+ function func (a : int_arr) return natural is
+ begin
+ return a'length;
+ end func;
+end pkg2;
+
+entity tb is
+end tb;
+
+use work.pkg2.all;
+
+architecture behav of tb is
+begin
+ process
+ constant c : natural := func (a => (1, 2, 3));
+ begin
+ wait;
+ end process;
+end behav;
diff --git a/testsuite/gna/bug20767/testsuite.sh b/testsuite/gna/bug20767/testsuite.sh
new file mode 100755
index 0000000..081f92f
--- /dev/null
+++ b/testsuite/gna/bug20767/testsuite.sh
@@ -0,0 +1,14 @@
+#! /bin/sh
+
+. ../../testenv.sh
+
+analyze_failure xilname.vhdl
+
+analyze -frelaxed-rules xilname.vhdl
+
+analyze aggr.vhdl
+elab_simulate tb
+
+clean
+
+echo "Test successful"
diff --git a/testsuite/gna/bug20767/xilname.vhdl b/testsuite/gna/bug20767/xilname.vhdl
new file mode 100644
index 0000000..0b0c36a
--- /dev/null
+++ b/testsuite/gna/bug20767/xilname.vhdl
@@ -0,0 +1,11 @@
+package xilnames is
+
+ type state is (state1, state2, state3);
+
+end xilnames;
+
+use work.xilnames.all;
+package xilname1 is
+
+ constant state1 : state := state1;
+end xilname1;