PR c++/84798 - ICE with auto in abstract function declarator.
authorJason Merrill <jason@redhat.com>
Tue, 13 Mar 2018 15:55:07 +0000 (11:55 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 13 Mar 2018 15:55:07 +0000 (11:55 -0400)
* parser.c (cp_parser_parameter_declaration_clause): Check
parser->default_arg_ok_p.

From-SVN: r258493

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

index 9b5f0c36663b9ccf8a9abda06753c2fecfee5a8d..d480c1bafba0c9de77bac149d6108d9836cf1a7a 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/84798 - ICE with auto in abstract function declarator.
+       * parser.c (cp_parser_parameter_declaration_clause): Check
+       parser->default_arg_ok_p.
+
 2018-03-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/84808
index cdc6238897322b7d5c43986e984981ca3762f530..8e8ebceb0d584cd65996c87011fc1b2720744258 100644 (file)
@@ -21198,7 +21198,10 @@ cp_parser_parameter_declaration_clause (cp_parser* parser)
 
   if (!processing_specialization
       && !processing_template_parmlist
-      && !processing_explicit_instantiation)
+      && !processing_explicit_instantiation
+      /* default_arg_ok_p tracks whether this is a parameter-clause for an
+         actual function or a random abstract declarator.  */
+      && parser->default_arg_ok_p)
     if (!current_function_decl
        || (current_class_type && LAMBDA_TYPE_P (current_class_type)))
       parser->auto_is_implicit_function_template_parm_p = true;
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto51.C b/gcc/testsuite/g++.dg/cpp0x/auto51.C
new file mode 100644 (file)
index 0000000..dfb0833
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/84798
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+struct S {
+    static constexpr T value = 0;
+};
+
+constexpr auto x = S<void(*)(auto)>::value; // { dg-error "auto" }
index 27fe2b722960f7ab424b541e948778f74ac4d1e4..2ae21ed1147b49765fd0bafac0179cbd64ac7a1d 100644 (file)
@@ -1,8 +1,7 @@
 // PR c++/60393
 // { dg-do compile { target c++14 } }
-// { dg-options "" }
 
-void (*f)(auto) + 0; // { dg-error "expected" }
+void (*f)(auto) + 0; // { dg-error "auto|expected" }
 
 struct A
 {