public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Help ! Frozen by a comment in gcc/c-common.h!
@ 2009-08-27 13:29 Alexei I. Adamovich
  2009-08-28  4:53 ` Ian Lance Taylor
  0 siblings, 1 reply; 6+ messages in thread
From: Alexei I. Adamovich @ 2009-08-27 13:29 UTC (permalink / raw)
  To: gcc

Hi All!

While modifying the C lexer to accommodate it for experimental
C-derived language front-end, I've stumbled across the following
comment in gcc/c-common.h before the "enum rid" definition (still
there in gcc-4.5-20090820 snapshot):

42 /* Reserved identifiers.  This is the union of all the keywords for C,
43    C++, and Objective-C.  All the type modifiers have to be in one
44    block at the beginning, because they are used as mask bits.  There
45    are 27 type modifiers; if we add many more we will have to redesign
46    the mask mechanism.  */
47 
48 enum rid
49 {
50   /* Modifiers: */
51   /* C, in empirical order of frequency.  */
52   RID_STATIC = 0,
53   RID_UNSIGNED, RID_LONG,    RID_CONST, RID_EXTERN
...

Could you please enlighten me -- is the comment still relevant? If so,
where the usage of type modifiers entries in enum rid as mask bits can
be seen in gcc code (or documentation, if applicable)?

I'd like to be aware, since I've defined several (four) additional type
modifiers.

Thanks in advance,

Alexei I. Adamovich



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Help ! Frozen by a comment in gcc/c-common.h!
  2009-08-27 13:29 Help ! Frozen by a comment in gcc/c-common.h! Alexei I. Adamovich
@ 2009-08-28  4:53 ` Ian Lance Taylor
  2009-08-30  3:04   ` Alexei I. Adamovich
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Lance Taylor @ 2009-08-28  4:53 UTC (permalink / raw)
  To: Alexei I. Adamovich; +Cc: gcc

"Alexei I. Adamovich" <lexa@adam.botik.ru> writes:

> While modifying the C lexer to accommodate it for experimental
> C-derived language front-end, I've stumbled across the following
> comment in gcc/c-common.h before the "enum rid" definition (still
> there in gcc-4.5-20090820 snapshot):
>
> 42 /* Reserved identifiers.  This is the union of all the keywords for C,
> 43    C++, and Objective-C.  All the type modifiers have to be in one
> 44    block at the beginning, because they are used as mask bits.  There
> 45    are 27 type modifiers; if we add many more we will have to redesign
> 46    the mask mechanism.  */
> 47 
> 48 enum rid
> 49 {
> 50   /* Modifiers: */
> 51   /* C, in empirical order of frequency.  */
> 52   RID_STATIC = 0,
> 53   RID_UNSIGNED, RID_LONG,    RID_CONST, RID_EXTERN
> ...
>
> Could you please enlighten me -- is the comment still relevant? If so,
> where the usage of type modifiers entries in enum rid as mask bits can
> be seen in gcc code (or documentation, if applicable)?

I suspect that that comment is no longer relevant.  At least, I can't
seem to find the mask.  Perhaps somebody else knows.

Ian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Help ! Frozen by a comment in gcc/c-common.h!
  2009-08-28  4:53 ` Ian Lance Taylor
@ 2009-08-30  3:04   ` Alexei I. Adamovich
  2009-08-30  6:58     ` Alexey I. Adamovich
  0 siblings, 1 reply; 6+ messages in thread
From: Alexei I. Adamovich @ 2009-08-30  3:04 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

Hi!

On Thu, Aug 27, 2009 at 09:51:30AM -0700, Ian Lance Taylor wrote:
> I suspect that that comment is no longer relevant.  At least, I can't
> seem to find the mask.  Perhaps somebody else knows.

I got. Since no anybody more has commented, let us be sure that the
mask mechanism has gone. [I've recently found corresponding bit mask in
gcc-3.3.6 in grokdeclarator (c-decl.c), e.g:
> 3589               if (i == RID_LONG && (specbits & (1 << (int) RID_LONG)))
or
> 3624               specbits |= 1 << (int) i;
where
> 3586           enum rid i = C_RID_CODE (id);
]

So for the sake of those who will develop C-derived front ends, should
we change the comment like below:
> /* Reserved identifiers.  This is the union of all the keywords for C,
>    C++, and Objective-C.  In the past, in earlier GCC versions all the
>    type modifiers had to be in one block at the beginning, because
>    they were used as mask bits.  There were 27 type modifiers; so if
>    anybody added many more the mask mechanism would have to be
>    redesigned.  Now it doesn't matter, since corresponding mask
>    machinery gone */
Should I (or you) submit a patch?

