view gcc/testsuite/g++.dg/tree-ssa/pr89698.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line source

// { dg-do compile }
// { dg-options "-O -fdump-tree-fre1" }

class A {
    virtual void f(){};
public:
    int x;
    A(int in): x(in) {};
};

class B: public A {
public:
    int y;
    B(int in):A(in-1), y(in) {};
};

void bar(void *);
void test()
{
  B b(2);
  A* bp = &b;
  void* vp = dynamic_cast<void*>(bp);
  bar (vp);
}

// We should be able to constant fold from the virtual table
// the offset added to bp for the dynamic cast and forward
// &b to the argument of bar
// { dg-final { scan-tree-dump "bar \\\(&b" "fre1" } }