diff options
author | Richard Guenther <rguenther@suse.de> | 2006-03-10 16:44:01 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2006-03-10 16:44:01 +0000 |
commit | 891c0eeed7c8b2b087f908bd845ab0bea7663b00 (patch) | |
tree | ca610c80b72b454616b08e05bf5c2ed82d666839 /gcc/builtins.c | |
parent | 8c1aaf261ba3d7306ae295fe06d5b25470e89f2e (diff) | |
download | gcc-891c0eeed7c8b2b087f908bd845ab0bea7663b00.zip gcc-891c0eeed7c8b2b087f908bd845ab0bea7663b00.tar.gz gcc-891c0eeed7c8b2b087f908bd845ab0bea7663b00.tar.bz2 |
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
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index f6095e8..1ce6083 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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; |