view gcc/testsuite/g++.dg/ipa/devirt-34.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-do compile } */
/* { dg-options "-O2 -fdump-ipa-devirt"  } */
struct A {virtual int t(){return 42;}};
struct B:A {virtual int t(){return 1;}};

struct A aa;
struct B bb;
int
t(struct B *b)
{
  struct A *a=b;
  a->t();

  return 0;
}

/* We should guess that the pointer of type B probably points to an instance
   of B or its derivates and exclude A::t from list of likely targets.  */

/* { dg-final { scan-ipa-dump "Speculative targets"  "devirt"  } } */
/* { dg-final { scan-ipa-dump "1 speculatively devirtualized"  "devirt"  } } */