URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 154 |
Rev 816 |
// Copyright (C) 2005 Free Software Foundation, Inc.
|
// Copyright (C) 2005 Free Software Foundation, Inc.
|
// Contributed by Nathan Sidwell 4 Apr 2005
|
// Contributed by Nathan Sidwell 4 Apr 2005
|
|
|
// { dg-do run }
|
// { dg-do run }
|
|
|
// PR 20746: Covariant return pointer could be null.
|
// PR 20746: Covariant return pointer could be null.
|
|
|
// Origin: yanliu@ca.ibm.com
|
// Origin: yanliu@ca.ibm.com
|
// nathan@codesourcery.com
|
// nathan@codesourcery.com
|
|
|
struct A {
|
struct A {
|
virtual void One ();
|
virtual void One ();
|
};
|
};
|
struct B {
|
struct B {
|
virtual B *Two ();
|
virtual B *Two ();
|
virtual B &Three ();
|
virtual B &Three ();
|
};
|
};
|
|
|
struct C : A, B
|
struct C : A, B
|
{
|
{
|
virtual C *Two ();
|
virtual C *Two ();
|
virtual C &Three ();
|
virtual C &Three ();
|
};
|
};
|
void A::One () {}
|
void A::One () {}
|
B *B::Two() {return this;}
|
B *B::Two() {return this;}
|
B &B::Three() {return *this;}
|
B &B::Three() {return *this;}
|
C *C::Two () {return 0;}
|
C *C::Two () {return 0;}
|
C &C::Three () {return *(C *)0;}
|
C &C::Three () {return *(C *)0;}
|
|
|
B *Foo (B *b)
|
B *Foo (B *b)
|
{
|
{
|
return b->Two ();
|
return b->Two ();
|
}
|
}
|
|
|
B &Bar (B *b)
|
B &Bar (B *b)
|
{
|
{
|
return b->Three ();
|
return b->Three ();
|
}
|
}
|
|
|
int main ()
|
int main ()
|
{
|
{
|
C c;
|
C c;
|
|
|
/* We should not adjust a null pointer. */
|
/* We should not adjust a null pointer. */
|
if (Foo (&c))
|
if (Foo (&c))
|
return 1;
|
return 1;
|
/* But we should adjust a (bogus) null reference. */
|
/* But we should adjust a (bogus) null reference. */
|
if (!&Bar (&c))
|
if (!&Bar (&c))
|
return 2;
|
return 2;
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.