binPAC : support for more than one &requires attribute on a field

Description

In the binPAC grammar, nothing prevents from applying many &requires attributes to the same field.
However, in such a case the generated C++ code is incorrect.

type MyArray = record {
a: uint16 &requires(c) &requires(d);
b: uint16;
} &let {
c : uint16 = b * 2;
d : uint16 = b * 3;
};

The generated code is :
// Parse "a"
// Parse "b"
b_ = FixByteOrder(t_byteorder, *((uint16 const *) ((t_begin_of_data + 2))));
// Evaluate 'let' and 'withinput' fields
d_ = b() * 3;
a_ = FixByteOrder(t_byteorder, *((uint16 const *) (t_begin_of_data)));
// Evaluate 'let' and 'withinput' fields

// Evaluate 'let' and 'withinput' fields
c_ = b() * 2;

In pac_types.cc, only the last &requires attribute is kept, the previous ones are forgotten.
Replacing attr_requires_ of type Expr with a ListExpr solves the problem and produces the (expected) C++ code below :

// Parse "a"
// Parse "b"
b_ = FixByteOrder(t_byteorder, *((uint16 const *) ((t_begin_of_data + 2))));
// Evaluate 'let' and 'withinput' fields
c_ = b() * 2;
d_ = b() * 3;
a_ = FixByteOrder(t_byteorder, *((uint16 const *) (t_begin_of_data)));

I have written a small patch for this problem. I can submit it if you agree with my changes.

Environment

None

Assignee

Johanna Amann

Reporter

Fran├žois

Labels

None

External issue ID

None

Components

Fix versions

Affects versions

Priority

Normal
Configure