C++ ObjC++ Var(flag_diagnostics_show_template_tree) Init(0)
Print hierarchical comparisons when template types are mismatched.
+fdiagnostics-all-candidates
+C++ ObjC++ Var(flag_diagnostics_all_candidates)
+Note all candidates during overload resolution failure.
+
fdirectives-only
C ObjC C++ ObjC++
Preprocess directives only.
{
if (only_viable_p.is_true () && candidates->viable != 1)
break;
+ if (ignored_candidate_p (candidates) && !flag_diagnostics_all_candidates)
+ {
+ inform (loc, "some candidates omitted; "
+ "use %<-fdiagnostics-all-candidates%> to display them");
+ break;
+ }
print_z_candidate (loc, N_("candidate:"), candidates);
}
}
if (DECL_DELETED_FN (fn))
{
if (complain & tf_error)
- mark_used (fn);
+ {
+ mark_used (fn);
+ if (cand->next)
+ {
+ if (flag_diagnostics_all_candidates)
+ print_z_candidates (input_location, cand, /*only_viable_p=*/false);
+ else
+ inform (input_location,
+ "use %<-fdiagnostics-all-candidates%> to display "
+ "considered candidates");
+ }
+ }
return error_mark_node;
}
@item -fcoroutines
Enable support for the C++ coroutines extension (experimental).
+@opindex fdiagnostics-all-candidates
+@item -fdiagnostics-all-candidates
+Permit the C++ front end to note all candidates during overload resolution
+failure, including when a deleted function is selected.
+
@opindex fno-elide-constructors
@opindex felide-constructors
@item -fno-elide-constructors
--- /dev/null
+// Verify -fdiagnostics-all-candidates makes us note other candidates
+// when a deleted function is selected by overload resolution.
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-fdiagnostics-all-candidates" }
+
+void f(int) = delete; // { dg-message "declared here" }
+void f(...); // { dg-message "candidate" }
+void f(int, int); // { dg-message "candidate" }
+
+// An example where the perfect candidate optimization causes us
+// to ignore function templates.
+void g(int) = delete; // { dg-message "declared here" }
+template<class T> void g(T); // { dg-message "candidate" }
+
+// An example where we have a strictly viable candidate and
+// an incompletely considered bad candidate.
+template<class T> void h(T, T) = delete; // { dg-message "declared here|candidate" }
+void h(int*, int) = delete; // { dg-message "candidate" }
+
+int main() {
+ f(0); // { dg-error "deleted" }
+ g(0); // { dg-error "deleted" }
+ h(1, 1); // { dg-error "deleted" }
+ // { dg-error "invalid conversion" "" { target *-*-* } .-1 } when noting 2nd cand
+}
--- /dev/null
+// Verify we suggest -fdiagnostics-all-candidates when diagnosing
+// overload resolution selecting a deleted function.
+// { dg-do compile { target c++11 } }
+#include "deleted16.C"
+
+// { dg-error "deleted" "" { target *-*-* } 21 }
+// { dg-error "deleted" "" { target *-*-* } 22 }
+// { dg-error "deleted" "" { target *-*-* } 23 }
+
+// { dg-message "use '-fdiagnostics-all-candidates'" "" { target *-*-* } 21 }
+// { dg-message "use '-fdiagnostics-all-candidates'" "" { target *-*-* } 22 }
+// { dg-message "use '-fdiagnostics-all-candidates'" "" { target *-*-* } 23 }
// Verify we note even non-template candidates when diagnosing
// overload resolution failure for a template-id.
+// { dg-additional-options "-fdiagnostics-all-candidates" }
template<class T> void f(T); // { dg-message "candidate" }
void f(int); // { dg-message {candidate: 'void f\(int\)' \(ignored\)} }
--- /dev/null
+// Verify we suggest -fdiagnostics-all-candidates when there are
+// omitted candidates.
+#include "error6.C"
+
+// { dg-error "no match" "" { target *-*-* } 9 }
+// { dg-message "use '-fdiagnostics-all-candidates'" "" { target *-*-* } 9 }