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 when initializing struct array #228

Closed
2 tasks done
ashamedbit opened this issue Sep 7, 2024 · 1 comment
Closed
2 tasks done

bug: Error nodes when initializing struct array #228

ashamedbit opened this issue Sep 7, 2024 · 1 comment
Labels

Comments

@ashamedbit
Copy link

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

Parsing error when a struct array is defined ( whose values are populated by other function calls)

Steps To Reproduce/Bad Parse Tree

translation_unit [0, 0] - [13, 0]
struct_specifier [0, 0] - [2, 1]
name: type_identifier [0, 7] - [0, 18]
body: field_declaration_list [0, 19] - [2, 1]
field_declaration [1, 1] - [1, 10]
type: primitive_type [1, 1] - [1, 4]
declarator: field_identifier [1, 5] - [1, 9]
struct_specifier [4, 0] - [7, 1]
name: type_identifier [4, 7] - [4, 19]
body: field_declaration_list [4, 20] - [7, 1]
field_declaration [5, 1] - [5, 8]
type: primitive_type [5, 1] - [5, 4]
declarator: field_identifier [5, 5] - [5, 7]
field_declaration [6, 1] - [6, 10]
type: primitive_type [6, 1] - [6, 4]
declarator: field_identifier [6, 5] - [6, 9]
declaration [8, 0] - [10, 2]
storage_class_specifier [8, 0] - [8, 6]
type_qualifier [8, 7] - [8, 12]
type: struct_specifier [8, 13] - [8, 31]
name: type_identifier [8, 20] - [8, 31]
declarator: init_declarator [8, 32] - [10, 1]
declarator: array_declarator [8, 32] - [8, 47]
declarator: identifier [8, 32] - [8, 45]
value: initializer_list [8, 50] - [10, 1]
initializer_list [9, 1] - [9, 92]
cast_expression [9, 3] - [9, 37]
type: type_descriptor [9, 4] - [9, 18]
type: sized_type_specifier [9, 4] - [9, 18]
value: parenthesized_expression [9, 19] - [9, 37]
binary_expression [9, 20] - [9, 36]
left: binary_expression [9, 20] - [9, 30]
left: number_literal [9, 20] - [9, 24]
right: number_literal [9, 26] - [9, 30]
right: number_literal [9, 32] - [9, 36]
number_literal [9, 39] - [9, 40]
number_literal [9, 42] - [9, 43]
call_expression [9, 45] - [9, 90]
function: identifier [9, 45] - [9, 63]
arguments: argument_list [9, 63] - [9, 90]
ERROR [9, 64] - [9, 70]
identifier [9, 64] - [9, 70]
identifier [9, 71] - [9, 83]
identifier [9, 85] - [9, 89]

Expected Behavior/Parse Tree

No error nodes on parsing the provided initialized struct array. It is compilable C code.

Repro

struct sock_filter {
 int code;
};

struct seccomp_data {
 int nr;
 int arch;
};
static const struct sock_filter preauth_insns[] = {
 { (unsigned short)(0x00 +0x00 +0x20), 0, 0, __builtin_offsetof(struct seccomp_data, arch) },
};
@ashamedbit ashamedbit added the bug label Sep 7, 2024
@ashamedbit ashamedbit changed the title bug: Misparsing when initializing struct array bug: Error nodes when initializing struct array Sep 7, 2024
@ObserverOfTime
Copy link
Member

Same underlying issue as #229.

@ObserverOfTime ObserverOfTime closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants