aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/static1_0.C
blob: 525480dab93b63511a906faf35f9b68e85fcb833 (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
40
41
42
43
44
45
46
47
48
// { dg-options "-std=c++11 -O2" }

// A test case for static var promotion on targets like powerpc, where
// the static initializer data is loaded via indirection through
// TOC. Ensure that the global label for static initializer data is
// unique via *.cmo* suffix.

// Bug: after static var promotion in two different modules, we have
// the following which leads to multiple definition of ._41" error during
// link time.

// Module 1                     Module 2
//      .hidden ._41.cmo.1           .hidden ._41.cmo.3
//      .globl ._41                  .globl ._41
// ._41:                        ._41:
//   ...                          ...


// Instead we should use the appropriate unique names for initializer
// data as in the following.

// Module 1                     Module 2
//      .hidden ._41.cmo.1           .hidden ._41.cmo.3
//      .globl ._41.cmo.1            .globl ._41.cmo.3
// ._41.cmo.1:                  ._41.cmo.3:
// ...                          ...

class A {
 public:
  int f(int x) const;
};

class B {
 public:
  int f(int x) const;
};

int main()
{
  A *a = new A();
  B *b = new B();
  int total = 0;
  for (int i=0; i<3; ++i) {
    total += a->f(1);
    total += b->f(1);
  }
  return (total > 0) ? 0 : 1;
}