<div dir="ltr">On Wed, Aug 28, 2013 at 2:54 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div class="h5">On Wed, Aug 28, 2013 at 1:35 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span> wrote:<br>
</div></div><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: efriedma<br>
Date: Wed Aug 28 15:35:35 2013<br>
New Revision: 189510<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=189510&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=189510&view=rev</a><br>
Log:<br>
Improve error for assignment to incomplete class.<br>
<br>
PR7681.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
cfe/trunk/lib/Sema/SemaOverload.cpp<br>
cfe/trunk/test/SemaCXX/overloaded-operator.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=189510&r1=189509&r2=189510&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=189510&r1=189509&r2=189510&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Aug 28 15:35:35 2013<br>
@@ -2752,6 +2752,7 @@ def err_ovl_ambiguous_oper_unary : Error<br>
def err_ovl_ambiguous_oper_binary : Error<<br>
"use of overloaded operator '%0' is ambiguous (with operand types %1 and %2)">;<br>
def err_ovl_no_viable_oper : Error<"no viable overloaded '%0'">;<br>
+def note_assign_lhs_incomplete : Note<"type %0 is incomplete">;<br>
def err_ovl_deleted_oper : Error<<br>
"overload resolution selected %select{unavailable|deleted}0 operator '%1'%2">;<br>
def err_ovl_deleted_special_oper : Error<<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=189510&r1=189509&r2=189510&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=189510&r1=189509&r2=189510&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Aug 28 15:35:35 2013<br>
@@ -10714,6 +10714,11 @@ Sema::CreateOverloadedBinOp(SourceLocati<br>
Diag(OpLoc, diag::err_ovl_no_viable_oper)<br>
<< BinaryOperator::getOpcodeStr(Opc)<br>
<< Args[0]->getSourceRange() << Args[1]->getSourceRange();<br>
+ if (Args[0]->getType()->isIncompleteType()) {<br>
+ Diag(OpLoc, diag::note_assign_lhs_incomplete)<br>
+ << Args[0]->getType()<br>
+ << Args[0]->getSourceRange() << Args[1]->getSourceRange();<br>
+ }<br></blockquote><div><br></div></div></div><div>Is there a reason to not use RequireCompleteType here? It'd be nice to at least point the note at the forward declaration of the class rather than at the '='.</div>
<div class="im">
<div> </div><div><br></div></div></div></div></div></blockquote><div><br></div><div>You mean, use RequireCompleteType to print an alternative error message? That could work; I hadn't thought of it because the error is only indirectly caused by the fact that the type is incomplete.</div>
<div><br></div><div>-Eli </div></div><br></div></div>