Implement P0634R3, Down with typename!
authorMarek Polacek <polacek@redhat.com>
Sat, 1 Dec 2018 17:56:27 +0000 (17:56 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Sat, 1 Dec 2018 17:56:27 +0000 (17:56 +0000)
commit96c35892bea68ac180f19079cf08fea3b6cda0a8
tree62aac676207aaf1271e15e4b8bf28f25fd074abe
parente770ab191ca90d4d9265b5c39af456f7931b9cd6
Implement P0634R3, Down with typename!

* parser.c (CP_PARSER_FLAGS_TYPENAME_OPTIONAL): New enumerator.
(cp_parser_type_name): Remove declaration.
(cp_parser_postfix_expression): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_type_id.
(cp_parser_new_type_id): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL to
cp_parser_type_specifier_seq.
(cp_parser_lambda_declarator_opt): Pass
CP_PARSER_FLAGS_TYPENAME_OPTIONAL to
cp_parser_parameter_declaration_clause.
(cp_parser_condition): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_simple_declaration): Pass CP_PARSER_FLAGS_NONE to
cp_parser_init_declarator.
(cp_parser_conversion_type_id): Pass CP_PARSER_FLAGS_NONE to
cp_parser_type_specifier_seq.
(cp_parser_default_type_template_argument): Pass
CP_PARSER_FLAGS_TYPENAME_OPTIONAL to cp_parser_type_id.
(cp_parser_template_parameter): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_parameter_declaration.
(cp_parser_explicit_instantiation): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_simple_type_specifier): Adjust call to cp_parser_type_name
to relay if we should treat the typename keyword as optional.  Maybe
call cp_parser_make_typename_type is parsing a template-id and it's
not a TYPE_DECL.
(cp_parser_type_name): Remove unused function.
(cp_parser_enum_specifier): Pass to CP_PARSER_FLAGS_NONE
cp_parser_type_specifier_seq.
(cp_parser_alias_declaration): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_type_id.
(cp_parser_init_declarator): New parameter.  Pass it down to
cp_parser_declarator.
(cp_parser_declarator): New parameter.  Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.  Pass the new parameter to
cp_parser_direct_declarator.
(cp_parser_direct_declarator): New parameter.  Pass it to
cp_parser_parameter_declaration_clause and cp_parser_declarator.
(cp_parser_declarator_id):
(cp_parser_type_id_1): New parameter.  Pass it to
cp_parser_type_specifier_seq.  Adjust call to cp_parser_declarator.
(cp_parser_type_id): New parameter.  Pass it to cp_parser_type_id_1.
(cp_parser_template_type_arg): Pass CP_PARSER_FLAGS_NONE to
cp_parser_type_id_1.
(cp_parser_trailing_type_id): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_type_id_1.
(cp_parser_type_specifier_seq): New parameter.
(function_being_declared_is_template_p):
(cp_parser_parameter_declaration_clause): New parameter.  Pass it to
cp_parser_parameter_declaration_list.
(cp_parser_parameter_declaration_list): New parameter.  Pass it to
cp_parser_parameter_declaration.
(cp_parser_parameter_declaration): New parameter.  Pass it to
cp_parser_decl_specifier_seq.  Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_member_declaration): Adjust call to
cp_parser_decl_specifier_seq to also include
CP_PARSER_FLAGS_TYPENAME_OPTIONAL.  Pass
CP_PARSER_FLAGS_TYPENAME_OPTIONAL to cp_parser_declarator.
(cp_parser_exception_declaration): Pass CP_PARSER_FLAGS_NONE to
cp_parser_type_specifier_seq and cp_parser_declarator.
(cp_parser_requirement_parameter_list): Pass CP_PARSER_FLAGS_NONE to
cp_parser_parameter_declaration_clause.
(cp_parser_constructor_declarator_p): Resolve the TYPENAME_TYPE.
(cp_parser_single_declaration): Pass CP_PARSER_FLAGS_TYPENAME_OPTIONAL
to cp_parser_decl_specifier_seq and cp_parser_init_declarator.
(cp_parser_cache_defarg): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator and cp_parser_parameter_declaration_list.
(cp_parser_objc_method_tail_params_opt): Pass CP_PARSER_FLAGS_NONE to
cp_parser_parameter_declaration.
(cp_parser_objc_class_ivars): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_objc_try_catch_finally_statement): Pass CP_PARSER_FLAGS_NONE
to cp_parser_parameter_declaration
(cp_parser_objc_struct_declaration): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator.
(cp_parser_omp_for_loop_init): Pass CP_PARSER_FLAGS_NONE to
cp_parser_declarator and cp_parser_type_specifier_seq.

