aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-modref.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-11-18 13:10:28 -0500
committerPatrick Palka <ppalka@redhat.com>2021-11-18 13:10:28 -0500
commit53c964ad996a1bb22566b987eafb333b5899deab (patch)
tree2895631da6d0cd3b4d5dfaf2794d889f5799ba25 /gcc/ipa-modref.c
parent75ac95f6647367783c4d65f6f686867ca425cb61 (diff)
downloadgcc-53c964ad996a1bb22566b987eafb333b5899deab.zip
gcc-53c964ad996a1bb22566b987eafb333b5899deab.tar.gz
gcc-53c964ad996a1bb22566b987eafb333b5899deab.tar.bz2
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.
Diffstat (limited to 'gcc/ipa-modref.c')
0 files changed, 0 insertions, 0 deletions