<p dir="ltr">Looks great, thanks!</p>
<div class="gmail_quote">On 28 Apr 2014 11:58, "Prathamesh Kulkarni" <<a href="mailto:bilbotheelffriend@gmail.com">bilbotheelffriend@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, Apr 29, 2014 at 12:06 AM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
> On Mon, Apr 28, 2014 at 11:35 AM, Prathamesh Kulkarni<br>
> <<a href="mailto:bilbotheelffriend@gmail.com">bilbotheelffriend@gmail.com</a>> wrote:<br>
>><br>
>> On Mon, Apr 28, 2014 at 11:48 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>><br>
>> wrote:<br>
>> > On Mon, Apr 28, 2014 at 10:58 AM, Prathamesh Kulkarni<br>
>> > <<a href="mailto:bilbotheelffriend@gmail.com">bilbotheelffriend@gmail.com</a>> wrote:<br>
>> >><br>
>> >> Hi,<br>
>> >>    I had reported this bug earlier:<br>
>> >><br>
>> >><br>
>> >> <a href="http://clang-developers.42468.n3.nabble.com/Generic-constant-string-as-controlling-expression-td4036519.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Generic-constant-string-as-controlling-expression-td4036519.html</a><br>

>> >><br>
>> >> For following case:<br>
>> >> int main(void)<br>
>> >> {<br>
>> >>   int x = _Generic("hello", char *: 1);<br>
>> >> }<br>
>> >><br>
>> >> clang gives error:<br>
>> >> generic_expr.c:3:20: error: controlling expression type 'char [6]' not<br>
>> >> compatible with any generic association type<br>
>> >>  int x = _Generic ("hello", char *: 1);<br>
>> >><br>
>> >> I guess that's because array-to-pointer conversion is not performed<br>
>> >> when array is used as controlling expression.<br>
>> >> gcc-4.9 compiles the above test-case.<br>
>> >><br>
>> >> I have attached a patch that performs array-to-pointer conversion<br>
>> >> when array is used as controlling expression, and it compiles the<br>
>> >> above test-case.<br>
>> >> OK to commit ?<br>
>> ><br>
>> ><br>
>> > This isn't quite the right approach -- it will still do the wrong thing<br>
>> > if a<br>
>> > function designator is used as the argument to _Generic. You should use<br>
>> > DefaultFunctionArrayConversion here instead, replacing the existing<br>
>> > placeholder handling with it.<br>
>> Thanks. I modified the patch to call DefaultFunctionArrayConversion.<br>
>> Is it correct ?<br>
><br>
><br>
> No, you still don't handle function types. Please remove the (redundant)<br>
> handling of placeholder expressions too.<br>
Sorry, didn't get that earlier.<br>
The current patch removes handling of placeholder expression and calls<br>
DefaultFunctionArrayConversion.<br>
<br>
Following test-cases compile:<br>
// check for function-designator<br>
unsigned foo(void)<br>
{<br>
  return 0x03041992;<br>
}<br>
<br>
int main()<br>
{<br>
 int x = _Generic (foo, unsigned (*)(void): 1);<br>
 return x;<br>
}<br>
<br>
// check for array<br>
int main()<br>
{<br>
  int x = _Generic ("hello", char *: 1);<br>
  return x;<br>
}<br>
<br>
Is this patch correct ?<br>
<br>
Thanks and Regards,<br>
Prathamesh<br>
</blockquote></div>