FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.ext / pretty3.C
blob9d49f63dd15f848ee9acefb3da282a048121ad78
1 // Copyright (C) 1999 Free Software Foundation, Inc.
2 // Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org>
4 // make sure __FUNCTION__ and __PRETTY_FUNCTION__ work in templates
6 #include <stdio.h>
7 #include <string.h>
9 static bool bad = false;
11 template<class T> void f1 (T)
13   char const *function = __FUNCTION__;
14   char const *pretty = __PRETTY_FUNCTION__;
15   
16   printf ("generic\n");
17   printf ("__FUNCTION__ %s\n", function);
18   printf ("__PRETTY_FUNCTION__ %s\n", pretty);
19   
20   if (strcmp (function, "f1"))
21     bad = true;
22   if (strcmp (pretty, "void f1(T) [with T = float]")) // only for float instantiation
23     bad = true;
26 template<> void f1<int> (int)
28   char const *function = __FUNCTION__;
29   char const *pretty = __PRETTY_FUNCTION__;
30   
31   printf ("specialized\n");
32   printf ("__FUNCTION__ %s\n", function);
33   printf ("__PRETTY_FUNCTION__ %s\n", pretty);
34   
35   if (strcmp (function, "f1"))
36     bad = true;
37   if (strcmp (pretty, "void f1(T) [with T = int]"))
38     bad = true;
41 int main ()
43   f1(0);    // f1<int>
44   f1(0.0f); // f1<float>
45   return bad;