mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-05 07:40:28 +08:00
c++: Don't try to parse a function declaration as deduction guide [PR97663]
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. 2020-11-03 Jakub Jelinek <jakub@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.
This commit is contained in:
parent
9f925f3b19
commit
875225301e
@ -20790,6 +20790,7 @@ cp_parser_init_declarator (cp_parser* parser,
|
||||
{
|
||||
/* Handle C++17 deduction guides. */
|
||||
if (!decl_specifiers->type
|
||||
&& !decl_specifiers->any_type_specifiers_p
|
||||
&& ctor_dtor_or_conv_p <= 0
|
||||
&& cxx_dialect >= cxx17)
|
||||
{
|
||||
|
15
gcc/testsuite/g++.dg/cpp1z/class-deduction75.C
Normal file
15
gcc/testsuite/g++.dg/cpp1z/class-deduction75.C
Normal file
@ -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 ();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user