[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pcc-list
Subject:    Re: typedef name as parameters
From:       Anders Magnusson <ragge () ludd ! ltu ! se>
Date:       2008-08-03 10:58:25
Message-ID: 48958F51.60004 () ludd ! ltu ! se
[Download RAW message or body]

Gregory McGarry wrote:
> 
> On 01/08/2008, at 2:36 AM, Anders Magnusson wrote:
> 
>> Stefan Kempf wrote:
>>> Gregory McGarry wrote:
>>>> The following code doesn't compile:
>>>>
>>>> typedef void (*foo)(void);
>>>> typedef void (*bar)(int);
>>>> int baz(bar foo);
>>>>
>>>> While the error is:
>>>>
>>>> $ pcc -S ff.c
>>>> ff.c, line 3: declaration doesn't match prototype
>>>>
>>>> Later in 6.9.1.6:
>>>>
>>>> "If the declarator includes an identifier list, each declaration in the
>>>> declaration list shall have at least one declarator, those declarators
>>>> shall declare only identifiers from the identifier list, and every
>>>> identifier in the identifier list shall be declared.  An identifier
>>>> declared as a typedef name shall not be redeclared as a parameter."
>>>>
>>>> I conclude that pcc is doing the right thing here, however it may be
>>>> good to actually detect the actual error.
>>>
>>> How does 6.9.1.6 apply to your example? (bar foo) looks like a parameter
>>> type list, not an identifier list to me.
>>>
>> True.  The example given should compile.  It's a bug.
> 
> That works for me.
> 
And now it's fixed, I'm just test-compiling right now to see that it works
as expected.  I have changed the code so that the call to defid() is not done
until after it is found out to be a function, so no names in prototypes anymore.
This also solves the problem with -Wshadow and prototype parameter names.

-- Ragge

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic