This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GCC/EGCS parser bug


On Fri, 05 Feb 1999 16:03:14 +0100, Joachim Hollman wrote:
>I read that section, and the wording is the same in the old standard
>if I remember correctly.
>
>The reason for this clause is to disambiguate cases like
>
>typedef int a;
>void f(int (a));
>
>However, because of the '*' in front of "func" in
>
>typedef void (*func)(int);
>void f(int i1, void (*func)(void *, void *), int i2)
>                     ^
>the construct (*func) is a direct-declarator, *not* an
>abstract-declarator,
>and "func" can *only* be parsed as an identifier.

So you get past that clause, func is parsed as an identifier, and
then you hit the rules in section 6.2.3:

       [#1] ...Thus,  there are separate name spaces for various categories
       of identifiers, as follows:

         -- label names (disambiguated by the syntax of  the  label
            declaration and use);

         -- the   tags  of  structures,  unions,  and  enumerations
            (disambiguated  by  following  any22)  of  the keywords
            struct, union, or enum);

         -- the members of structures or unions; each structure  or
            union  has  a  separate  name  space  for  its  members
            (disambiguated by the type of the  expression  used  to
            access the member via the . or -> operator);

         -- all  other  identifiers,  called  ordinary  identifiers
            (declared in ordinary  declarators  or  as  enumeration
            constants).

The `ordinary identifiers' bucket catches typedef names and prototype
parameter names, and you have a clash.

zw


>
>Zack Weinberg wrote:
>> 
>> On Fri, 05 Feb 1999 14:03:55 +0100, Joachim Hollman wrote:
>> >I disagree, but I also realize that you get many bug reports and that
>> >you don't have time to give a detailed response to each one.
>> >
>> >As I see it, one of us misinterpret the ANSI standard.
>> >
>> >Don't you think it would be a good idea to ask somebody else on the
>> >egcs/gcc
>> >team to take a close look at this to make sure that it isn't a bug?
>> 
>> Go ahead and repost to egcs-bugs.  However, may I quote a bit of the
>> standard?
>> 
>> C9x CD2, section 6.7.5.3:
>> 
>>        [#7] If, in a parameter declaration, an  identifier  can  be
>>        treated  as  a typedef name or as a parameter name, it shall
>>        be taken as a typedef name.
>> 
>> zw
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]