diff options
author | Joseph Myers <joseph@codesourcery.com> | 2009-10-23 12:18:42 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2009-10-23 12:18:42 +0000 |
commit | 1769b8dfbdd9fdb5001849358e026c13dbe51c63 (patch) | |
tree | 0fe23e5ff51a04afd7bc7b9f279e3b3b20be309d | |
parent | 81c7b70f17f3cf1421909a1d01d9cb21740e57c7 (diff) |
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.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@153496 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/alias.c | 9 | ||||
-rw-r--r-- | gcc/c-common.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c | 10 |
5 files changed, 40 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b0a45ab8cfe..7e51d688bf3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2009-10-23 Joseph Myers <joseph@codesourcery.com> + + 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. + 2009-10-23 Richard Guenther <rguenther@suse.de> PR middle-end/41805 diff --git a/gcc/alias.c b/gcc/alias.c index 694498ab55a..09ec775c5d0 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. */ diff --git a/gcc/c-common.c b/gcc/c-common.c index 16e17b39d1d..8a6d15b9d9b 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -4183,6 +4183,15 @@ c_common_get_alias_set (tree t) tree u; PTR *slot; + /* For VLAs, use the alias set of the element type rather than the + default of alias set 0 for types compared structurally. */ + if (TYPE_P (t) && TYPE_STRUCTURAL_EQUALITY_P (t)) + { + if (TREE_CODE (t) == ARRAY_TYPE) + return get_alias_set (TREE_TYPE (t)); + return -1; + } + /* Permit type-punning when accessing a union, provided the access is directly through the union. For example, this code does not permit taking the address of a union member and then storing diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aa2522805c2..81d39b58144 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-10-23 Joseph Myers <joseph@codesourcery.com> + + PR c/41673 + * gcc.dg/Wstrict-aliasing-bogus-vla-1.c: New test. + 2009-10-23 Richard Guenther <rguenther@suse.de> PR tree-optimization/41778 diff --git a/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c b/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c new file mode 100644 index 00000000000..e9f63d36872 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c @@ -0,0 +1,10 @@ +/* PR 41673: bogus -Wstrict-aliasing warning from VLA dereference. */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu99 -O2 -Wall" } */ + +int main(int argc, char *argv[]) +{ + float x[argc]; + float y[argc]; + return 0 == __builtin_memcpy(y, x, argc * sizeof(*x)); +} |