On Thu, Jan 24, 2019 at 06:39:22AM +0000, Bernd Edlinger wrote: > --- gcc/c-family/c-warn.c (revision 268195) > +++ gcc/c-family/c-warn.c (working copy) > @@ -2725,14 +2725,18 @@ static tree > check_address_or_pointer_of_packed_member (tree type, tree rhs) > { > bool rvalue = true; > + bool indirect = false; > > if (INDIRECT_REF_P (rhs)) > - rhs = TREE_OPERAND (rhs, 0); > + { > + rhs = TREE_OPERAND (rhs, 0); > + indirect = true; > + } > > if (TREE_CODE (rhs) == ADDR_EXPR) > { > rhs = TREE_OPERAND (rhs, 0); > - rvalue = false; > + rvalue = indirect; > }
Given the unfolded *&, I wonder if the above actually shouldn't be a loop with indirection integral counter instead of a boolean and simply bump the indirection count on INDIRECT_REF_P and decrease on ADDR_EXPR, and if indirection count is > 0 after the loop return NULL_TREE? Say for *&*& or similar, and ***var.field always not warning etc. Otherwise the patch looks good. Though you might throw in a few test lines with the intermixed casts and compound exprs multiple times (why you've added correctly the loop in there). Jakub