re PR middle-end/26565 (Unaligned accesses with __attribute__(packed) and memcpy)
2006-03-10 Richard Guenther <rguenther@suse.de> PR middle-end/26565 * builtins.c (get_pointer_alignment): Handle component references for field alignment. * gcc.dg/torture/pr26565.c: New testcase. From-SVN: r111934
This commit is contained in:
parent
8c1aaf261b
commit
891c0eeed7
@ -1,3 +1,9 @@
|
||||
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
|
||||
|
@ -275,15 +275,21 @@ get_pointer_alignment (tree exp, unsigned int max_align)
|
||||
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;
|
||||
|
@ -1,3 +1,8 @@
|
||||
2006-03-10 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR middle-end/26565
|
||||
* gcc.dg/torture/pr26565.c: New testcase.
|
||||
|
||||
2006-03-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>
|
||||
|
||||
PR libgfortran/26499
|
||||
|
28
gcc/testsuite/gcc.dg/torture/pr26565.c
Normal file
28
gcc/testsuite/gcc.dg/torture/pr26565.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* { 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user