]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
parser.c (cp_parser_type_id_1): 'auto' type is ok with a late-specified return type.
authorJason Merrill <jason@redhat.com>
Tue, 9 Jun 2009 04:18:54 +0000 (00:18 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 9 Jun 2009 04:18:54 +0000 (00:18 -0400)
* parser.c (cp_parser_type_id_1): 'auto' type is ok with a
late-specified return type.

From-SVN: r148306

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/auto15.C [new file with mode: 0644]

index d9327a9d379b9e64ac164c32ecb8055dbf300bad..c4e84aa14b8e00cdac97eba3c455081ef78877a5 100644 (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
index 05ae257fbf79c19da4369cb7d76e31f35f412f01..b988850d206e1b614acfe61838a1bec8f1b06b2d 100644 (file)
@@ -13848,8 +13848,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,
index e20679a9ba36280e32bc7b4d422705b926d19928..b08a0b91930b2eaf77f3cff72f51736693065994 100644 (file)
@@ -1,3 +1,7 @@
+2009-06-08  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/auto15.C: New.
+
 2009-06-08  Jan Hubicka  <jh@suse.cz>
 
        PR debug/39834
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto15.C b/gcc/testsuite/g++.dg/cpp0x/auto15.C
new file mode 100644 (file)
index 0000000..b23e1e2
--- /dev/null
@@ -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;
+}