Nested class error: unexpected multiple definition

Create issue
Issue #5 resolved
Sixdsn created an issue

Taking this code as exemple: Six is the main class and has Tmp, Foo and Bar as nested classes. Without Six::Foo and Six::Bar inheriting from Six::Tmp, everything works fine.

class Six
{
    class Tmp;
    class Bar;
    class Foo;
};

class Six::Tmp
{
};

class Six::Bar : public Tmp
{
};

class Six::Foo : public Tmp
{
};

But if we have Six::Foo and Six::Bar heriting from another class (such as Six::Tmp) the parser breaks saying:

[2185] Evaluating stack ['class', 'Six']
       BraceDepth: 0 (called from 2047)
[2248] trace
[1825] curAccessSpecifier changed/defaulted to private
[ 382] Class:   ['class', 'Six']
[1832] NEW CLASS Six 
[2185] Evaluating stack []
       BraceDepth: 1 (called from 2062)
[2195] Six (private) 
[2214] trace
[2215] (Empty Stack)
[2067] CURBD 0
[2070] END OF CLASS DEF 
[2080] END OF STRUCT DEF 
[2185] Evaluating stack []
       BraceDepth: 0 (called from 2169)
[2214] trace
[2215] (Empty Stack)
[2185] Evaluating stack ['class', 'Six', ':', ':', 'Tmp']
       BraceDepth: 0 (called from 2047)
[2248] trace
[1825] curAccessSpecifier changed/defaulted to private
[ 382] Class:   ['class', 'Six', ':', ':', 'Tmp']
[1832] NEW CLASS Tmp 
[2185] Evaluating stack []
       BraceDepth: 1 (called from 2062)
[2195] Six::Tmp (private) 
[2214] trace
[2215] (Empty Stack)
[2067] CURBD 0
[2070] END OF CLASS DEF 
[2080] END OF STRUCT DEF 
[2185] Evaluating stack []
       BraceDepth: 0 (called from 2169)
[2195] Six (private) 
[2214] trace
[2215] (Empty Stack)
[2185] Evaluating stack ['class', 'Six', ':', ':', 'Bar', ':', 'public', 'Tmp']
       BraceDepth: 0 (called from 2047)
[2195] Six (private) 
[2248] trace
[1825] curAccessSpecifier changed/defaulted to private
[ 382] Class:   ['class', 'Six', ':', ':', 'Bar', ':', 'public', 'Tmp']
[1832] NEW CLASS Six 
[2185] Evaluating stack []
       BraceDepth: 1 (called from 2062)
[2195] Six::Six (private) 
[2214] trace
[2215] (Empty Stack)
[2067] CURBD 0
[2070] END OF CLASS DEF 
[2080] END OF STRUCT DEF 
[2185] Evaluating stack []
       BraceDepth: 0 (called from 2169)
[2195] Six (private) 
[2214] trace
[2215] (Empty Stack)
[2185] Evaluating stack ['class', 'Six', ':', ':', 'Foo', ':', 'public', 'Tmp']
       BraceDepth: 0 (called from 2047)
[2195] Six (private) 
[2248] trace
[1825] curAccessSpecifier changed/defaulted to private
[ 382] Class:   ['class', 'Six', ':', ':', 'Foo', ':', 'public', 'Tmp']
[1832] NEW CLASS Six 
[1860] ERROR name collision: Six::Six

Because it doesn't get the right class name if it's a nested class defined outside the main class and heriting from another class.

For Six::Bar and Six::Foo, it says class name is Six and as it is a nested class from Six the real name is Six::Six to him... so it breaks to the second heriting nested class decl

Comments (4)

  1. Sixdsn reporter

    Yes i know it's tricky and i won't pressure you about that :) the thing is, it gets correctly all elements, but only fail on the real classname of a nested class if it inherits from another class

  2. Log in to comment