Alexei I. Adamovich

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Help ! Frozen by a comment in gcc/c-common.h!
  2009-08-30  3:04   ` Alexei I. Adamovich
@ 2009-08-30  6:58     ` Alexey I. Adamovich
  2009-08-31 18:23       ` Ian Lance Taylor
  0 siblings, 1 reply; 6+ messages in thread
From: Alexey I. Adamovich @ 2009-08-30  6:58 UTC (permalink / raw)
  To: gcc; +Cc: Ian Lance Taylor

Forgot RID_LAST_MODIFIER

On Sat, Aug 29, 2009 at 08:29:21PM +0400, Alexei I. Adamovich wrote:
> So for the sake of those who will develop C-derived front ends, should
> we change the comment like below:
> > /* Reserved identifiers.  This is the union of all the keywords for C,
> >    C++, and Objective-C.  In the past, in earlier GCC versions all the
> >    type modifiers had to be in one block at the beginning, because
> >    they were used as mask bits.  There were 27 type modifiers; so if
> >    anybody added many more the mask mechanism would have to be
> >    redesigned.  Now it doesn't matter, since corresponding mask
> >    machinery gone */

Should the last lines be re-written as follows:
>    redesigned.  Now it doesn't matter, since corresponding mask
>    machinery gone.  But anyway when adding any type modifier it's
>    better to follow the old rule and to get sure that
>    RID_LAST_MODIFIER is defined and handled correctly also */
[?]

Alexei I. Adamovich

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Help ! Frozen by a comment in gcc/c-common.h!
  2009-08-30  6:58     ` Alexey I. Adamovich
@ 2009-08-31 18:23       ` Ian Lance Taylor
  2009-08-31 19:27         ` Alexey I. Adamovich
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Lance Taylor @ 2009-08-31 18:23 UTC (permalink / raw)
  To: Alexey I. Adamovich; +Cc: gcc

lexa@dm.botik.ru (Alexey I. Adamovich) writes:

> Forgot RID_LAST_MODIFIER
>
> On Sat, Aug 29, 2009 at 08:29:21PM +0400, Alexei I. Adamovich wrote:
>> So for the sake of those who will develop C-derived front ends, should
>> we change the comment like below:
>> > /* Reserved identifiers.  This is the union of all the keywords for C,
>> >    C++, and Objective-C.  In the past, in earlier GCC versions all the
>> >    type modifiers had to be in one block at the beginning, because
>> >    they were used as mask bits.  There were 27 type modifiers; so if
>> >    anybody added many more the mask mechanism would have to be
>> >    redesigned.  Now it doesn't matter, since corresponding mask
>> >    machinery gone */
>
> Should the last lines be re-written as follows:
>>    redesigned.  Now it doesn't matter, since corresponding mask
>>    machinery gone.  But anyway when adding any type modifier it's
>>    better to follow the old rule and to get sure that
>>    RID_LAST_MODIFIER is defined and handled correctly also */
> [?]

I think we should drop the reference to previous gcc versions and the
old scheme.  I don't think it helps in understanding the code.

It's still necessary to set RID_LAST_MODIFIER correctly as
declspecs_add_type uses it.

Ian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Help ! Frozen by a comment in gcc/c-common.h!
  2009-08-31 18:23       ` Ian Lance Taylor
@ 2009-08-31 19:27         ` Alexey I. Adamovich
  0 siblings, 0 replies; 6+ messages in thread
From: Alexey I. Adamovich @ 2009-08-31 19:27 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

Hi!

On Mon, Aug 31, 2009 at 08:44:24AM -0700, Ian Lance Taylor wrote:
> I think we should drop the reference to previous gcc versions and the
> old scheme.  I don't think it helps in understanding the code.
> 
> It's still necessary to set RID_LAST_MODIFIER correctly as
> declspecs_add_type uses it.

Perfect. Thanks, Ian.

Sincerely,

  Alexei I. Adamovich

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-31 18:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-27 13:29 Help ! Frozen by a comment in gcc/c-common.h! Alexei I. Adamovich
2009-08-28  4:53 ` Ian Lance Taylor
2009-08-30  3:04   ` Alexei I. Adamovich
2009-08-30  6:58     ` Alexey I. Adamovich
2009-08-31 18:23       ` Ian Lance Taylor
2009-08-31 19:27         ` Alexey I. Adamovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).