[cfe-commits] [patch] Decltype in simple-type-specifiers

David Blaikie dblaikie at gmail.com
Mon Jan 23 21:56:42 PST 2012


On Mon, Jan 23, 2012 at 7:45 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> Looks good to me.

Thanks - committed as r148787.

> (Unrelated to your change...) while looking at your [stmt.ambig]p1 test, I
> noticed that we appear to disambiguate
>
>  T(x)()->m;
>
> as an expression, when T and m are both types. I'm not sure that's right: it's
> not clear whether the "purely syntactic" disambiguation covers the "T must be
> 'auto'" rule or not.
>
> FWIW, recent g++ rejects the above (it says: function with trailing return
> type not declared with 'auto' type specifier).

Interesting... I assume we get the 'auto' case correct & I'm inclined
to think that's legitimate (sure, it's convenient because it means we
don't have to do anything). 'auto' does syntactically disambiguate the
expression (& quite easily, since it appears at the start) no name
resolution, etc, required.

I know someone mentioned that a possible future expansion to 'auto'
might be 'auto' in sub-parts of a declaration (eg:
std::vector<auto>::iterator = v.begin()) - in that case I don't know
if this would qualify as ambiguous since the auto declaration version
would need an assignment (I don't know if that can be factored into
the disambiguation).

Also - can you use late bound return types in function pointer
declarations? I suppose it might be possible. "auto (*x)(int) -> float
= func;" ?

- David

>
> - Richard
>
> On Sat, January 21, 2012 09:48, David Blaikie wrote:
>> Bump... another really small patch.
>>
>>
>> On Mon, Jan 9, 2012 at 11:17 PM, David Blaikie <dblaikie at gmail.com> wrote:
>>
>>> 3rd time's the charm... sorry for the noise.
>>>
>>>
>>> On Mon, Jan 9, 2012 at 11:14 PM, David Blaikie <dblaikie at gmail.com> wrote:
>>>
>>>> Oops - updated test (removed some previously expected warnings that
>>>> don't fire any more since we've got some of the uniform initialization
>>>> stuff working now)
>>>>
>>>> On Mon, Jan 9, 2012 at 10:23 PM, David Blaikie <dblaikie at gmail.com>
>>>> wrote:
>>>>
>>>>> Bump (patch resync'd to recent revision)
>>>>>
>>>>>
>>>>> On Tue, Dec 13, 2011 at 4:12 PM, David Blaikie <dblaikie at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> & of course I forgot to include the patch... here we go.
>>>>>>
>>>>>>
>>>>>> On Tue, Dec 13, 2011 at 4:11 PM, David Blaikie <dblaikie at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> This patch adds support for decltype in simple-type-specifiers such
>>>>>>> as:
>>>>>>>
>>>>>>>
>>>>>>> struct foo { foo(int); }; foo func() {  return decltype(foo())(3);
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> I'm not sure how much testing would be desired here - I could go
>>>>>>> through the spec & find all the uses of simple-type-specifier & add
>>>>>>> test cases that verify that decltype works in such contexts but for
>>>>>>>  now I've done a smattering of those cases & things seem to be
>>>>>>> working fairly nicely.
>>>>>>>
>>>>>>> Let me know if this is suitable,
>>>>>>> - David
>>>>>>>
>>
>




More information about the cfe-commits mailing list