C++14 expands the places where auto type-deduction is done, but it's
still not valid as a template argument.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit f4e8e25c01d6ec074a7a03821e8a5ab6a8f042e9
Author: Jason Merrill <ja...@redhat.com>
Date: Mon Feb 24 00:40:41 2014 -0500
PR c++/60312
* parser.c (cp_parser_template_type_arg): Check for invalid 'auto'.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 1e98032..d99dff0 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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
index 0000000..1bc3995
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/auto-neg1.C
@@ -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" }