re PR c++/60312 ([c++1y] ICE using auto as template parameter)
authorJason Merrill <jason@redhat.com>
Mon, 24 Feb 2014 18:47:20 +0000 (13:47 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 24 Feb 2014 18:47:20 +0000 (13:47 -0500)
PR c++/60312
* parser.c (cp_parser_template_type_arg): Check for invalid 'auto'.

From-SVN: r208092

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp1y/auto-neg1.C [new file with mode: 0644]

index 1b204dcf4be8f9aa24e0a8460da03b19c000b7f0..5369ee680cdf93a11d76baac039a9dac22f29c3c 100644 (file)
@@ -1,3 +1,8 @@
+2014-02-24  Jason Merrill  <jason@redhat.com>
+
+       PR c++/60312
+       * parser.c (cp_parser_template_type_arg): Check for invalid 'auto'.
+
 2014-02-21  Jason Merrill  <jason@redhat.com>
 
        PR c++/58170
index 1e9803263067e1950de88e2ea975182a68dab8a7..d99dff0265c35b29529aef82f596328d5ace1a21 100644 (file)
@@ -18005,6 +18005,11 @@ static tree cp_parser_template_type_arg (cp_parser *parser)
     = G_("types may not be defined in template arguments");
   r = cp_parser_type_id_1 (parser, true, false);
   parser->type_definition_forbidden_message = saved_message;
+  if (cxx_dialect >= cxx1y && type_uses_auto (r))
+    {
+      error ("invalid use of %<auto%> in template argument");
+      r = error_mark_node;
+    }
   return r;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-neg1.C b/gcc/testsuite/g++.dg/cpp1y/auto-neg1.C
new file mode 100644 (file)
index 0000000..1bc3995
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/60312
+// { dg-options -std=c++1y }
+
+template<typename> struct A;
+
+template<> struct A<auto>      // { dg-error "auto|template argument" }
+{
+  template<int> void foo();
+};
+
+void bar()
+{
+  A<auto>().foo<0>();          // { dg-error "auto|template argument" }
+}
+
+// { dg-prune-output "expected" }