This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: V9 [PATCH] C/C++: Add -Waddress-of-packed-member


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]