This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH]:Fix 13387 breakage
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 23 Dec 2003 09:07:23 +0000
- Subject: [C++ PATCH]:Fix 13387 breakage
- Organization: Codesourcery LLC
Hi,
This patch fixes the aliasing breakage that Richard Sandiford
pointed out from my 13387 patch. I have examined the mips assembly this
produces and it seems good, but I am waiting for Richard to tell me that
the test case confirms it, before checking that in[1]. Meanwhile Mark & I
are confident that this patch is correct, so I have installed it now. I was
unable to produce a test case that manifested on the i86.
booted & tested on i686-pc-linux-gnu.
nathan
[1]I typoed the list's address on my original email, so that was accidentally
sent off list
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2003-12-22 Nathan Sidwell <nathan@codesourcery.com>
PR c++/13387
* cp-lang.c (cxx_get_alias_set): Correct logic for a base type.
Index: cp/cp-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v
retrieving revision 1.68
diff -c -3 -p -r1.68 cp-lang.c
*** cp/cp-lang.c 16 Dec 2003 10:08:37 -0000 1.68
--- cp/cp-lang.c 22 Dec 2003 15:56:32 -0000
*************** ok_to_generate_alias_set_for_type (tree
*** 296,306 ****
static HOST_WIDE_INT
cxx_get_alias_set (tree t)
{
! if (CLASS_TYPE_P (t) && TYPE_CONTEXT (t) && CLASS_TYPE_P (TYPE_CONTEXT (t))
&& CLASSTYPE_AS_BASE (TYPE_CONTEXT (t)) == t)
/* The base variant of a type must be in the same alias set as the
complete type. */
! t = TYPE_CONTEXT (t);
if (/* It's not yet safe to use alias sets for some classes in C++. */
!ok_to_generate_alias_set_for_type (t)
--- 296,307 ----
static HOST_WIDE_INT
cxx_get_alias_set (tree t)
{
! if (TREE_CODE (t) == RECORD_TYPE
! && TYPE_CONTEXT (t) && CLASS_TYPE_P (TYPE_CONTEXT (t))
&& CLASSTYPE_AS_BASE (TYPE_CONTEXT (t)) == t)
/* The base variant of a type must be in the same alias set as the
complete type. */
! return get_alias_set (TYPE_CONTEXT (t));
if (/* It's not yet safe to use alias sets for some classes in C++. */
!ok_to_generate_alias_set_for_type (t)
// { dg-do run { target mips*-*-* } }
// { dg-options "-O2 -mabi-64" }
// Contributed by Nathan Sidwell 22 Dec 2003 <nathan@codesourcery.com>
// Origin: rsandifo@redhat.com
// PR c++/13387. Alias sets were incorrect
struct C {
C(short *p = 0) : ptr (p), index (0) {}
short operator*() { return ptr[index]; }
short *ptr;
int index;
};
C f1 (C) __attribute__ ((noinline));
C f1 (C x)
{
return x;
}
void f2 (short)__attribute__ ((noinline));;
short s;
void f2 (short s_)
{
s = s_;
}
C g (C x)__attribute__ ((noinline));
C g (C x)
{
x = f1 (x);
f2 (*x);
return x;
}
int main ()
{
short p = 0x1234;
C x (&p);
g (x);
return s != p;
}