DR 2413 - typename in conversion-function-ids.
authorMarek Polacek <polacek@redhat.com>
Tue, 6 Aug 2019 02:23:43 +0000 (02:23 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 6 Aug 2019 02:23:43 +0000 (02:23 +0000)
* 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
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/typename17.C [new file with mode: 0644]

index 6427c2d..049863e 100644 (file)
@@ -1,3 +1,10 @@
+2019-08-05  Marek Polacek  <polacek@redhat.com>
+
+       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  <paolo.carlini@oracle.com>
 
        * cp-tree.h (cp_expr_loc_or_input_loc): New.
index 86857e7..83e6d24 100644 (file)
@@ -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);
index a4af533..b78e6b1 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-05  Marek Polacek  <polacek@redhat.com>
+
+       DR 2413 - typename in conversion-function-ids.
+       * g++.dg/cpp2a/typename17.C: New test.
+
 2019-08-05  Martin Sebor  <msebor@redhat.com>
 
        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 (file)
index 0000000..bf534f1
--- /dev/null
@@ -0,0 +1,6 @@
+// DR 2413 - typename in conversion-function-ids.
+// { dg-do compile { target c++2a } }
+
+template<class T> struct S {
+  operator T::X();
+};