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

AST parser error - namespace alias '::TimerBase' #526

Closed
Bertk opened this issue May 31, 2015 · 5 comments
Closed

AST parser error - namespace alias '::TimerBase' #526

Bertk opened this issue May 31, 2015 · 5 comments
Assignees
Labels
Milestone

Comments

@Bertk
Copy link
Contributor

Bertk commented May 31, 2015

Parser fails if a namespace alias (global namespace) is used (works with VC 12.0/14.0).

using TimerBase = boost::timer::auto_cpu_timer;
// removing '::' from '::TimerBase' does not create the C++ parser failure 
class  MyTimer : public ::TimerBase
{
public:
    MyTimer(const std::wstring& strName,
             const std::wstring& strMessage);
    ~MyTimer();
private:
// some more

};
@guwirth
Copy link
Collaborator

guwirth commented Jun 1, 2015

Think the parser don't know something from namespace alias (at least at the usage). Error should also occur with 'class MyTimer : public ::TimerBase' alone? Can you verify this please?

Bertk added a commit to Bertk/sonar-cxx that referenced this issue Jun 4, 2015
@Bertk Bertk added the bug label Jun 4, 2015
@Bertk
Copy link
Contributor Author

Bertk commented Jun 4, 2015

I fixed the first problem but this is not a complete fix for this issue. The 'class MyTimer : public ::TimerBase' still creates a parser failure.


  -->  class MyTimer : public ::TimerBase;EOF

    at org.sonar.sslr.internal.vm.Machine.parse(Machine.java:74)
    at com.sonar.sslr.impl.Parser.parse(Parser.java:87)
    at com.sonar.sslr.impl.Parser.parse(Parser.java:72)

@guwirth guwirth added this to the M 0.9.4 milestone Jun 4, 2015
@Bertk
Copy link
Contributor Author

Bertk commented Jun 4, 2015

This works 😇

class MyTimer : public ::TimerBase {};

Bertk added a commit to Bertk/sonar-cxx that referenced this issue Jun 4, 2015
SonarOpenCommunity#526
see http://en.cppreference.com/w/cpp/language/qualified_lookup
"If there is nothing on the left hand side of the ::, the lookup
considers only declarations made in the global namespace scope (or
introduced into the global namespace by a using declaration). This makes
it possible to refer to such names even if they were hidden by a local
declaration"
@guwirth
Copy link
Collaborator

guwirth commented Jun 4, 2015

@Bertk Should we close this or keep it open?

@Bertk
Copy link
Contributor Author

Bertk commented Jun 4, 2015

We can close this issue - solution 08d5d6c is merged.

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

No branches or pull requests

2 participants