[cfe-dev] K&R style argument lists and the type system

Chris Lattner clattner at apple.com
Mon Aug 25 22:36:00 PDT 2008


On Aug 25, 2008, at 5:50 PM, Eli Friedman wrote:

> On Mon, Aug 25, 2008 at 4:20 PM, steve naroff <snaroff at apple.com>  
> wrote:
>>> Any ideas for how to solve this?  We could always map definitions
>>> identifier-lists to FunctionTypeNoProto, but that means a good chunk
>>> of additional code to check type-merging doesn't do bad stuff to a
>>> definition and allow CodeGen to synthesize the type of such a  
>>> function
>>> definition properly.
>>
>> This makes more sense to me, since there is no prototype for a(x,y).
>>
>> I think it's better to keep the old style function definition  
>> separate from
>> the modern syntax/semantics...
>
> Bleh, I think we have to encode the exact signature into the type
> system somehow.  Consider the following testcase:
>
> int a(x) float x; {return x;}
> int b(int x) {return x;}
> int c(int x) {return (x ? a : b)(1);}
>
> This is a constraint violation per C99, which would be completely
> unintuitive to diagnose without encoding the fact that "a" takes float
> into the type.
>
> gcc apparently screws up this case; it doesn't print a warning even
> with -std=c99 -pedantic.  Although, the standard is a bit screwy here.

Are you sure this is a constraint violation?  Of what rule?

-Chris



More information about the cfe-dev mailing list