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: __asm not recognized as gnu_asm_expression #259

Closed
2 tasks done
Cons-Cat opened this issue Apr 16, 2024 · 0 comments · Fixed by #286
Closed
2 tasks done

bug: __asm not recognized as gnu_asm_expression #259

Cons-Cat opened this issue Apr 16, 2024 · 0 comments · Fixed by #286
Labels

Comments

@Cons-Cat
Copy link

Cons-Cat commented Apr 16, 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-cpp

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

No response

Describe the bug

When parsing __asm, which is required as an alternative to asm and __asm__ by MSVC and supported by Clang, the parser fails to recognize this is a gnu_asm_expression node. This appears to be because __asm is not listed in the node-types.json file.

Steps To Reproduce/Bad Parse Tree

Parse either asm(""); or register int r asm("rax");, and compare to __asm(""); and register int r __asm("rax");.

(translation_unit
 (function_definition type: (primitive_type)
  declarator: 
   (function_declarator declarator: (identifier)
    parameters: (parameter_list ( )))
  body: 
   (compound_statement {
    (expression_statement
     (call_expression function: (identifier)
      arguments: 
       (argument_list (
        (string_literal " ")
        )))
     ;)
    (declaration
     type: (storage_class_specifier register)
     declarator: (primitive_type)
     (ERROR (identifier))
     (init_declarator declarator: (identifier)
      value: 
       (argument_list (
        (string_literal " (string_content) ")
        )))
     ;)
    })))

Expected Behavior/Parse Tree

(translation_unit
 (function_definition type: (primitive_type)
  declarator: 
   (function_declarator declarator: (identifier)
    parameters: (parameter_list ( )))
  body: 
   (compound_statement {
    (expression_statement
     (gnu_asm_expression __asm (
      assembly_code: (string_literal " ")
      ))
     ;)
    (declaration
     type: (storage_class_specifier register)
     declarator: (primitive_type) (identifier)
     (gnu_asm_expression __asm (
      assembly_code: (string_literal " (string_content) ")
      ))
     ;)
    })))

Repro

int main() {
    __asm("");
    register int r __asm("rax");
}
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