parser.c (cp_parser_type_id_1): 'auto' type is ok with a late-specified return type.

* parser.c (cp_parser_type_id_1): 'auto' type is ok with a
        late-specified return type.

From-SVN: r148307
This commit is contained in:
Jason Merrill 2009-06-09 00:23:00 -04:00 committed by Jason Merrill
parent 3f4e4c50ff
commit 5874064b94
4 changed files with 33 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2009-06-08 Jason Merrill <jason@redhat.com>
* parser.c (cp_parser_type_id_1): 'auto' type is ok with a
late-specified return type.
2009-06-08 Jakub Jelinek <jakub@redhat.com>
PR c++/40373

View File

@ -13808,8 +13808,17 @@ cp_parser_type_id_1 (cp_parser* parser, bool is_template_arg)
if (type_specifier_seq.type
&& type_uses_auto (type_specifier_seq.type))
{
error ("invalid use of %<auto%>");
return error_mark_node;
/* A type-id with type 'auto' is only ok if the abstract declarator
is a function declarator with a late-specified return type. */
if (abstract_declarator
&& abstract_declarator->kind == cdk_function
&& abstract_declarator->u.function.late_return_type)
/* OK */;
else
{
error ("invalid use of %<auto%>");
return error_mark_node;
}
}
return groktypename (&type_specifier_seq, abstract_declarator,

View File

@ -1,3 +1,7 @@
2009-06-08 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/auto15.C: New.
2009-06-08 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/40334

View File

@ -0,0 +1,13 @@
// { dg-options "-std=c++0x" }
template< typename Fn > struct function;
template< typename Result, typename ... ArgTypes >
struct function< auto (ArgTypes...)->Result > {
};
int main()
{
function< auto(double)->int > y;
return 0;
}