Topic: Language Question


Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Sun, 26 Jun 1994 23:10:08 GMT
Raw View
In article <JASON.94Jun23150536@deneb.cygnus.com> jason@cygnus.com (Jason Merrill) writes:
>>>>>> Mark Immel <immel@chord.centerline.com> writes:
>
>> I'm want to know if:
>
>> class Foo;
>
>> typedef void (Foo::FooFunc)();
>
>> is a legal typedef.
>
>I would argue no, since the declarator-id in that declaration is
>Foo::FooFunc, and the declarator-id for a typedef must be a simple
>identifier:
>
>  8.3  Meaning of declarators                              [dcl.meaning]
>
>  Each  declarator contains exactly one  declarator-id; it
>  names the identifier that is declared.  A  declarator-id  shall  be  a  |
>  simple    identifier, except for the following cases:  the declaration  |
>  of some special functions (12.3, 12.4,  13.4),  the  definition  of  a  |
>  member  function  (9.4), the definition of a static data member (9.5),  |
>  the declaration of a friend function that is a member of another class  |
>  (11.4).

Thank you for the quote Jason.

I'd just like to mention that the above paragraph appears to be flawed
in at least one way.  I am refering to the case of the (new) notation
which the committee has selected for use to designate a member of a
template formal type as being itself a type.

Additionally, I'm inclined to wonder about the relevance (if any) of a
proposal from Tony Hansen (which the committee accepted some time ago)
which had the effect of making it perfectly valid to do:

  struct OUTER { struct INNER; };

  struct OUTER::INNER { ... };

This case is not covered by the paragraph you have quoted, but then it
doesn't have to be because the name OUTER::INNER in this example is only
being used as a *tag name*, not as part of a declarator.  But what I'm
wondering about is whether or not the committee did (or will) permit
something like:

  struct OUTER { typedef INNER; };

  typedef int OUTER::INNER;

(This seems highly analogous to the case involving member struct types,
and if one was deemed useful, surely the other one must be also, yes?)

--

-- Ron Guilmette, Sunnyvale, CA ---------- RG Consulting -------------------
---- domain addr: rfg@netcom.com ----------- Purveyors of Compiler Test ----
---- uucp addr: ...!uunet!netcom!rfg ------- Suites and Bullet-Proof Shoes -




Author: immel@chord.centerline.com (Mark Immel)
Date: 23 Jun 1994 13:53:30 GMT
Raw View
Would the language experts out there help me out?

I'm want to know if:

class Foo;

typedef void (Foo::FooFunc)();

is a legal typedef.  I know that:

typedef void (Foo::*FooFuncPtr)();

is legal as is:

typedef void (plainFunc)();

but compilers seem to differ on the first example.  I've got the WP
but can't seem to find the answer.

Thanks in advance; if you wish mail me (immel@centerline.com) and I'll
post a summary.

-- Mark
   immel@centerline.com





Author: jason@cygnus.com (Jason Merrill)
Date: Thu, 23 Jun 1994 22:05:36 GMT
Raw View
>>>>> Mark Immel <immel@chord.centerline.com> writes:

> I'm want to know if:

> class Foo;

> typedef void (Foo::FooFunc)();

> is a legal typedef.

I would argue no, since the declarator-id in that declaration is
Foo::FooFunc, and the declarator-id for a typedef must be a simple
identifier:

  8.3  Meaning of declarators                              [dcl.meaning]

  Each  declarator contains exactly one  declarator-id; it
  names the identifier that is declared.  A  declarator-id  shall  be  a  |
  simple    identifier, except for the following cases:  the declaration  |
  of some special functions (12.3, 12.4,  13.4),  the  definition  of  a  |
  member  function  (9.4), the definition of a static data member (9.5),  |
  the declaration of a friend function that is a member of another class  |
  (11.4).

I would not object strenouously to changing the binding of the scope
qualification there, but since there is nothing in [dcl.typedef] talking
about this I must assume that the general rules apply.

Jason