Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dcabdb05 authored by Myles Watson's avatar Myles Watson
Browse files

PDL: Fix shadowed struct members

Structs with shadowed members would ignore the builder parameter.

Bug: 303449758
Test: atest bluetooth_packet_parser_test
Change-Id: Ic197074f0d9521a9c3d50b71a82ab4053fdb45ce
parent 3625a1ce
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -484,7 +484,6 @@ cc_test {
        },
    },
    min_sdk_version: "30",
    cflags: ["-Wno-unused-parameter"],
}

cc_defaults {
+1 −1
Original line number Diff line number Diff line
@@ -357,7 +357,7 @@ void StructDef::GenConstructor(std::ostream& s) const {
  // Initialize remaining fields.
  add_comma = parent_ != nullptr;
  for (auto const& field : params) {
    if (parent_params.GetField(field->GetName()) != nullptr) {
    if (fields_.GetField(field->GetName()) == nullptr) {
      continue;
    }
    if (add_comma) {
+9 −0
Original line number Diff line number Diff line
@@ -1988,6 +1988,15 @@ TEST(GeneratedPacketTest, testCreateOptional) {
  ASSERT_TRUE(grandchild_view.has_value());
}

TEST(GeneratedPacketTest, testStructWithShadowedNames) {
  uint32_t four_bytes = 0x01020304;
  StructType struct_type = StructType::TWO_BYTE;
  auto ebs = AtLeastFourByteStruct(four_bytes, struct_type);

  ASSERT_EQ(ebs.four_bytes_, four_bytes);
  ASSERT_EQ(ebs.struct_type_, struct_type);
}

}  // namespace parser
}  // namespace packet
}  // namespace bluetooth