[cfe-commits] r126134 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaObjC/auto-objective-c.m

Douglas Gregor dgregor at apple.com
Mon Feb 21 17:19:33 PST 2011


On Feb 21, 2011, at 5:09 PM, Richard Smith wrote:

> On Tue, February 22, 2011 00:50, Douglas Gregor wrote:
>> On Feb 21, 2011, at 4:44 PM, Richard Smith wrote:
>>> On Mon, February 21, 2011 18:37, Fariborz Jahanian wrote:
>>>> Author: fjahanian
>>>> Date: Mon Feb 21 12:37:13 2011
>>>> New Revision: 126134
>>>> 
>>>> 
>>>> 
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=126134&view=rev
>>>> Log:
>>>> Turn on 'auto' in plain  objc mode.
>>>> 
>>> 
>>> Without trailing return type support, this produces unhelpful
>>> diagnostics:
>>> 
>>> 
>>> $ echo -e 'auto a();' | clang++ -xobjective-c -
>>> <stdin>:1:1: error: 'auto' return without trailing return type
>>> auto a(); ^
>>> 1 error generated.
>>> $ echo -e 'auto a() -> void;' | clang++ -xobjective-c -
>>> <stdin>:1:10: error: expected function body after function declarator
>>> auto a() -> void; ^
>>> 1 error generated.
>>> 
>>> 
>>> It should be straightforward to teach GetTypeForDeclarator that
>>> objective-c (or perhaps anything that's not C++) is a special case, if
>>> you don't want trailing return types there too.
>> 
>> Good point! We don't want trailing return types in Objective-C.
> 
> This should sort it out.

Hey, thanks!

-      !D.isFunctionDeclarator()) {
+      (!getLangOptions().CPlusPlus0x || !D.isFunctionDeclarator())) {

Maybe this should just be getLangOptions().CPlusPlus, in case we do the previously-threatened trick of catching some uses of 'auto' as a type-specifier in C++?

	- Doug



More information about the cfe-commits mailing list