On Wed, Aug 28, 2013 at 2:54 PM, Richard Smith <[email protected]>wrote:
> On Wed, Aug 28, 2013 at 1:35 PM, Eli Friedman <[email protected]>wrote: > >> Author: efriedma >> Date: Wed Aug 28 15:35:35 2013 >> New Revision: 189510 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=189510&view=rev >> Log: >> Improve error for assignment to incomplete class. >> >> PR7681. >> >> Modified: >> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> cfe/trunk/lib/Sema/SemaOverload.cpp >> cfe/trunk/test/SemaCXX/overloaded-operator.cpp >> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=189510&r1=189509&r2=189510&view=diff >> >> ============================================================================== >> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Aug 28 >> 15:35:35 2013 >> @@ -2752,6 +2752,7 @@ def err_ovl_ambiguous_oper_unary : Error >> def err_ovl_ambiguous_oper_binary : Error< >> "use of overloaded operator '%0' is ambiguous (with operand types %1 >> and %2)">; >> def err_ovl_no_viable_oper : Error<"no viable overloaded '%0'">; >> +def note_assign_lhs_incomplete : Note<"type %0 is incomplete">; >> def err_ovl_deleted_oper : Error< >> "overload resolution selected %select{unavailable|deleted}0 operator >> '%1'%2">; >> def err_ovl_deleted_special_oper : Error< >> >> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=189510&r1=189509&r2=189510&view=diff >> >> ============================================================================== >> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Aug 28 15:35:35 2013 >> @@ -10714,6 +10714,11 @@ Sema::CreateOverloadedBinOp(SourceLocati >> Diag(OpLoc, diag::err_ovl_no_viable_oper) >> << BinaryOperator::getOpcodeStr(Opc) >> << Args[0]->getSourceRange() << Args[1]->getSourceRange(); >> + if (Args[0]->getType()->isIncompleteType()) { >> + Diag(OpLoc, diag::note_assign_lhs_incomplete) >> + << Args[0]->getType() >> + << Args[0]->getSourceRange() << Args[1]->getSourceRange(); >> + } >> > > 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 '='. > > > 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. -Eli
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
