From 1e2800358a9df1c5379e7bd66b9858b452742cb6 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Thu, 29 Oct 1998 12:40:21 +0000 Subject: [PATCH] Fix for sparc va_arg macro aliasing problem. * c-common.c (c_get_alias_set): Handle ARRAY_REF of union field. From-SVN: r23427 --- gcc/ChangeLog | 4 ++++ gcc/c-common.c | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8eb81d2c43f..9670a1be0a3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +Thu Oct 29 12:39:35 1998 Jim Wilson + + * c-common.c (c_get_alias_set): Handle ARRAY_REF of union field. + Thu Oct 29 14:10:22 EST 1998 Andrew MacLeod * except.c (emit_eh_context): Make the EH context register stay alive diff --git a/gcc/c-common.c b/gcc/c-common.c index 508a8c2e599..ddb87cd4a00 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3155,8 +3155,15 @@ c_get_alias_set (t) the conservative assumption. */ return 0; - if (TREE_CODE (t) == COMPONENT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == UNION_TYPE) + if ((TREE_CODE (t) == COMPONENT_REF + && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == UNION_TYPE) + /* Also permit punning when accessing an array which is a union + member. This makes the current sparc va_arg macro work, but may + not be otherwise necessary. */ + || (TREE_CODE (t) == ARRAY_REF + && TREE_CODE (TREE_OPERAND (t, 0)) == COMPONENT_REF + && (TREE_CODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND (t, 0), 0))) + == UNION_TYPE))) /* 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