aboutsummaryrefslogtreecommitdiff
path: root/gcc/alias.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2009-10-23 13:18:42 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2009-10-23 13:18:42 +0100
commitcb9c2485b2487ee5aa9a3e1b75385c508d28519f (patch)
tree0fe23e5ff51a04afd7bc7b9f279e3b3b20be309d /gcc/alias.c
parent93f28ca73fbb038d98a74a464d04c734743720c4 (diff)
downloadgcc-cb9c2485b2487ee5aa9a3e1b75385c508d28519f.zip
gcc-cb9c2485b2487ee5aa9a3e1b75385c508d28519f.tar.gz
gcc-cb9c2485b2487ee5aa9a3e1b75385c508d28519f.tar.bz2
re PR c/41673 (variable-length array dereference inside sizeof gives "warning: dereferencing type-punned pointer will break strict-aliasing rules")
PR c/41673 * alias.c (get_alias_set): Call langhook before returning 0 for types with structural equality. * c-common.c (c_common_get_alias_set): Use alias set of element type for arrays with structural comparison. testsuite: * gcc.dg/Wstrict-aliasing-bogus-vla-1.c: New test. From-SVN: r153496
Diffstat (limited to 'gcc/alias.c')
-rw-r--r--gcc/alias.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/alias.c b/gcc/alias.c
index 694498a..09ec775 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -691,7 +691,14 @@ get_alias_set (tree t)
requires structural comparisons to identify compatible types
use alias set zero. */
if (TYPE_STRUCTURAL_EQUALITY_P (t))
- return 0;
+ {
+ /* Allow the language to specify another alias set for this
+ type. */
+ set = lang_hooks.get_alias_set (t);
+ if (set != -1)
+ return set;
+ return 0;
+ }
t = TYPE_CANONICAL (t);
/* Canonical types shouldn't form a tree nor should the canonical
type require structural equality checks. */