[cfe-dev] TypedefDecl for injected-class-name

Doug Gregor doug.gregor at gmail.com
Mon Nov 10 06:42:15 PST 2008


Hi Argiris,

On Fri, Nov 7, 2008 at 7:46 PM, Argiris Kirtzidis <akyrtzi at gmail.com> wrote:
> 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



More information about the cfe-dev mailing list