r185056 - Fix a conversion to incomplete type bug -- The error message now specifically states that the type is incomplete and points to the forward declaration of the incomplete type.

Eli Friedman eli.friedman at gmail.com
Wed Jun 26 19:09:05 PDT 2013


On Wed, Jun 26, 2013 at 6:50 PM, Larisse Voufo <lvoufo at google.com> wrote:

> Author: lvoufo
> Date: Wed Jun 26 20:50:25 2013
> New Revision: 185056
>
> URL: http://llvm.org/viewvc/llvm-project?rev=185056&view=rev
> Log:
> Fix a conversion to incomplete type bug -- The error message now
> specifically states that the type is incomplete and points to the forward
> declaration of the incomplete type.
>
> Added:
>     cfe/trunk/test/SemaCXX/conversion-incomplete-type.cpp
> Modified:
>     cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>     cfe/trunk/lib/Sema/SemaInit.cpp
>     cfe/trunk/lib/Sema/SemaOverload.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=185056&r1=185055&r2=185056&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 26
> 20:50:25 2013
> @@ -5014,6 +5014,8 @@ def err_typecheck_ambiguous_condition :
>    "conversion %diff{from $ to $|between types}0,1 is ambiguous">;
>  def err_typecheck_nonviable_condition : Error<
>    "no viable conversion%diff{ from $ to $|}0,1">;
> +def err_typecheck_nonviable_condition_incomplete : Error<
> +  "no viable conversion%diff{ from $ to incomplete type $|}0,1">;
>  def err_typecheck_deleted_function : Error<
>    "conversion function %diff{from $ to $|between types}0,1 "
>    "invokes a deleted function">;
>
> Modified: cfe/trunk/lib/Sema/SemaInit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=185056&r1=185055&r2=185056&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaInit.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Jun 26 20:50:25 2013
> @@ -6251,9 +6251,15 @@ bool InitializationSequence::Diagnose(Se
>        break;
>
>      case OR_No_Viable_Function:
> -      S.Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
> -        << Args[0]->getType() << DestType.getNonReferenceType()
> -        << Args[0]->getSourceRange();
> +      if (!DestType.getNonReferenceType()->isIncompleteType() ||
> +          !S.RequireCompleteType(Kind.getLocation(),
> +                                 DestType.getNonReferenceType(),
> +
>  diag::err_typecheck_nonviable_condition_incomplete,
> +                               Args[0]->getType(),
> Args[0]->getSourceRange()))
> +        S.Diag(Kind.getLocation(),
> diag::err_typecheck_nonviable_condition)
> +          << Args[0]->getType() << Args[0]->getSourceRange()
> +          << DestType.getNonReferenceType();
>
> You don't need to call isIncompleteType() before calling
RequireCompleteType().

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130626/55c5cff6/attachment.html>


More information about the cfe-commits mailing list