Implement return type deduction for normal functions with -std=c++1y.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 24 Mar 2012 20:56:08 +0000 (20:56 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 24 Mar 2012 20:56:08 +0000 (20:56 +0000)
commit86359a653cbb9f4042735a8e42a1fbdbb7bf59f4
treef4083b8417d9f0e518dd8e9e301138cb94c4b2a5
parent40715742ef33b983ed8a40b135f6acfcdbbde2d0
Implement return type deduction for normal functions with -std=c++1y.
* cp-tree.h (FNDECL_USED_AUTO): New macro.
(LAMBDA_EXPR_DEDUCE_RETURN_TYPE_P): Remove.
(dependent_lambda_return_type_node): Remove.
(CPTI_DEPENDENT_LAMBDA_RETURN_TYPE): Remove.
(struct language_function): Add x_auto_return_pattern field.
(current_function_auto_return_pattern): New.
(enum tsubst_flags): Add tf_partial.
* decl.c (decls_match): Handle auto return comparison.
(duplicate_decls): Adjust error message for auto return.
(cxx_init_decl_processing): Remove dependent_lambda_return_type_node.
(cp_finish_decl): Don't do auto deduction for functions.
(grokdeclarator): Allow auto return without trailing return type in
C++1y mode.
(check_function_type): Defer checking of deduced return type.
(start_preparsed_function): Set current_function_auto_return_pattern.
(finish_function): Set deduced return type to void if not previously
deduced.
* decl2.c (change_return_type): Handle error_mark_node.
(mark_used): Always instantiate functions with deduced return type.
Complain about use if deduction isn't done.
* parser.c (cp_parser_lambda_declarator_opt): Use 'auto' for
initial return type.
(cp_parser_lambda_body): Don't deduce return type in a template.
(cp_parser_conversion_type_id): Allow auto in C++1y.
* pt.c (instantiate_class_template_1): Don't mess with
LAMBDA_EXPR_DEDUCE_RETURN_TYPE_P.
(tsubst_copy_and_build): Likewise.
(fn_type_unification, tsubst): Don't reduce the template parm level
of 'auto' during deduction.
(unify): Compare 'auto' specially.
(get_bindings): Change test.
(always_instantiate_p): Always instantiate functions with deduced
return type.
(do_auto_deduction): Handle error_mark_node and lambda context.
Don't check for use in initializer.
(contains_auto_r): Remove.
* search.c (lookup_conversions_r): Handle auto conversion function.
* semantics.c (lambda_return_type): Handle null return.  Don't mess
with dependent_lambda_return_type_node.
(apply_deduced_return_type): Rename from apply_lambda_return_type.
* typeck.c (merge_types): Handle auto.
(check_return_expr): Do auto deduction.
* typeck2.c (add_exception_specifier): Fix complain check.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185768 138bc75d-0d04-0410-961f-82ee72b054a4
30 files changed:
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/search.c
gcc/cp/semantics.c
gcc/cp/typeck.c
gcc/cp/typeck2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/auto18.C
gcc/testsuite/g++.dg/cpp0x/auto3.C
gcc/testsuite/g++.dg/cpp0x/trailing2.C
gcc/testsuite/g++.dg/cpp1y/auto-fn1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn12.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn13.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1y/auto-fn9.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/pr38639.C
gcc/testsuite/g++.dg/warn/pr23075.C
gcc/testsuite/g++.old-deja/g++.pt/spec22.C