+2006-03-10 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/26565
+ * builtins.c (get_pointer_alignment): Handle component
+ references for field alignment.
+
2006-03-10 J"orn Rennecke <joern.rennecke@st.com>
* config.gcc (sh*-superh-elf, sh*elf (newlib)): Use newlib.h
case ADDR_EXPR:
/* See what we are pointing at and look at its alignment. */
exp = TREE_OPERAND (exp, 0);
+ while (handled_component_p (exp))
+ {
+ if (TREE_CODE (exp) == COMPONENT_REF)
+ align = MIN (align, DECL_ALIGN (TREE_OPERAND (exp, 1)));
+ exp = TREE_OPERAND (exp, 0);
+ }
if (TREE_CODE (exp) == FUNCTION_DECL)
- align = FUNCTION_BOUNDARY;
+ align = MIN (align, FUNCTION_BOUNDARY);
else if (DECL_P (exp))
- align = DECL_ALIGN (exp);
+ align = MIN (align, DECL_ALIGN (exp));
#ifdef CONSTANT_ALIGNMENT
else if (CONSTANT_CLASS_P (exp))
- align = CONSTANT_ALIGNMENT (exp, align);
+ align = MIN (align, (unsigned)CONSTANT_ALIGNMENT (exp, align));
#endif
- return MIN (align, max_align);
+ return align;
default:
return align;
--- /dev/null
+/* { dg-do run } */
+
+void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n);
+
+struct timeval {
+ long tv_sec;
+};
+
+struct outdata {
+ long align;
+ char seq;
+ struct timeval tv __attribute__((packed));
+};
+
+void send_probe(struct outdata *outdata, struct timeval *tp) __attribute__((noinline));
+void send_probe(struct outdata *outdata, struct timeval *tp)
+{
+ memcpy(&outdata->tv, tp, sizeof outdata->tv);
+}
+
+struct timeval t;
+struct outdata outdata;
+
+int main()
+{
+ send_probe(&outdata, &t);
+ return 0;
+}