[PATCH] Fix PR18473 - Set NullType of ParenListExpr to Void (Similar to what's done for InitListExpr)

Richard Smith richard at metafoo.co.uk
Thu Feb 6 15:50:04 PST 2014


  I don't think this patch does the right thing: in your first example it makes the `ParenListExpr` for `(1)` have non-dependent type `void` and not be value-dependent. Then we'll try evaluating it inside the lambda, and evaluation will fail (because it doesn't make sense to evaluate a `ParenListExpr`), and we'll conclude that the initializer for `l` can never be constant. I think if you remove the `static` from that example, you'll reject valid (because you'll incorrectly conclude that `l` is captured but cannot be).

  I committed a different fix for the original issue in r200954, but I think this is still worth dealing with. It's not good to have non-value-dependent expressions that we can't actually evaluate, but I think the right approach here is to make the initializer expression value-dependent in this case, not to make it 'void'.


================
Comment at: lib/Sema/SemaExpr.cpp:5250
@@ -5249,2 +5249,3 @@
   Expr *expr = new (Context) ParenListExpr(Context, L, Val, R);
+  expr->setType(Context.VoidTy); // FIXME: just a place holder for now.
   return Owned(expr);
----------------
How about doing this slightly differently: in `InitializationSequence::Perform`, when we rebuild a dependent sequence, pass the type of the initialized object to the created `ParenListExpr` or `InitListExpr` (if any), and set the object to be type-, value- and instantiation-dependent if said type is dependent. Then, use `VoidTy` as the type in the case where we aren't creating the `ParenListExpr` from a dependent initialization sequence.


http://llvm-reviews.chandlerc.com/D2575



More information about the cfe-commits mailing list