Skip to content

Fixed #11745 (Fix AST for 'new type..[..]{..}')#5118

Merged
danmar merged 2 commits into
mainfrom
ast-11745
Jun 5, 2023
Merged

Fixed #11745 (Fix AST for 'new type..[..]{..}')#5118
danmar merged 2 commits into
mainfrom
ast-11745

Conversation

@danmar
Copy link
Copy Markdown
Collaborator

@danmar danmar commented Jun 5, 2023

No description provided.

Comment thread lib/tokenlist.cpp
break;
prev = prev->link();
}
if (prev->str() == "new")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a check for cpp?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! I'll fix

Comment thread lib/tokenlist.cpp
if (Token::simpleMatch(tok->link(),"} [")) {
tok = tok->next();
} else if (state.cpp && iscpp11init(tok)) {
} else if ((state.cpp && iscpp11init(tok)) || Token::simpleMatch(tok->previous(), "] {")) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the new check be inside iscpp11init()?

Copy link
Copy Markdown
Collaborator Author

@danmar danmar Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not c++11 initialization

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int a[2] { 0, 0 }; isn't valid in either C or C++03, unless I'm missing something.

Copy link
Copy Markdown
Collaborator Author

@danmar danmar Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrchr-github Your example is not valid that is correct. The code we want to handle is for example:

auto p = new int*[2]{new int, new int};

So the code we want to handle is not a variable initialisation at all. There is no variable initialization in the RHS..

@danmar danmar merged commit 5976faa into main Jun 5, 2023
@danmar danmar deleted the ast-11745 branch June 5, 2023 18:43
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