On 12/20/18 2:52 PM, H.J. Lu wrote:
On Thu, Dec 20, 2018 at 11:28 AM Jason Merrill <ja...@redhat.com> wrote:
On 12/19/18 12:35 PM, H.J. Lu wrote:
+ while (handled_component_p (rhs))
+ {
+ if (TREE_CODE (rhs) == COMPONENT_REF)
+ break;
+ rhs = TREE_OPERAND (rhs, 0);
+ }
+
+ if (TREE_CODE (rhs) != COMPONENT_REF)
+ return NULL_TREE;
+
+ object = TREE_OPERAND (rhs, 0);
+ field = TREE_OPERAND (rhs, 1);
+
+ tree context = check_alignment_of_packed_member (type, field);
+ if (context)
+ return context;
All the above looks unnecessary; it will be handled by the loop below.
+ /* Check alignment of the object. */
+ while (handled_component_p (object))
+ {
+ if (TREE_CODE (object) == COMPONENT_REF)
+ {
+ do
+ {
+ field = TREE_OPERAND (object, 1);
+ context = check_alignment_of_packed_member (type, field);
+ if (context)
+ return context;
+ object = TREE_OPERAND (object, 0);
+ }
+ while (TREE_CODE (object) == COMPONENT_REF);
This inner loop also seems unnecessary.
+ }
+ else
+ object = TREE_OPERAND (object, 0);
+ }
Jason
I changed it to
static tree
check_address_of_packed_member (tree type, tree rhs)
{
if (INDIRECT_REF_P (rhs))
rhs = TREE_OPERAND (rhs, 0);
if (TREE_CODE (rhs) == ADDR_EXPR)
rhs = TREE_OPERAND (rhs, 0);
tree context = NULL_TREE;
/* Check alignment of the object. */
while (handled_component_p (rhs))
{
if (TREE_CODE (rhs) == COMPONENT_REF)
{
tree field = TREE_OPERAND (rhs, 1);
context = check_alignment_of_packed_member (type, field);
if (context)
break;
}
rhs = TREE_OPERAND (rhs, 0);
}
return context;
}
Here is the updated patch. OK for trunk?
OK.
Jason