aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-09-18 05:29:29 +0200
committerTristan Gingold <tgingold@free.fr>2018-09-18 05:29:29 +0200
commit262c190bfdca756a989ca31b702700ec34d335fc (patch)
treeb6e2e09c413359713dc5646e40ae92fd00866722 /src/vhdl
parent0f7bdd76d45a453b226ac58ae289bd21cfeb62c2 (diff)
downloadghdl-262c190bfdca756a989ca31b702700ec34d335fc.tar.gz
ghdl-262c190bfdca756a989ca31b702700ec34d335fc.tar.bz2
ghdl-262c190bfdca756a989ca31b702700ec34d335fc.zip
Adjust -Whide (disabled in some useless cases).
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/errorout.ads2
-rw-r--r--src/vhdl/sem_assocs.adb10
-rw-r--r--src/vhdl/sem_scopes.adb29
3 files changed, 38 insertions, 3 deletions
diff --git a/src/vhdl/errorout.ads b/src/vhdl/errorout.ads
index ff7c54ada..4a3b6fdf7 100644
--- a/src/vhdl/errorout.ads
+++ b/src/vhdl/errorout.ads
@@ -344,7 +344,7 @@ private
Default_Warnings : constant Warnings_Setting :=
(Warnid_Binding | Warnid_Library | Warnid_Shared
- | Warnid_Pure | Warnid_Specs
+ | Warnid_Pure | Warnid_Specs | Warnid_Hide
| Warnid_Port => (Enabled => True, Error => False),
others => (Enabled => False, Error => False));
end Errorout;
diff --git a/src/vhdl/sem_assocs.adb b/src/vhdl/sem_assocs.adb
index 961ec3c5f..33b1f33b1 100644
--- a/src/vhdl/sem_assocs.adb
+++ b/src/vhdl/sem_assocs.adb
@@ -2062,6 +2062,9 @@ package body Sem_Assocs is
Assoc : Iir;
Inter : Iir;
+ -- True if -Whide is enabled (save the state).
+ Warn_Hide_Enabled : Boolean;
+
type Param_Assoc_Type is (None, Open, Individual, Whole);
type Assoc_Array is array (Natural range <>) of Param_Assoc_Type;
@@ -2150,8 +2153,15 @@ package body Sem_Assocs is
-- declaration and that would otherwise be directly visible is
-- hidden.
Sem_Scopes.Open_Declarative_Region;
+
+ -- Do not warn about hidding here, way to common, way useless.
+ Warn_Hide_Enabled := Is_Warning_Enabled (Warnid_Hide);
+ Enable_Warning (Warnid_Hide, False);
+
Sem_Scopes.Add_Declarations_From_Interface_Chain (Interface_Chain);
+ Enable_Warning (Warnid_Hide, Warn_Hide_Enabled);
+
First_Named_Assoc := Assoc;
loop
if Formal = Null_Iir then
diff --git a/src/vhdl/sem_scopes.adb b/src/vhdl/sem_scopes.adb
index 17e3847ed..417eecf5c 100644
--- a/src/vhdl/sem_scopes.adb
+++ b/src/vhdl/sem_scopes.adb
@@ -404,6 +404,28 @@ package body Sem_Scopes is
return Inter >= Current_Region_Start;
end Is_In_Current_Declarative_Region;
+ -- Emit a warning when DECL hides PREV_DECL.
+ procedure Warning_Hide (Decl : Iir; Prev_Decl : Iir)
+ is
+ begin
+ if Get_Kind (Decl) in Iir_Kinds_Interface_Declaration
+ and then Get_Kind (Get_Parent (Decl)) = Iir_Kind_Component_Declaration
+ then
+ -- Do not warn when an interface in a component hides a declaration.
+ -- This is a common case (eg: in testbenches), and there is no real
+ -- hiding.
+ return;
+ end if;
+
+ if Decl = Prev_Decl then
+ -- Can happen in configuration. No real hidding.
+ return;
+ end if;
+
+ Warning_Msg_Sem (Warnid_Hide, +Decl,
+ "declaration of %i hides %n", (+Decl, +Prev_Decl));
+ end Warning_Hide;
+
-- Add interpretation DECL to the identifier of DECL.
-- POTENTIALLY is true if the identifier comes from a use clause.
procedure Add_Name (Decl : Iir; Ident : Name_Id; Potentially : Boolean)
@@ -919,8 +941,11 @@ package body Sem_Scopes is
-- declarative region if the inner region contains an homograph
-- of this declaration; the outer declaration is the hidden
-- within the immediate scope of the inner homograph.
- Warning_Msg_Sem (Warnid_Hide, +Decl,
- "declaration of %i hides %n", (+Decl, +Current_Decl));
+ if Is_Warning_Enabled (Warnid_Hide)
+ and then not Is_Potentially_Visible (Current_Inter)
+ then
+ Warning_Hide (Decl, Current_Decl);
+ end if;
Add_New_Interpretation (True);
end Add_Name;