alias.c (get_alias_set): Return a previously calculated alias set for a VAR_DECL.

* alias.c (get_alias_set): Return a previously calculated
        alias set for a VAR_DECL.

From-SVN: r44683
This commit is contained in:
Jason Merrill 2001-08-07 07:13:54 -04:00 committed by Jason Merrill
parent e13ef1e287
commit 1b81b7891b
3 changed files with 37 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2001-08-07 Jason Merrill <jason_merrill@redhat.com>
* alias.c (get_alias_set): Return a previously calculated
alias set for a VAR_DECL.
2001-08-06 Richard Henderson <rth@redhat.com>
* varasm.c (assemble_gc_entry): Remove.

View File

@ -527,6 +527,13 @@ get_alias_set (t)
return 0;
}
/* If we've already determined the alias set for this decl, just
return it. This is necessary for C++ anonymous unions, whose
component variables don't look like union members (boo!). */
if (TREE_CODE (t) == VAR_DECL
&& DECL_RTL_SET_P (t) && GET_CODE (DECL_RTL (t)) == MEM)
return MEM_ALIAS_SET (DECL_RTL (t));
/* Give the language another chance to do something special. */
if (orig_t != t
&& (set = lang_get_alias_set (t)) != -1)

View File

@ -0,0 +1,25 @@
// Test that type punning using an anonymous union works with strict aliasing.
// { dg-do run }
// { dg-options -O2 -fstrict-aliasing }
extern "C" void abort ();
void f (int i)
{
union
{
int ui;
float uf[2];
};
ui = i;
if (uf[0] != 42.0)
abort ();
}
int main ()
{
union U { int i; float f[2]; } u;
u.f[0] = 42.0;
f (u.i);
}