From 66950a32d9083727a89ea489b07b90d29f6c9b87 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 30 Sep 2009 21:46:01 +0000 Subject: When overload resolution fails for an overloaded operator, show the overload candidates (but not the built-in ones). We still rely on the underlying built-in semantic analysis to produce the initial diagnostic, then print the candidates following that diagnostic. One side advantage of this approach is that we can perform more validation of C++'s operator overloading with built-in candidates vs. the semantic analysis for those built-in operators: when there are no viable candidates, we know to expect an error from the built-in operator handling code. Otherwise, we are not modeling the built-in semantics properly within operator overloading. This is checked as: assert(Result.isInvalid() && "C++ binary operator overloading is missing candidates!"); if (Result.isInvalid()) PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false); The assert() catches cases where we're wrong in a +Asserts build. The "if" makes sure that, if this happens in a production clang (-Asserts), we still build the proper built-in operator and continue on our merry way. This is effectively what happened before this change, but we've added the assert() to catch more flies. llvm-svn: 83175 --- clang/test/SemaCXX/copy-assignment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/test/SemaCXX/copy-assignment.cpp') diff --git a/clang/test/SemaCXX/copy-assignment.cpp b/clang/test/SemaCXX/copy-assignment.cpp index 6e5012f5a7a..413e4d19336 100644 --- a/clang/test/SemaCXX/copy-assignment.cpp +++ b/clang/test/SemaCXX/copy-assignment.cpp @@ -11,7 +11,7 @@ struct ConvertibleToConstA { }; struct B { - B& operator=(B&); + B& operator=(B&); // expected-note 4 {{candidate function}} }; struct ConvertibleToB { -- cgit v1.2.3