summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/attr-alias-2.C
blob: 61a132f77a7b02107af0da5c256fb180925dd4f3 (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;
  virtual 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);
}