mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-29 01:03:29 +02:00
vhdlpp: Improved type matching rules.
This commit is contained in:
@@ -350,8 +350,10 @@ const VType* ExpBinary::probe_type(Entity*ent, ScopeBase*scope) const
|
||||
if (t2 == 0)
|
||||
return t1;
|
||||
|
||||
if (t1 == t2)
|
||||
if (t1->type_match(t2))
|
||||
return t1;
|
||||
if (t2->type_match(t1))
|
||||
return t2;
|
||||
|
||||
if (const VType*tb = resolve_operand_types_(t1, t2))
|
||||
return tb;
|
||||
|
||||
@@ -295,6 +295,9 @@ class VTypeRangeConst : public VTypeRange {
|
||||
return new VTypeRangeConst(base_type()->clone(), start_, end_);
|
||||
}
|
||||
|
||||
int64_t start() const { return start_; }
|
||||
int64_t end() const { return end_; }
|
||||
|
||||
void write_to_stream(std::ostream&fd) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -53,6 +53,13 @@ bool VTypePrimitive::type_match(const VType*that) const
|
||||
(that_type == NATURAL || that_type == INTEGER));
|
||||
}
|
||||
|
||||
if(const VTypeRangeConst*range = dynamic_cast<const VTypeRangeConst*>(that)) {
|
||||
if (type_ == INTEGER)
|
||||
return true;
|
||||
if (type_ == NATURAL && range->start() >= 0 && range->end() >= 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user