summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ipa/devirt-16.C
blob: 85567867ff169345cda5357afecaf00ebd5c75c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* We shall devirtualize to unreachable.  No anonymous type method should surivve
   reachability.  */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-ipa-whole-program"  } */
namespace {
class B {
public:
  virtual int foo(void)
{
  return 0;
}
};
class A : public B {
public:
  virtual int foo(void)
{
  return 1;
}
};
}
class B *b;
main()
{
  int c;
  if (c)
    {
    class A a;
    a.foo();
    class B b;
    b.foo();
    }
  return b->foo();
}

/* { dg-final { scan-ipa-dump "Devirtualizing" "whole-program"} } */
/* { dg-final { scan-ipa-dump "builtin_unreachable" "whole-program"} } */
/* { dg-final { scan-ipa-dump-not "A::foo" "whole-program"} } */
/* { dg-final { scan-ipa-dump-not "A::foo" "whole-program"} } */
/* { dg-final { cleanup-ipa-dump "whole-program" } } */