Issue#1415: Fixing classification of + and - when used with predefined attributes. (#1417)

This commit is contained in:
Jeremiah Leary 2025-06-29 11:59:49 -05:00 committed by GitHub
parent 78b7cf3bb6
commit 4c0120a5a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 1 deletions

View File

@ -126,3 +126,25 @@ begin
a <= -1 + 10;
end architecture RTL;
-- test attributes
architecture rtl of fifo is
begin
-- passing
a <= b'left + type_bits;
a <= b'right - type_bits;
a <= b'left / type_bits;
a <= b'right * type_bits;
a <= b'left ** type_bits;
-- failing
a <= b'left + type_bits;
a <= b'right - type_bits;
a <= b'left / type_bits;
a <= b'right * type_bits;
a <= b'left ** type_bits;
end architecture rtl;

View File

@ -126,3 +126,25 @@ begin
a <= -1 + 10;
end architecture RTL;
-- test attributes
architecture rtl of fifo is
begin
-- passing
a <= b'left + type_bits;
a <= b'right - type_bits;
a <= b'left / type_bits;
a <= b'right * type_bits;
a <= b'left ** type_bits;
-- failing
a <= b'left+type_bits;
a <= b'right-type_bits;
a <= b'left/type_bits;
a <= b'right*type_bits;
a <= b'left**type_bits;
end architecture rtl;

View File

@ -41,6 +41,7 @@ class test_whitespace_rule(unittest.TestCase):
lExpected.extend(range(100, 105))
lExpected.extend(range(106, 111))
lExpected.extend(range(112, 117))
lExpected.extend(range(144, 149))
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))

View File

@ -682,7 +682,9 @@ def remove_beginning_of_file_tokens(lTokens):
def assign_token_of_addition_operator_that_can_be_either_unary_and_binary(iToken, lTokens, sValue, dTokenTypes):
if (
if utils.are_previous_consecutive_token_types_ignoring_whitespace([predefined_attribute.keyword], iToken - 1, lTokens):
lTokens[iToken] = dTokenTypes["binary"](sValue)
elif (
utils.are_previous_consecutive_token_types_ignoring_whitespace([parser.open_parenthesis], iToken - 1, lTokens)
or utils.are_previous_consecutive_token_types_ignoring_whitespace([parser.keyword], iToken - 1, lTokens)
or utils.are_previous_consecutive_token_types_ignoring_whitespace([parser.assignment], iToken - 1, lTokens)