TypedefDecl for injected-class-name

Hi Doug,

Is creating a TypedefDecl for injected-class-name really necessary ?
I think we can avoid allocating something like this, probably by using
      PushOnScopeChains(Dcl, S);
where 'Dcl' is the CXXRecordDecl.

Creating a TypedefDecl doesn't "fit" well with the 'real' declarations, e.g:

class C {
  static int C;
};

t.cpp:2:14: error: redefinition of 'C' as different kind of symbol
  static int C;
             ^
t.cpp:1:9: error: previous definition is here
class C {
        ^

where we would like to have something like:

error: declaration of a member with the same name as its class

And the fact that

class C {
  int C;
};

compiles is actually due to a bug where instance fields is not colliding with other member declarations, like

class C {
  typedef int T;
  int T; // bug, no collision
};

-Argiris

Hi Argiris,

Is creating a TypedefDecl for injected-class-name really necessary ?

No, it isn't necessary.

I think we can avoid allocating something like this, probably by using
     PushOnScopeChains(Dcl, S);
where 'Dcl' is the CXXRecordDecl.

That is much better; it also simplified
Sema::CheckDestructorDeclarator's initial check to make sure we're not
declaring a destructor using a typedef of the class-name.

Thanks!

Creating a TypedefDecl doesn't "fit" well with the 'real' declarations, e.g:

class C {
static int C;
};

t.cpp:2:14: error: redefinition of 'C' as different kind of symbol
static int C;
            ^
t.cpp:1:9: error: previous definition is here
class C {
       ^

where we would like to have something like:

error: declaration of a member with the same name as its class

Yes, we do need to (properly) diagnose this class of error.

  - Doug