Skip to content

Commit

Permalink
Deprecate &bit-order on bit ranges.
Browse files Browse the repository at this point in the history
This does not appear to have any effect and allowing it may be
confusing to users. Deprecate it with the idea of eventual
removal.
  • Loading branch information
awelzel committed Jan 29, 2024
1 parent 7a92203 commit 755c45c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions spicy/toolchain/src/compiler/visitors/validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,15 @@ struct VisitorPost : public hilti::visitor::PreOrder<void, VisitorPost>, public
error(fmt("'%s' can be used at most once", a), p);
}
}

if ( auto t = f.itemType().tryAs<type::Bitfield>() ) {
for ( const auto& b : t->bits() ) {
if ( AttributeSet::has(b.attributes(), "&bit-order") )
hilti::logger().deprecated(fmt("&bit-order on bitfield item '%s' has no effect and is deprecated",
b.id()),
b.meta().location());
}
}
}

void operator()(const spicy::type::unit::item::UnresolvedField& u, position_t p) {
Expand Down
3 changes: 3 additions & 0 deletions tests/Baseline/spicy.types.bitfield.bit-bitorder/output
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[warning] <...>/bit-bitorder.spicy:14:5-14:56: &bit-order on bitfield item 'x1015_msb0' has no effect and is deprecated
[warning] <...>/bit-bitorder.spicy:15:5-15:56: &bit-order on bitfield item 'x1015_lsb0' has no effect and is deprecated
17 changes: 17 additions & 0 deletions tests/spicy/types/bitfield/bit-bitorder.spicy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @TEST-EXEC: spicyc -p -o /dev/null %INPUT 2>output
# @TEST-EXEC: btest-diff output
#
# @TEST-DOC: Test deprecated "&bit-order" attribute on bits emits deprecation warning.

module Mini;

import spicy;

public type X = unit {
be16_lsb0: bitfield(16) {
x0: 0;
x1015: 10..15;
x1015_msb0: 10..15 &bit-order=spicy::BitOrder::MSB0;
x1015_lsb0: 10..15 &bit-order=spicy::BitOrder::LSB0;
};
};

0 comments on commit 755c45c

Please sign in to comment.