[cfe-dev] [patch] _Generic constant string used as controlling expression
Prathamesh Kulkarni
bilbotheelffriend at gmail.com
Mon Apr 28 11:35:52 PDT 2014
On Mon, Apr 28, 2014 at 11:48 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Mon, Apr 28, 2014 at 10:58 AM, Prathamesh Kulkarni
> <bilbotheelffriend at gmail.com> wrote:
>>
>> Hi,
>> I had reported this bug earlier:
>>
>> http://clang-developers.42468.n3.nabble.com/Generic-constant-string-as-controlling-expression-td4036519.html
>>
>> For following case:
>> int main(void)
>> {
>> int x = _Generic("hello", char *: 1);
>> }
>>
>> clang gives error:
>> generic_expr.c:3:20: error: controlling expression type 'char [6]' not
>> compatible with any generic association type
>> int x = _Generic ("hello", char *: 1);
>>
>> I guess that's because array-to-pointer conversion is not performed
>> when array is used as controlling expression.
>> gcc-4.9 compiles the above test-case.
>>
>> I have attached a patch that performs array-to-pointer conversion
>> when array is used as controlling expression, and it compiles the
>> above test-case.
>> OK to commit ?
>
>
> This isn't quite the right approach -- it will still do the wrong thing if a
> function designator is used as the argument to _Generic. You should use
> DefaultFunctionArrayConversion here instead, replacing the existing
> placeholder handling with it.
Thanks. I modified the patch to call DefaultFunctionArrayConversion.
Is it correct ?
Thanks and Regards,
Prathamesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generic-expr.patch
Type: text/x-patch
Size: 552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140429/eeb144bd/attachment.bin>
More information about the cfe-dev
mailing list