From c026e33449102076609e084ca2cd4a729b3c504b Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Tue, 6 Aug 2019 02:23:43 +0000 Subject: [PATCH] DR 2413 - typename in conversion-function-ids. * parser.c (cp_parser_conversion_type_id): Call cp_parser_type_specifier_seq with CP_PARSER_FLAGS_TYPENAME_OPTIONAL instead of CP_PARSER_FLAGS_NONE. * g++.dg/cpp2a/typename17.C: New test. From-SVN: r274136 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/parser.c | 5 +++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp2a/typename17.C | 6 ++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/typename17.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6427c2dac86..049863edf8e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2019-08-05 Marek Polacek + + DR 2413 - typename in conversion-function-ids. + * parser.c (cp_parser_conversion_type_id): Call + cp_parser_type_specifier_seq with CP_PARSER_FLAGS_TYPENAME_OPTIONAL + instead of CP_PARSER_FLAGS_NONE. + 2019-08-05 Paolo Carlini * cp-tree.h (cp_expr_loc_or_input_loc): New. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 86857e7d468..83e6d24a9c1 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14844,8 +14844,9 @@ cp_parser_conversion_type_id (cp_parser* parser) parser->type_definition_forbidden_message = G_("types may not be defined in a conversion-type-id"); - /* Parse the type-specifiers. */ - cp_parser_type_specifier_seq (parser, CP_PARSER_FLAGS_NONE, + /* Parse the type-specifiers. DR 2413 clarifies that `typename' is + optional in conversion-type-id. */ + cp_parser_type_specifier_seq (parser, CP_PARSER_FLAGS_TYPENAME_OPTIONAL, /*is_declaration=*/false, /*is_trailing_return=*/false, &type_specifiers); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4af533613a..b78e6b1d56e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-05 Marek Polacek + + DR 2413 - typename in conversion-function-ids. + * g++.dg/cpp2a/typename17.C: New test. + 2019-08-05 Martin Sebor PR middle-end/50476 diff --git a/gcc/testsuite/g++.dg/cpp2a/typename17.C b/gcc/testsuite/g++.dg/cpp2a/typename17.C new file mode 100644 index 00000000000..bf534f1717f --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/typename17.C @@ -0,0 +1,6 @@ +// DR 2413 - typename in conversion-function-ids. +// { dg-do compile { target c++2a } } + +template struct S { + operator T::X(); +}; -- 2.30.2