gcc/libcc1
Patrick Palka a6ee556c76 c++: Fix return type deduction with an abbreviated function template
This patch fixes two issues with return type deduction in the presence of an
abbreviated function template.

The first issue (PR 69448) is that if a placeholder auto return type contains
any modifiers such as & or *, then the abbreviated function template
compensation in splice_late_return_type does not get performed for the
underlying auto node, leading to incorrect return type deduction.  This happens
because splice_late_return_type does not consider that a placeholder auto return
type might have modifiers.  To fix this it seems we need to look through
modifiers in the return type to obtain the location of the underlying auto node
in order to replace it with the adjusted auto node.  To that end this patch
refactors the utility function find_type_usage to return a pointer to the
matched tree, and uses it to find and replace the underlying auto node.

The second issue (PR 80471) is that the AUTO_IS_DECLTYPE flag is not being
preserved in splice_late_return_type when compensating for an abbreviated
function template, leading to us treating a decltype(auto) return type as if it
was an auto return type.  Fixed by making make_auto_1 set the AUTO_IS_DECLTYPE
flag whenever we're building a decltype(auto) node and adjusting callers
appropriately.  The test for PR 80471 is adjusted to expect the correct
behavior.

gcc/cp/ChangeLog:

	PR c++/69448
	PR c++/80471
	* type-utils.h (find_type_usage): Refactor to take a tree * and to
	return a tree *, and update documentation accordingly.
	* pt.c (make_auto_1): Set AUTO_IS_DECLTYPE when building a
	decltype(auto) node.
	(make_constrained_decltype_auto): No need to explicitly set
	AUTO_IS_DECLTYPE anymore.
	(splice_late_return_type): Use find_type_usage to find and
	replace a possibly nested auto node instead of using is_auto.
	Check test for is_auto into an assert when deciding whether
	to late_return_type.
	(type_uses_auto): Adjust the call to find_type_usage.
	* parser.c (cp_parser_decltype): No need to explicitly set
	AUTO_IS_DECLTYPE anymore.

libcc1/ChangeLog:

	PR c++/69448
	PR c++/80471
	* libcp1plugin.cc (plugin_get_expr_type): No need to explicitly set
	AUTO_IS_DECLTYPE anymore.

gcc/testsuite/ChangeLog:

	PR c++/69448
	PR c++/80471
	* g++.dg/concepts/abbrev3.C: New test.
	* g++.dg/cpp2a/concepts-pr80471.C: Adjust a static_assert to expect the
	correct behavior.
	* g++.dg/cpp0x/auto9.C: Adjust a dg-error directive.
2020-02-10 20:43:53 -05:00
..
ChangeLog c++: Fix return type deduction with an abbreviated function template 2020-02-10 20:43:53 -05:00
Makefile.am Update copyright years. 2020-01-01 12:51:42 +01:00
Makefile.in Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
aclocal.m4 Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856). 2018-10-31 17:03:16 +00:00
callbacks.cc Update copyright years. 2020-01-01 12:51:42 +01:00
callbacks.hh Update copyright years. 2020-01-01 12:51:42 +01:00
cc1plugin-config.h.in
compiler-name.hh Update copyright years. 2020-01-01 12:51:42 +01:00
configure Regenerate `configure' scripts for `uclinuxfdpiceabi' libtool.m4 update 2019-09-27 21:24:42 +00:00
configure.ac Update copyright years. 2020-01-01 12:51:42 +01:00
connection.cc Update copyright years. 2020-01-01 12:51:42 +01:00
connection.hh Update copyright years. 2020-01-01 12:51:42 +01:00
findcomp.cc Update copyright years. 2020-01-01 12:51:42 +01:00
findcomp.hh Update copyright years. 2020-01-01 12:51:42 +01:00
libcc1.cc Update copyright years. 2020-01-01 12:51:42 +01:00
libcc1.sym Introduce C++ support in libcc1 2017-01-31 01:02:03 +00:00
libcc1plugin.cc Update copyright years. 2020-01-01 12:51:42 +01:00
libcc1plugin.sym
libcp1.cc Update copyright years. 2020-01-01 12:51:42 +01:00
libcp1plugin.cc c++: Fix return type deduction with an abbreviated function template 2020-02-10 20:43:53 -05:00
libcp1plugin.sym Introduce C++ support in libcc1 2017-01-31 01:02:03 +00:00
marshall-c.hh Update copyright years. 2020-01-01 12:51:42 +01:00
marshall-cp.hh Update copyright years. 2020-01-01 12:51:42 +01:00
marshall.cc Update copyright years. 2020-01-01 12:51:42 +01:00
marshall.hh Update copyright years. 2020-01-01 12:51:42 +01:00
names.cc Update copyright years. 2020-01-01 12:51:42 +01:00
names.hh Update copyright years. 2020-01-01 12:51:42 +01:00
rpc.hh Update copyright years. 2020-01-01 12:51:42 +01:00
status.hh Update copyright years. 2020-01-01 12:51:42 +01:00