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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// { dg-do run }
// Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org>
// make sure __FUNCTION__ and __PRETTY_FUNCTION__ work in member functions
#include <stdio.h>
#include <string.h>
static bool bad = false;
struct X
{
X ();
~X ();
void fn ();
operator int ();
};
X::X ()
{
char const *function = __FUNCTION__;
char const *pretty = __PRETTY_FUNCTION__;
printf ("ctor\n");
printf ("__FUNCTION__ %s\n", function);
printf ("__PRETTY_FUNCTION__ %s\n", pretty);
if (strcmp (function, "X"))
bad = true;
if (strcmp (pretty, "X::X()"))
bad = true;
}
X::~X ()
{
char const *function = __FUNCTION__;
char const *pretty = __PRETTY_FUNCTION__;
printf ("dtor\n");
printf ("__FUNCTION__ %s\n", function);
printf ("__PRETTY_FUNCTION__ %s\n", pretty);
if (strcmp (function, "~X"))
bad = true;
if (strcmp (pretty, "X::~X()"))
bad = true;
}
void X::fn ()
{
char const *function = __FUNCTION__;
char const *pretty = __PRETTY_FUNCTION__;
printf ("member fn\n");
printf ("__FUNCTION__ %s\n", function);
printf ("__PRETTY_FUNCTION__ %s\n", pretty);
if (strcmp (function, "fn"))
bad = true;
if (strcmp (pretty, "void X::fn()"))
bad = true;
}
X::operator int ()
{
char const *function = __FUNCTION__;
char const *pretty = __PRETTY_FUNCTION__;
printf ("conversion\n");
printf ("__FUNCTION__ %s\n", function);
printf ("__PRETTY_FUNCTION__ %s\n", pretty);
if (strcmp (pretty, "X::operator int()"))
bad = true;
return 0;
}
int main ()
{
{
X x;
x.fn ();
(void)int (x);
}
return bad;
}
|