<p><br>
On Feb 27, 2012 12:40 PM, "Sebastian Redl" <<a href="mailto:sebastian.redl@getdesigned.at">sebastian.redl@getdesigned.at</a>> wrote:<br>
><br>
> Author: cornedbee<br>
> Date: Mon Feb 27 14:34:02 2012<br>
> New Revision: 151551<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=151551&view=rev">http://llvm.org/viewvc/llvm-project?rev=151551&view=rev</a><br>
> Log:<br>
> Convert initializer lists to temporaries in CreateBuiltinBinOp. Allows assignment of init lists to built-in types and resolves PR12088.<br>
><br>
> Modified:<br>
>    cfe/trunk/lib/Sema/SemaExpr.cpp<br>
>    cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp<br>
><br>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=151551&r1=151550&r2=151551&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=151551&r1=151550&r2=151551&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Feb 27 14:34:02 2012<br>
> @@ -7612,6 +7612,25 @@<br>
>  ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,<br>
>                                     BinaryOperatorKind Opc,<br>
>                                     Expr *LHSExpr, Expr *RHSExpr) {<br>
> +  if (getLangOptions().CPlusPlus0x && isa<InitListExpr>(RHSExpr)) {<br>
> +    // The syntax only allows initializer lists on the RHS of assignment,<br>
> +    // so we don't need to worry about accepting invalid code for<br>
> +    // non-assignment operators.<br>
> +    // C++11 5.17p9:<br>
> +    //   The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning<br>
> +    //   of x = {} is x = T().<br>
> +    InitializationKind Kind =<br>
> +        InitializationKind::CreateDirectList(RHSExpr->getLocStart());<br>
> +    InitializedEntity Entity =<br>
> +        InitializedEntity::InitializeTemporary(LHSExpr->getType());<br>
> +    InitializationSequence InitSeq(*this, Entity, Kind, &RHSExpr, 1);<br>
> +    ExprResult Init = InitSeq.Perform(*this, Entity, Kind,<br>
> +                                      MultiExprArg(&RHSExpr, 1));<br>
> +    if (Init.isInvalid())<br>
> +      return Init;<br>
> +    RHSExpr = Init.take();<br>
> +  }<br>
> +<br>
>   ExprResult LHS = Owned(LHSExpr), RHS = Owned(RHSExpr);<br>
>   QualType ResultTy;     // Result type of the binary operator.<br>
>   // The following two variables are used for compound assignment operators<br>
><br>
> Modified: cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp?rev=151551&r1=151550&r2=151551&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp?rev=151551&r1=151550&r2=151551&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp (original)<br>
> +++ cfe/trunk/test/CXX/expr/expr.ass/p9-cxx11.cpp Mon Feb 27 14:34:02 2012<br>
> @@ -11,10 +11,9 @@<br>
>   z = { 1, 2 };<br>
>   z += { 1, 2 };<br>
><br>
> -  // FIXME: implement semantics of scalar init list assignment.<br>
>   int a, b;<br>
> -  a = b = { 1 }; // unexpected-error {{incompatible type 'void'}}<br>
> -  a = { 1 } = b; // unexpected-error {{incompatible type 'void'}}<br>
> +  a = b = { 1 };<br>
> +  a = { 1 } = b;</p>
<p>This is supposed to be ill-formed. How do we handle scalar compound assignments of braced-init-lists? My reading is that such assignments are also ill formed.</p>
<p>>  }<br>
><br>
>  struct S {<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</p>