Menu

#137 Code completion - code without "using namespace" - don't shows class members

Undefined
fixed
ollydbg
Bug_Report
2015-06-02
2015-02-18
aleksusklim
No

Wrong completion with namespaces.

Exact example code:

#include"c.h" // In that file: namespace z{class t{int y;};}
using z::t;
//using namespace z;
int main(){
t v;
v. // Bug is here
return 0;}

If you uncomment line "//using namespace z;" the Code completion will work perfect.
But here we see that class "t" is already visible by "using z::t;".
Strange, but if you put the contents of "c.h" instead of "#include", this will work fine again.

In my example, code completion don't shows "y:int" in pop-up.

Platform: LinuxMint x64, CodeBlocks 13.12, CodeCompletion v1.0, compiler: gcc.

Discussion

  • ollydbg

    ollydbg - 2015-02-21
    • labels: using namespace, code completion --> using namespace, CodeCompletion
     
  • ollydbg

    ollydbg - 2015-02-21

    If I can remember, C::B's parser don't handle the "using z::t". I mean the parser just skip the line and do nothing.

    But we do handle "using namespace z;" statement when we prompt a suggestion list(codecompletion)

     
  • jat1

    jat1 - 2015-05-23

    Hi, I've attached a patch for this bug. It changes CC's behavior so that instead of skipping the pattern "using A::B", it will recognize it and parse it similarly to "using namespace A".

     

    Last edit: jat1 2015-05-23
  • ollydbg

    ollydbg - 2015-05-23
    • assigned_to: ollydbg
     
  • ollydbg

    ollydbg - 2015-05-23

    Thanks, jat1, I will look into your patch.

     
  • ollydbg

    ollydbg - 2015-06-01

    The patch works fine! Thanks.
    Now, I can't connect to SF through svn, so I can't commit this patch.
    I can use proxy to access to SF's web page.
    I added some comments in the patch, see attachment.

     
  • ollydbg

    ollydbg - 2015-06-02

    I can access to svn now, so the patch is in trunk now. Thanks for the contribution.

     
  • ollydbg

    ollydbg - 2015-06-02
    • status: open --> fixed
     
  • jat1

    jat1 - 2015-06-02

    The added comments look good, thanks. Do you think it would be better to change:

    // there are some kinds of using keyword usage
    // (1) using namespace A;
    // (2) using namespace A::B;
    // (3) using A::B;
    

    to this:

    // there are some kinds of using keyword usage
    // (1) using namespace A;
    // (2) using namespace A::B;    // where B is a namespace
    // (3) using A::B;              // where B is NOT a namespace
    

    so it is clearer why m_Str contains "A" for case (1) and (3), and "A::B" for case (2)? In other words, m_Str must end with a namespace for CC to work.

     
  • ollydbg

    ollydbg - 2015-06-02

    Thanks for the suggestion, done in the trunk.

     

Log in to post a comment.

MongoDB Logo MongoDB