Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Error nodes on asm code using numbers from array #232

Closed
2 tasks done
ashamedbit opened this issue Sep 7, 2024 · 0 comments · Fixed by #234
Closed
2 tasks done

bug: Error nodes on asm code using numbers from array #232

ashamedbit opened this issue Sep 7, 2024 · 0 comments · Fixed by #234
Labels

Comments

@ashamedbit
Copy link

ashamedbit commented Sep 7, 2024

Did you check existing issues?

  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues of tree-sitter-c

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

0.23.0

Describe the bug

When treesitter parses asm code that is populated using numbers from an array it leads to error nodes. Relevant code shown below.

Steps To Reproduce/Bad Parse Tree

translation_unit [0, 0] - [6, 0]
function_definition [0, 0] - [5, 1]
type: primitive_type [0, 0] - [0, 3]
declarator: function_declarator [0, 4] - [0, 10]
declarator: identifier [0, 4] - [0, 8]
parameters: parameter_list [0, 8] - [0, 10]
body: compound_statement [0, 10] - [5, 1]
declaration [1, 3] - [1, 21]
type: sized_type_specifier [1, 3] - [1, 16]
declarator: pointer_declarator [1, 17] - [1, 20]
declarator: identifier [1, 18] - [1, 20]
declaration [2, 3] - [2, 24]
type: sized_type_specifier [2, 3] - [2, 16]
declarator: init_declarator [2, 17] - [2, 23]
declarator: identifier [2, 17] - [2, 19]
value: number_literal [2, 22] - [2, 23]
declaration [3, 3] - [3, 31]
storage_class_specifier [3, 3] - [3, 11]
type: sized_type_specifier [3, 12] - [3, 25]
declarator: identifier [3, 26] - [3, 30]
expression_statement [4, 3] - [4, 83]
gnu_asm_expression [4, 3] - [4, 82]
assembly_code: string_literal [4, 8] - [4, 32]
string_content [4, 9] - [4, 31]
output_operands: gnu_asm_output_operand_list [4, 33] - [4, 57]
operand: gnu_asm_output_operand [4, 35] - [4, 46]
constraint: string_literal [4, 35] - [4, 39]
string_content [4, 36] - [4, 38]
value: identifier [4, 40] - [4, 42]
ERROR [4, 42] - [4, 45]
number_literal [4, 43] - [4, 44]
operand: gnu_asm_output_operand [4, 47] - [4, 57]
constraint: string_literal [4, 47] - [4, 51]
string_content [4, 48] - [4, 50]
value: identifier [4, 52] - [4, 56]
input_operands: gnu_asm_input_operand_list [4, 58] - [4, 74]
operand: gnu_asm_input_operand [4, 60] - [4, 67]
constraint: string_literal [4, 60] - [4, 63]
string_content [4, 61] - [4, 62]
value: identifier [4, 64] - [4, 66]
operand: gnu_asm_input_operand [4, 68] - [4, 74]
constraint: string_literal [4, 68] - [4, 71]
string_content [4, 69] - [4, 70]
value: number_literal [4, 72] - [4, 73]
clobbers: gnu_asm_clobber_list [4, 75] - [4, 81]
register: string_literal [4, 77] - [4, 81]
string_content [4, 78] - [4, 80]

Expected Behavior/Parse Tree

Parsed tree contains error nodes even though the code is compilable.

Repro

int main(){
   unsigned long *rp;
   unsigned long c1 = 0;
   register unsigned long high;
   asm ("addq %2,%0; adcq %3,%1" : "+m"(rp[0]),"+d"(high) : "r"(c1),"g"(0) : "cc");
}
@ashamedbit ashamedbit added the bug label Sep 7, 2024
@amaanq amaanq mentioned this issue Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant