On Thu, 9 Jun 2011, Jason Merrill wrote: > On 06/07/2011 10:24 AM, Jason Merrill wrote: > > On 06/07/2011 10:05 AM, Richard Guenther wrote: > > > In that case you could do what Jakub suggested - but only for rvalues > > > of course. > > > > Right, and I need to handle lvalues as well. > > > > > Can't you instead adjust the type you feed to fold_indirect_ref_1 in > > > the caller in the C++ FE? > > > > Not without digging down into the operand to see what type it wants. At > > that point I might as well just copy the whole function into the FE. > > Ping?
I'm out of good suggestions ;) You can do the same-qualifier matching and simply have a mismatched array element vs. array-ref type. We could also argue that whoever calls fold_indirect_ref_1 with TYPE that doesn't even have TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (op0 (!))) == TYPE_MAIN_VARIANT (type) is broken. Thus we could argue that even ignoring qualifiers is ok - but I'd be worried about folding *((volatile int *)&a[0] + 1) to a[1] with lost volatile qualification. Richard.