aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-06-29 07:30:31 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-06-29 07:30:31 +0000
commit4aa83879c93d2367f5245c94bd2f12c19f486dae (patch)
tree29eb8891c24a3daecbf68e50445cf77606b498d4 /gcc
parent36088299955f95ab58a5758cba2f29b84c8fbfbc (diff)
downloadgcc-4aa83879c93d2367f5245c94bd2f12c19f486dae.zip
gcc-4aa83879c93d2367f5245c94bd2f12c19f486dae.tar.gz
gcc-4aa83879c93d2367f5245c94bd2f12c19f486dae.tar.bz2
re PR middle-end/71002 (-fstrict-aliasing breaks Boost's short string optimization implementation)
2016-06-29 Richard Biener <rguenther@suse.de> PR middle-end/71002 * alias.c (component_uses_parent_alias_set_from): Handle type punning through union accesses by using the union alias set. * gimple.c (gimple_get_alias_set): Remove union type punning case. c-family/ * c-common.c (c_common_get_alias_set): Remove union type punning case. fortran/ * f95-lang.c (LANG_HOOKS_GET_ALIAS_SET): Remove (un-)define. (gfc_get_alias_set): Remove. * g++.dg/torture/pr71002.C: Adjust testcase. From-SVN: r237839
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/alias.c8
-rw-r--r--gcc/c-family/ChangeLog5
-rw-r--r--gcc/c-family/c-common.c15
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/f95-lang.c21
-rw-r--r--gcc/gimple.c15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/torture/pr71002.C11
9 files changed, 34 insertions, 59 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 109ff1c..e57c1a9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2016-06-29 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/71002
+ * alias.c (component_uses_parent_alias_set_from): Handle
+ type punning through union accesses by using the union alias set.
+ * gimple.c (gimple_get_alias_set): Remove union type punning case.
+
2016-07-29 Richard Biener <rguenther@suse.de>
* match.pd ((T)(T2)x -> (T)x): Remove restriction on final
diff --git a/gcc/alias.c b/gcc/alias.c
index 1e4c4d1..dd1dfd3 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -619,6 +619,14 @@ component_uses_parent_alias_set_from (const_tree t)
case COMPONENT_REF:
if (DECL_NONADDRESSABLE_P (TREE_OPERAND (t, 1)))
found = t;
+ /* 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
+ through it. Even the type-punning allowed here is a GCC
+ extension, albeit a common and useful one; the C standard says
+ that such accesses have implementation-defined behavior. */
+ else if (TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == UNION_TYPE)
+ found = t;
break;
case ARRAY_REF:
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 86ce14a9..d5b8395 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-29 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/71002
+ * c-common.c (c_common_get_alias_set): Remove union type punning case.
+
2016-06-24 Jason Merrill <jason@redhat.com>
P0145R2: Refining Expression Order for C++.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 3301c31..936ddfb 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -4736,8 +4736,6 @@ static GTY(()) hash_table<c_type_hasher> *type_hash_table;
alias_set_type
c_common_get_alias_set (tree t)
{
- tree u;
-
/* 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))
@@ -4747,19 +4745,6 @@ c_common_get_alias_set (tree 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
- through it. Even the type-punning allowed here is a GCC
- extension, albeit a common and useful one; the C standard says
- that such accesses have implementation-defined behavior. */
- for (u = t;
- TREE_CODE (u) == COMPONENT_REF || TREE_CODE (u) == ARRAY_REF;
- u = TREE_OPERAND (u, 0))
- if (TREE_CODE (u) == COMPONENT_REF
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE)
- return 0;
-
/* That's all the expressions we handle specially. */
if (!TYPE_P (t))
return -1;
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index b8cadce..68e1f34 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-29 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/71002
+ * f95-lang.c (LANG_HOOKS_GET_ALIAS_SET): Remove (un-)define.
+ (gfc_get_alias_set): Remove.
+
2016-06-25 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/71649
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index b89a291..5849073 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -74,7 +74,6 @@ static bool global_bindings_p (void);
static bool gfc_init (void);
static void gfc_finish (void);
static void gfc_be_parse_file (void);
-static alias_set_type gfc_get_alias_set (tree);
static void gfc_init_ts (void);
static tree gfc_builtin_function (tree);
@@ -110,7 +109,6 @@ static const struct attribute_spec gfc_attribute_table[] =
#undef LANG_HOOKS_MARK_ADDRESSABLE
#undef LANG_HOOKS_TYPE_FOR_MODE
#undef LANG_HOOKS_TYPE_FOR_SIZE
-#undef LANG_HOOKS_GET_ALIAS_SET
#undef LANG_HOOKS_INIT_TS
#undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE
#undef LANG_HOOKS_OMP_PREDETERMINED_SHARING
@@ -142,7 +140,6 @@ static const struct attribute_spec gfc_attribute_table[] =
#define LANG_HOOKS_PARSE_FILE gfc_be_parse_file
#define LANG_HOOKS_TYPE_FOR_MODE gfc_type_for_mode
#define LANG_HOOKS_TYPE_FOR_SIZE gfc_type_for_size
-#define LANG_HOOKS_GET_ALIAS_SET gfc_get_alias_set
#define LANG_HOOKS_INIT_TS gfc_init_ts
#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE gfc_omp_privatize_by_reference
#define LANG_HOOKS_OMP_PREDETERMINED_SHARING gfc_omp_predetermined_sharing
@@ -503,24 +500,6 @@ gfc_init_decl_processing (void)
}
-/* Return the typed-based alias set for T, which may be an expression
- or a type. Return -1 if we don't do anything special. */
-
-static alias_set_type
-gfc_get_alias_set (tree t)
-{
- tree u;
-
- /* Permit type-punning when accessing an EQUIVALENCEd variable or
- mixed type entry master's return value. */
- for (u = t; handled_component_p (u); u = TREE_OPERAND (u, 0))
- if (TREE_CODE (u) == COMPONENT_REF
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE)
- return 0;
-
- return -1;
-}
-
/* Builtin function initialization. */
static tree
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 677c560..e275dfc 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2400,21 +2400,6 @@ gimple_signed_type (tree type)
alias_set_type
gimple_get_alias_set (tree t)
{
- tree u;
-
- /* 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
- through it. Even the type-punning allowed here is a GCC
- extension, albeit a common and useful one; the C standard says
- that such accesses have implementation-defined behavior. */
- for (u = t;
- TREE_CODE (u) == COMPONENT_REF || TREE_CODE (u) == ARRAY_REF;
- u = TREE_OPERAND (u, 0))
- if (TREE_CODE (u) == COMPONENT_REF
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE)
- return 0;
-
/* That's all the expressions we handle specially. */
if (!TYPE_P (t))
return -1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 171e616..70e9048 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-29 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/71002
+ * g++.dg/torture/pr71002.C: Adjust testcase.
+
2016-06-29 Jakub Jelinek <jakub@redhat.com>
PR c/71685
diff --git a/gcc/testsuite/g++.dg/torture/pr71002.C b/gcc/testsuite/g++.dg/torture/pr71002.C
index 8a72680..666da02 100644
--- a/gcc/testsuite/g++.dg/torture/pr71002.C
+++ b/gcc/testsuite/g++.dg/torture/pr71002.C
@@ -16,11 +16,6 @@ struct long_t
char* pointer;
};
-union long_raw_t {
- unsigned char data[sizeof(long_t)];
- struct __attribute__((aligned(alignof(long_t)))) { } align;
-};
-
struct short_header
{
unsigned char is_short : 1;
@@ -35,20 +30,20 @@ struct short_t
union repr_t
{
- long_raw_t r;
+ long_t r;
short_t s;
const short_t& short_repr() const
{ return s; }
const long_t& long_repr() const
- { return *static_cast<const long_t*>(static_cast<const void*>(&r)); }
+ { return r; }
short_t& short_repr()
{ return s; }
long_t& long_repr()
- { return *static_cast<long_t*>(static_cast<void*>(&r)); }
+ { return r; }
};
class string