Hi!

While these function declarations have NULL decl_specifiers->type,
they have still type specifiers specified from which the default int
in the return type is added, so we shouldn't try to parse those as
deduction guides.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2020-11-02  Jakub Jelinek  <ja...@redhat.com>

        PR c++/97663
        * parser.c (cp_parser_init_declarator): Don't try to parse
        C++17 deduction guides if there are any type specifiers even when
        type is NULL.

        * g++.dg/cpp1z/class-deduction75.C: New test.

--- gcc/cp/parser.c.jj  2020-11-02 09:24:31.000000000 +0100
+++ gcc/cp/parser.c     2020-11-02 12:16:08.650452151 +0100
@@ -20790,6 +20790,7 @@ cp_parser_init_declarator (cp_parser* pa
     {
       /* Handle C++17 deduction guides.  */
       if (!decl_specifiers->type
+         && !decl_specifiers->any_type_specifiers_p
          && ctor_dtor_or_conv_p <= 0
          && cxx_dialect >= cxx17)
        {
--- gcc/testsuite/g++.dg/cpp1z/class-deduction75.C.jj   2020-11-02 
12:28:23.234403625 +0100
+++ gcc/testsuite/g++.dg/cpp1z/class-deduction75.C      2020-11-02 
12:28:14.384500584 +0100
@@ -0,0 +1,15 @@
+// PR c++/97663
+
+template <class T> struct foo {};
+template <class T> struct bar {};
+template <class T> struct baz {};
+template <class T> struct qux {};
+template <class T> struct corge {};
+
+namespace N {
+  unsigned foo ();
+  signed bar ();
+  long baz ();
+  long long qux ();
+  short corge (); 
+}

        Jakub

Reply via email to