OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.ext/] [pretty4.C] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do run  }
2
// Copyright (C) 2000 Free Software Foundation, Inc.
3
// Contributed by Nathan Sidwell 3 Mar 2000 
4
 
5
// __PRETTY_FUNCTION__, __FUNCTION__ and __function__ should have the
6
// type char const [X], where X is the right value for that particular function
7
 
8
static void const *strings[4];
9
static void const *tpls[4];
10
static unsigned pos = 0;
11
static int fail;
12
static void const *ptr = 0;
13
 
14
void unover (char const (*)[5]) {}
15
void foo (char const (*)[5]) {}
16
void foo (void *) {fail = 1;}
17
void foo (void const *) {fail = 1;}
18
void baz (char const (&)[5]) {}
19
 
20
template void PV (char const (&objRef)[I])
21
{
22
  strings[pos] = objRef;
23
  tpls[pos] = __PRETTY_FUNCTION__;
24
  pos++;
25
}
26
 
27
void fn ()
28
{
29
  PV (__FUNCTION__);
30
  PV (__func__);
31
  PV (__PRETTY_FUNCTION__);
32
  PV ("wibble");
33
}
34
 
35
void baz ()
36
{
37
  ptr = __FUNCTION__;
38
  // there should be no string const merging
39
  if (ptr == "baz")
40
    fail = 1;
41
  // but all uses should be the same.
42
  if (ptr != __FUNCTION__)
43
    fail = 1;
44
}
45
int baz (int)
46
{
47
  return ptr == __FUNCTION__;
48
}
49
 
50
int main ()
51
{
52
  // make sure we actually emit the VAR_DECL when needed, and things have the
53
  // expected type.
54
  foo (&__FUNCTION__);
55
  baz (__FUNCTION__);
56
  unover (&__FUNCTION__);
57
  if (fail)
58
    return 1;
59
 
60
  // __FUNCTION__ should be unique across functions with the same base name
61
  // (it's a local static, _not_ a string).
62
  baz ();
63
  if (fail)
64
    return 1;
65
  if (baz (1))
66
    return 1;
67
  fn ();
68
 
69
  // Check the names of fn. They should all be distinct strings (though two
70
  // will have the same value).
71
  if (strings[0] == strings[1])
72
    return 1;
73
  if (strings[0] == strings[2])
74
    return 1;
75
  if (strings[1] == strings[2])
76
    return 1;
77
 
78
  // check the names of the template functions so invoked
79
  if (tpls[0] != tpls[1])
80
    return 1;
81
  if (tpls[0] == tpls[2])
82
    return 1;
83
 
84
  return 0;
85
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.