summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/fnname3.C
blob: c29170a9a39aa5e18176df9a995e0b33a387667d (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Test whether __func__ works for constructors and destructors.

// Copyright (C) 2003 Free Software Foundation, Inc.
// Contributed by Matt Austern <austern@apple.com>, 3 Aug 2003
// { dg-do run }

struct uk9i
{
  uk9i();
  ~uk9i();

  static const char* fname;
  static bool obj_exists;
};

uk9i::uk9i()
{
  obj_exists = true;
  fname = __func__;
}

uk9i::~uk9i()
{
  obj_exists = false;
  fname = __func__;
}

const char* uk9i::fname = 0;
bool uk9i::obj_exists = false;

int main()
{
  bool ok = true;

  ok = ok && uk9i::fname == 0;
  ok = ok && !uk9i::obj_exists;

  {
    uk9i tmp;
    ok = ok && uk9i::obj_exists;
    ok = ok && uk9i::fname != 0;
    if (ok)
      {
	ok = ok && uk9i::fname[0] == 'u';
	ok = ok && uk9i::fname[1] == 'k';
	ok = ok && uk9i::fname[2] == '9';
	ok = ok && uk9i::fname[3] == 'i';
	ok = ok && uk9i::fname[4] == '\0';
      }
  }

  ok = ok && !uk9i::obj_exists;
  ok = ok && uk9i::fname != 0;
  if (ok)
    {
      ok = ok && uk9i::fname[0] == '~';
      ok = ok && uk9i::fname[1] == 'u';
      ok = ok && uk9i::fname[2] == 'k';
      ok = ok && uk9i::fname[3] == '9';
      ok = ok && uk9i::fname[4] == 'i';
      ok = ok && uk9i::fname[5] == '\0';
    }  

  return ok ? 0 : 1;
}