On Wed, Aug 15, 2012 at 03:39:29PM +0000, Joseph S. Myers wrote: > On Wed, 18 Jul 2012, Jakub Jelinek wrote: > > > + if (warn_sizeof_pointer_memaccess > > + && sizeof_arg != NULL_TREE) > > + sizeof_pointer_memaccess_warning (c_last_sizeof_arg_loc, > > + expr.value, exprlist, > > + sizeof_arg, > > + sizeof_ptr_memacc_comptypes); > > Why do you pass a local variable sizeof_arg but a global > c_last_sizeof_arg_loc here? I'd have expected the same approach to apply > for both arguments (e.g. passing down a pointer to a location alongside > &sizeof_arg).
I guess I could pass it the same way as sizeof_arg or stick the location_t into sizeof_arg (surround the value into NOP_EXPR with the location_t). I was mainly interested in whether such an approach is acceptable, or whether I need to stop evaluating sizeof right away, create SIZEOF_EXPR and only fold it during fully_fold*. I've briefly looked at that today, and see several problems with that though: 1) fully_fold* is in c-family/, so can't use e.g. c_vla_type_p (at least not easily, it could use a langhook) 2) c_expr_sizeof_{expr,type} currently calls pop_maybe_used, I don't see how that could be easily deferred till later when the expression is fully folded. So, we might need to do what c_expr_sizeof_{expr,type} does right now (including fully folding), to call pop_maybe_used with the right argument, and then either create SIZEOF_EXPR with the original argument and fully fold it again during fully folding of the SIZEOF_EXPR, or add an argument to SIZEOF_EXPR which would contain the folded expression (i.e. have two arguments, the original expression and the value of the sizeof). Jakub