r182624 - Fix crash-on-invalid if list-initialization works, but we bail out when

Richard Smith richard at metafoo.co.uk
Thu May 23 16:23:32 PDT 2013


Hi Bill, please pull this onto the branch.

On Thu, May 23, 2013 at 4:20 PM, Richard Smith
<richard-llvm at metafoo.co.uk>wrote:

> Author: rsmith
> Date: Thu May 23 18:20:04 2013
> New Revision: 182624
>
> URL: http://llvm.org/viewvc/llvm-project?rev=182624&view=rev
> Log:
> Fix crash-on-invalid if list-initialization works, but we bail out when
> building the resulting expression because it invokes a deleted constructor.
>
> Modified:
>     cfe/trunk/lib/Sema/SemaInit.cpp
>     cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaInit.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=182624&r1=182623&r2=182624&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaInit.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaInit.cpp Thu May 23 18:20:04 2013
> @@ -5745,7 +5745,8 @@ InitializationSequence::Perform(Sema &S,
>          ExprResult Res = S.PerformCopyInitialization(
>                               Element, Init.get()->getExprLoc(), Init,
>                               /*TopLevelOfInitList=*/ true);
> -        assert(!Res.isInvalid() && "Result changed since try phase.");
> +        if (Res.isInvalid())
> +          return ExprError();
>          Converted[i] = Res.take();
>        }
>        InitListExpr *Semantic = new (S.Context)
>
> Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=182624&r1=182623&r2=182624&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
> (original)
> +++ cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Thu
> May 23 18:20:04 2013
> @@ -208,3 +208,13 @@ namespace init_list_deduction_failure {
>    void h() { g({f}); }
>    // expected-error at -1 {{no matching function for call to 'g'}}
>  }
> +
> +namespace deleted_copy {
> +  struct X {
> +    X(int i) {}
> +    X(const X& x) = delete; // expected-note {{here}}
> +    void operator=(const X& x) = delete;
> +  };
> +
> +  std::initializer_list<X> x{1}; // expected-error {{invokes deleted
> constructor}}
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130523/c1507e43/attachment.html>


More information about the cfe-commits mailing list