2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / ext / pretty1.C
blob06608ae30ebb23a92f59ebe69d3dcbe23761d6d4
1 // PR c++/6794
2 // Test whether __PRETTY_FUNCTION__ works in templates, functions and
3 // in initializers at global scope
4 // { dg-do compile }
5 // { dg-options "" }
7 extern "C" void __assert_fail (const char *, const char *,
8                                unsigned int, const char *)
9   throw() __attribute__((noreturn));
10 extern "C" void abort (void);
11 extern "C" void exit (int);
13 #define str(expr) #expr
14 #define assert(expr)                                            \
15   ((expr) ? 0 : (__assert_fail (str(expr), __FILE__, __LINE__,  \
16                                 __PRETTY_FUNCTION__), 0))
18 int __attribute__((noinline))
19 foo (void)
21   return 1;
24 template<class T> int
25 bar (T)
27   return (assert (foo ()), 1);
30 template<> int
31 bar<int> (int)
33   return (assert (foo ()), 2);
36 int a = (assert (foo ()), 1);
37 int b = (assert (foo ()), 2);
39 int
40 main ()
42   double c = 1.0;
43   unsigned char *d = 0;
44   int e = (assert (foo ()), 3);
46   bar (c);
47   bar (d);
48   bar (e);
51 namespace N
53   int f = (assert (foo ()), 4);
56 void __attribute__((noinline))
57 __assert_fail (const char *cond, const char *file, unsigned int line,
58                const char *pretty) throw ()
60   abort ();
63 // { dg-final { scan-assembler "int bar\\(T\\).*with T = int" } }
64 // { dg-final { scan-assembler "top level" } }
65 // { dg-final { scan-assembler "int main\\(\\)" } }
66 // { dg-final { scan-assembler "int bar\\(T\\).*with T = double" } }
67 // { dg-final { scan-assembler "int bar\\(T\\).*with T = unsigned char\*" } }