aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-sem_names.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-12-08 06:23:21 +0100
committerTristan Gingold <tgingold@free.fr>2020-12-08 19:32:22 +0100
commit07a7f419eea89b3ab901642291650f49dfb24a36 (patch)
tree9b822b1730535ebcc5b5e26492aa4d86e0b4ab1d /src/vhdl/vhdl-sem_names.adb
parentebba3c77dc798f2e20ad6ba8a560a569faf1526b (diff)
downloadghdl-07a7f419eea89b3ab901642291650f49dfb24a36.tar.gz
ghdl-07a7f419eea89b3ab901642291650f49dfb24a36.tar.bz2
ghdl-07a7f419eea89b3ab901642291650f49dfb24a36.zip
vhdl: handle locally static attributes on entity/architecture/configurations
Attributes of entity/architecture/configurations are expected to be locally static so that they can be referenced from outside (so on the non-instantiated entity). But many designs break this assumption. In relaxed mode, non-locally static attributes are allowed but now cannot be referenced outside the entity. Locally static attributes can be referenced from outside. Fix #1528
Diffstat (limited to 'src/vhdl/vhdl-sem_names.adb')
-rw-r--r--src/vhdl/vhdl-sem_names.adb11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/vhdl/vhdl-sem_names.adb b/src/vhdl/vhdl-sem_names.adb
index 636979880..17db8ba99 100644
--- a/src/vhdl/vhdl-sem_names.adb
+++ b/src/vhdl/vhdl-sem_names.adb
@@ -3315,7 +3315,7 @@ package body Vhdl.Sem_Names is
| Iir_Kind_Unit_Declaration
| Iir_Kind_Component_Declaration
| Iir_Kinds_Library_Unit =>
- -- FIXME: to complete
+ -- FIXME: complete
null;
when Iir_Kinds_Sequential_Statement
| Iir_Kinds_Concurrent_Statement =>
@@ -3341,6 +3341,15 @@ package body Vhdl.Sem_Names is
Xref_Ref (Attr, Value);
+ if Get_Static_Attribute_Flag (Get_Attribute_Specification (Value))
+ and then not Get_Is_Within_Flag (Prefix)
+ and then Get_Expr_Staticness (Value) /= Locally
+ then
+ Error_Msg_Sem
+ (+Attr, "non-locally static attribute cannot be referenced here");
+ return Error_Mark;
+ end if;
+
return Value;
end Sem_User_Attribute;