aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.ext/pretty3.C
blob: d8ae3c8218a799d2549dc5123b1dbfc7450fbdb3 (plain)
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
// { dg-do run  }
// Copyright (C) 1999 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 21 Nov 1999 <nathan@acm.org>

// make sure __FUNCTION__ and __PRETTY_FUNCTION__ work in templates

#include <stdio.h>
#include <string.h>

static bool bad = false;

template<class T> void f1 (T)
{
  char const *function = __FUNCTION__;
  char const *pretty = __PRETTY_FUNCTION__;
  
  printf ("generic\n");
  printf ("__FUNCTION__ %s\n", function);
  printf ("__PRETTY_FUNCTION__ %s\n", pretty);
  
  if (strcmp (function, "f1"))
    bad = true;
  if (strcmp (pretty, "void f1(T) [with T = float]")) // only for float instantiation
    bad = true;
}

template<> void f1<int> (int)
{
  char const *function = __FUNCTION__;
  char const *pretty = __PRETTY_FUNCTION__;
  
  printf ("specialized\n");
  printf ("__FUNCTION__ %s\n", function);
  printf ("__PRETTY_FUNCTION__ %s\n", pretty);
  
  if (strcmp (function, "f1"))
    bad = true;
  if (strcmp (pretty, "void f1(T) [with T = int]"))
    bad = true;
}

int main ()
{
  f1(0);    // f1<int>
  f1(0.0f); // f1<float>
  return bad;
}