[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / ext / pretty2.C
blob0c05da9b70d9b7b544def20447c3c903c7cf97fd
1 // PR c++/6794
2 // Test whether __PRETTY_FUNCTION__ works in templates, functions and
3 // in initializers at global scope
4 // { dg-do run }
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 ();