* g++.dg/cpp0x/alias-decl-43.C: Adjust dg-error.
* g++.dg/cpp0x/decltype67.C: Only expect error in c++17_down.
* g++.dg/cpp1z/typename1.C: New test.
* g++.dg/cpp2a/typename1.C: New test.
* g++.dg/cpp2a/typename10.C: New test.
* g++.dg/cpp2a/typename11.C: New test.
* g++.dg/cpp2a/typename2.C: New test.
* g++.dg/cpp2a/typename3.C: New test.
* g++.dg/cpp2a/typename4.C: New test.
* g++.dg/cpp2a/typename5.C: New test.
* g++.dg/cpp2a/typename6.C: New test.
* g++.dg/cpp2a/typename7.C: New test.
* g++.dg/cpp2a/typename8.C: New test.
* g++.dg/cpp2a/typename9.C: New test.
* g++.dg/diagnostic/missing-typename.C: Only run the test in
c++17_down.
* g++.dg/other/crash-9.C: Add template disambiguator.
* g++.dg/other/nontype-1.C: Only expect error in c++17_down.
* g++.dg/parse/crash13.C: Likewise.
* g++.dg/parse/error36.C: Likewise.
* g++.dg/parse/no-typename1.C: Likewise.
* g++.dg/parse/typedef2.C: Likewise.
* g++.dg/parse/typename11.C: Likewise.
* g++.dg/template/crash48.C: Adjust dg-error.
* g++.dg/template/dependent-name5.C: Only expect error in c++17_down.
Add dg-error.
* g++.dg/template/error29.C: Only expect error in c++17_down.
* g++.dg/template/nested5.C: Add template disambiguator.
* g++.dg/template/pr84789.C: Only expect error in c++17_down.
* g++.dg/template/static30.C: Add dg-error.
* g++.dg/template/typedef6.C: Adjust dg-error.
* g++.dg/template/typename3.C: Only expect error in c++17_down.

From-SVN: r266710
33 files changed:
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/alias-decl-43.C
gcc/testsuite/g++.dg/cpp0x/decltype67.C
gcc/testsuite/g++.dg/cpp1z/typename1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp2a/typename9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/diagnostic/missing-typename.C
gcc/testsuite/g++.dg/other/crash-9.C
gcc/testsuite/g++.dg/other/nontype-1.C
gcc/testsuite/g++.dg/parse/crash13.C
gcc/testsuite/g++.dg/parse/error36.C
gcc/testsuite/g++.dg/parse/no-typename1.C
gcc/testsuite/g++.dg/parse/typedef2.C
gcc/testsuite/g++.dg/parse/typename11.C
gcc/testsuite/g++.dg/template/crash48.C
gcc/testsuite/g++.dg/template/dependent-name5.C
gcc/testsuite/g++.dg/template/error29.C
gcc/testsuite/g++.dg/template/nested5.C
gcc/testsuite/g++.dg/template/pr84789.C
gcc/testsuite/g++.dg/template/static30.C
gcc/testsuite/g++.dg/template/typedef6.C
gcc/testsuite/g++.dg/template/typename3.C