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

parser error during marco resolving #705

Closed
schroeca-zz opened this issue Dec 9, 2015 · 3 comments · Fixed by #709
Closed

parser error during marco resolving #705

schroeca-zz opened this issue Dec 9, 2015 · 3 comments · Fixed by #709
Assignees
Labels
Milestone

Comments

@schroeca-zz
Copy link

I'm using your plug-in to parse SystemC source code. Which is fully compliant to the C++ standard.

The following source code leads to an parser error.

First file:

SC_METHOD(sc_method1);

The SystemC macro SC_METHD is defined in sc_modules.h which looks like this:

#define declare_method_process(handle, name, host_tag, func)        \
    {                                                           \
        ::sc_core::sc_process_handle handle =                      \
        sc_core::sc_get_curr_simcontext()->create_method_process( \
        name,  false, SC_MAKE_FUNC_PTR( host_tag, func ), \
        this, 0 ); \
        this->sensitive << handle;                                        \
        this->sensitive_pos << handle;                                    \
        this->sensitive_neg << handle;                                    \
    }

#define SC_METHOD(func)                                                       \
    declare_method_process( func ## _handle,                                  \
                            #func,                                            \
                            SC_CURRENT_USER_MODULE,                           \
                            func )

If I paste the resolved macro directly in my source file, everything works fine.
If I use the SC_METHOD macro i get an error.

My SonarQube version is: 4.5.6
My Plubin version is: 0.9.4

@guwirth
Copy link
Collaborator

guwirth commented Dec 9, 2015

Please use the sslr toolkit to reduce the problem/example: https://github.com/SonarOpenCommunity/sonar-cxx/releases/download/cxx-0.9.4/sslr-cxx-toolkit-0.9.4.jar

Remove all parts not needed to reproduce it, e.g.:

#define declare_method_process(handle, name, func)        \
    {                                                           \
        int handle = f(name, SC_MAKE_FUNC_PTR(func)); \
    }

#define SC_METHOD(func)                                                       \
    declare_method_process( func ## _handle,                                  \
                            #func,                                            \
                            func )

@schroeca-zz
Copy link
Author

I'm very sorry but I'm not a SonarQube Admin and it is not possible to remove anything from the define statements.

I'm also not sure how to use this sslr toolkit.

I tried to reproduce the behaviour with different modifications of the define statements.

It seems that the **"::"**sc_core:: ... which is necessary to be sure that it is referenced to the global namespace causes the parser crash

This seems to be related to #526

@guwirth
Copy link
Collaborator

guwirth commented Dec 11, 2015

reproducible with this:

#define SC_METHOD(func) declare_method_process( func ## _handle, #func, func )
SC_METHOD(test);

Problem is the #func after func ## _handle.

@guwirth guwirth added bug and removed question labels Dec 11, 2015
@guwirth guwirth added this to the M 0.9.5 milestone Dec 11, 2015
guwirth added a commit that referenced this issue Dec 12, 2015
#define SC_METHOD(func) declare_method_process( func ## _handle, #func, func )
SC_METHOD(test); // declare_method_process( test_handle, "test", test );

close #705
@guwirth guwirth self-assigned this Dec 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants