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

Parsing error when two template closing delimiter are used together without separator ">>" #2318

Closed
slnj opened this issue Feb 20, 2022 · 6 comments · Fixed by #2291 or #2319
Closed
Assignees
Labels
Milestone

Comments

@slnj
Copy link

slnj commented Feb 20, 2022

Getting parsing error in this case:
FAILS:

auto foo( A<int>* p ) 
{
    auto a = f(std::shared_ptr<A<int>>(p));
}

But If change ">>" by "> >" ( adding one separator between ">" then parsing is ok )
OK:

auto foo( A<int>* p ) 
{
    auto a = f(std::shared_ptr<A<int> >(p));
} 

Also if f() call is removed , ">>" without separator is accepted.
OK:

auto foo( A<int>* p ) 
{
    auto a = std::shared_ptr<A<int>>(p);
}
@guwirth guwirth added the bug label Feb 21, 2022
@guwirth
Copy link
Collaborator

guwirth commented Feb 21, 2022

@guwirth guwirth linked a pull request Feb 21, 2022 that will close this issue
@slnj
Copy link
Author

slnj commented Feb 21, 2022

Seems each < should initialize its own parentheseLevel variable.
Maybe change parentheseLevel to a int stack, push a 0 when a < is found, and pop when > is found, ++ top element when '(' found and -- on ')', and the top value being checked at line 79 for consume initialization.

guwirth added a commit to guwirth/sonar-cxx that referenced this issue Feb 22, 2022
@guwirth guwirth self-assigned this Feb 22, 2022
@guwirth guwirth added this to the 2.0.7 milestone Feb 22, 2022
@guwirth
Copy link
Collaborator

guwirth commented Feb 22, 2022

Hi @slnj,

thanks for your feedback.

I have a fix for your issue, but I'm not sure if this is a fix for all cases. Please test it and give me feedback. The code implements:
https://github.com/SonarOpenCommunity/sonar-cxx/blob/master/cxx-squid/dox/Right_Angle_Brackets_N1757_05-0017.html

I always try to find a solution with minimal impact to avoid destroying other things.

Regards,

@guwirth
Copy link
Collaborator

guwirth commented Feb 24, 2022

Hi @slnj,

there is a new version for testing:
https://ci.appveyor.com/project/SonarOpenCommunity/sonar-cxx/branch/master/artifacts

Regards,

@slnj
Copy link
Author

slnj commented Feb 26, 2022

Excellent!!
With this, all parsing error on my code are gone!!!

Thanks & Regards
Santiago

@guwirth
Copy link
Collaborator

guwirth commented Feb 26, 2022

@slnj Thx for your valuable input!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment