OSDN Git Service

* g++.old-deja/g++.eh/cleanup2.C: New test.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.ext / pretty3.C
1 // Copyright (C) 1999 Free Software Foundation, Inc.
2 // Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org>
3
4 // make sure __FUNCTION__ and __PRETTY_FUNCTION__ work in templates
5
6 // execution test - XFAIL *-*-*
7
8 #include <stdio.h>
9 #include <string.h>
10
11 static bool bad = false;
12
13 template<class T> void f1 (T)
14 {
15   char const *function = __FUNCTION__;
16   char const *pretty = __PRETTY_FUNCTION__;
17   
18   printf ("generic\n");
19   printf ("__FUNCTION__ %s\n", function);
20   printf ("__PRETTY_FUNCTION__ %s\n", pretty);
21   
22   if (strcmp (function, "f1"))
23     bad = true;
24   if (strcmp (pretty, "void f1<float> (float)")) // only for float instantiation
25     bad = true;
26 }
27
28 template<> void f1<int> (int)
29 {
30   char const *function = __FUNCTION__;
31   char const *pretty = __PRETTY_FUNCTION__;
32   
33   printf ("specialized\n");
34   printf ("__FUNCTION__ %s\n", function);
35   printf ("__PRETTY_FUNCTION__ %s\n", pretty);
36   
37   if (strcmp (function, "f1"))
38     bad = true;
39   if (strcmp (pretty, "void f1<int> (int)"))
40     bad = true;
41 }
42
43 int main ()
44 {
45   f1(0);    // f1<int>
46   f1(0.0f); // f1<float>
47   return bad;
48 }