Patrick Palka 53c964ad99 c++: error recovery during C++20 template-id ADL failure
When diagnosing ADL failure we try to perform a second unqualified
lookup for backwards compatibility with legacy code (via -fpermissive),
and for better diagnostics.

But for C++20 template-id ADL, the backwards compatibility code
sometimes causes confusing subsequent diagnostics such as in the
testcase below where we end up diagnosing deduction failure after
emitting the helpful "no declarations were found by ADL".  This happens
because the code just discards the arguments of the template-id callee
when replacing it with the later-declared template, which leads to
overload resolution failure:

  <stdin>: In instantiation of ‘void f() [with T = int]’:
  <stdin>:12:22:   required from here
  <stdin>:5:9: error: ‘g’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
  <stdin>:10:6: note: ‘template<class T> void g(int)’ declared here, later in the translation unit
  <stdin>:5:9: error: no matching function for call to ‘g(int)’
  <stdin>:10:6: note: candidate: ‘template<class T> void g(int)’
  <stdin>:10:6: note:   template argument deduction/substitution failed:
  <stdin>:5:9: note:   couldn’t deduce template parameter ‘T’

So for C++20 template-id ADL, this patch disables the backwards
compatibility code while keeping the helpful "no declarations were
found by ADL" diagnostic.

gcc/cp/ChangeLog:

	* pt.c (tsubst_copy_and_build) <case CALL_EXPR>: Disable the
	-fpermissive fallback for C++20 template-id ADL, but keep the
	diagnostic.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/fn-template25.C: New test.
2021-11-18 13:10:28 -05:00
2021-10-27 00:16:33 +00:00
2021-11-09 00:16:21 +00:00
2021-11-14 00:16:23 +00:00
2021-10-23 00:16:26 +00:00
2021-11-13 00:16:39 +00:00
2021-10-23 00:16:26 +00:00
2021-11-13 00:16:39 +00:00
2021-11-02 00:16:32 +00:00
2021-11-18 00:16:34 +00:00
2021-10-23 00:16:26 +00:00
2021-11-16 00:16:31 +00:00
2021-11-12 00:16:32 +00:00
2021-10-19 00:16:23 +00:00
2021-11-18 10:26:55 -05:00
2021-10-23 00:16:26 +00:00
2021-10-20 00:16:43 +00:00
2021-11-01 00:16:20 +00:00
2021-11-17 00:16:29 +00:00

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.
Description
No description provided
Readme 3.1 GiB
Languages
C 48%
Ada 18.3%
C++ 14.1%
Go 7%
GCC Machine Description 4.6%
Other 7.7%