68f37670ef
In case of l/rvalue or cv-qual mismatch during reference binding, we try to give more helpful diagnostics by computing a bad conversion that allows the mismatch. But in doing so, we may end up considering and instantiating a conversion function that could induce a hard error and in turn cause us to reject otherwise valid code. We could just give up on producing a better diagnostic here, but ideally we'd preserve the better diagnostics for invalid code while avoiding unnecessary template instantiations for valid code. To that end, this patch adapts the bad conversion shortcutting mechanism from r12-3346-g47543e5f9d1fc5 to additionally handle this situation. The main observation from there is that during overload resolution, if we know we have a strictly viable candidate then we don't need to distinguish between an unviable and non-strictly viable candidate. Thus we don't need to distinguish between an invalid and bad conversion either, which is what this patch exploits. Of course, we don't know whether we have a strictly viable candidate until after the fact, so we still need to remember when we deferred distinguishing between an invalid and bad conversion. This patch adds a special conversion kind ck_deferred_bad for this purpose. PR c++/94894 PR c++/105766 PR c++/106201 gcc/cp/ChangeLog: * call.cc (enum conversion_kind): Add ck_deferred_bad enumerator. (has_next): Return false for it. (reference_binding): Return a ck_deferred_bad conversion instead of an actual bad conversion when LOOKUP_SHORTCUT_BAD_CONVS is set. Remove now obsolete early exit for the incomplete TO case. (implicit_conversion_1): Don't mask out LOOKUP_SHORTCUT_BAD_CONVS. (add_function_candidate): Set LOOKUP_SHORTCUT_BAD_CONVS iff shortcut_bad_convs. (missing_conversion_p): Also return true for a ck_deferred_bad conversion. * cp-tree.h (LOOKUP_SHORTCUT_BAD_CONVS): Define. gcc/testsuite/ChangeLog: * g++.dg/conversion/ref8.C: New test. * g++.dg/conversion/ref9.C: New test. |
||
---|---|---|
c++tools | ||
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcody | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libiberty | ||
libitm | ||
libobjc | ||
liboffloadmic | ||
libphobos | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ar-lib | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
symlink-tree | ||
test-driver | ||
ylwrap |
This directory contains the GNU Compiler Collection (GCC). The GNU Compiler Collection is free software. See the files whose names start with COPYING for copying permission. The manuals, and some of the runtime libraries, are under different terms; see the individual source files for details. The directory INSTALL contains copies of the installation information as HTML and plain text. The source of this information is gcc/doc/install.texi. The installation information includes details of what is included in the GCC sources and what files GCC installs. See the file gcc/doc/gcc.texi (together with other files that it includes) for usage and porting information. An online readable version of the manual is in the files gcc/doc/gcc.info*. See http://gcc.gnu.org/bugs/ for how to report bugs usefully. Copyright years on GCC source files may be listed using range notation, e.g., 1987-2012, indicating that every year in the range, inclusive, is a copyrightable year that could otherwise be listed individually.