Skip to content

Commit

Permalink
Relax constraints for valid types of struct expressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
fruffy committed Nov 14, 2023
1 parent 39cb323 commit 9052ad1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ir/expression.def
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,20 @@ class P4ListExpression : BaseListExpression {

/// An expression that evaluates to a struct.
class StructExpression : Expression {
/// The struct or header type that is being intialized.
/// The struct or header type that is being initialized.
/// May only be known after type checking; so it can be nullptr.
NullOK Type structType;

/// Allow the struct expression to have a Type_StructLike type.
optional bool structOkay = false;

inline IndexedVector<NamedExpression> components;
validate {
components.check_null(); components.validate();
BUG_CHECK(structType == nullptr || structType->is<IR::Type_Name>() ||
structType->is<IR::Type_Specialized>(),
"%1%: unexpected struct type", this);
structType->is<IR::Type_Specialized>()
|| (structOkay && structType->is<IR::Type_StructLike>()),
"%1%: unexpected struct type %2%", this, structType->node_type_name());
}
size_t size() const { return components.size(); }
NamedExpression getField(cstring name) const {
Expand Down

0 comments on commit 9052ad1

Please sign in to comment.