summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/attr-alias-1.C
blob: 1427267e5173954bf8410aeef5d21edc4aba09c4 (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
/* { dg-do run }  */
/* { dg-require-alias "" } */

#include <typeinfo>

struct Klass
{
  int implementation () const;
  int magic () const;
};

int Klass::implementation (void) const
{
  return 0;
}

int Klass::magic () const
  __attribute__ ((alias ("_ZNK5Klass14implementationEv")));

int __attribute__ ((noinline))
  Foo (Klass const *ptr)
{
  if (ptr->magic () != 0)
    return 1;

  if (typeid (*ptr) != typeid (Klass))
    return 2;

  return 0;
}

int main ()
{
  Klass obj;
  
  return Foo (&obj);
}