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

Fix parsing of friend simple-type-specifier #681

Merged
merged 2 commits into from
May 21, 2023

Conversation

HGuillemet
Copy link
Contributor

class B {
  friend bool operator<( B x, B y) { return true; }
}

Fails to parse with an Unexpected token 'EOF'.

In group, friend, not followed by class/struct/union, is assumed to be a C++11 friendship declaration with a simple-type-specifier.
bool is skipped, probably taken for some attributes, and a call to type on operator < throws the exception because it looks for template arguments until end of file.
This PR proposes a fix by never skipping the token after friend, so type will parse what is expected to be a type (bool in this case, instead of operator). I think that what needs to be skipped (attributes ?) only concerns non-friend declaration.

No changes in parsing for existing presets, but in Pytorch, where an addition declaration (ptr_to_first_element) is added in global.java. Without the PR, parsing of List.h ends prematurely because of a friend bool operator<.

Allows to parse intrusive_ptr.h in Pytorch.

@saudet saudet merged commit bf5e5da into bytedeco:master May 21, 2023
@HGuillemet HGuillemet deleted the fix_friend_simple_type branch May 21, 2023 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants