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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [g++.dg/] [ext/] [pretty1.C] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
// PR c++/6794
2
// Test whether __PRETTY_FUNCTION__ works in templates, functions and
3
// in initializers at global scope
4
// { dg-do compile }
5
// { dg-options "" }
6
 
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);
12
 
13
#define str(expr) #expr
14
#define assert(expr)                                            \
15
  ((expr) ? 0 : (__assert_fail (str(expr), __FILE__, __LINE__,  \
16
                                __PRETTY_FUNCTION__), 0))
17
 
18
int __attribute__((noinline))
19
foo (void)
20
{
21
  return 1;
22
}
23
 
24
template int
25
bar (T)
26
{
27
  return (assert (foo ()), 1);
28
}
29
 
30
template<> int
31
bar (int)
32
{
33
  return (assert (foo ()), 2);
34
}
35
 
36
int a = (assert (foo ()), 1);
37
int b = (assert (foo ()), 2);
38
 
39
int
40
main ()
41
{
42
  double c = 1.0;
43
  unsigned char *d = 0;
44
  int e = (assert (foo ()), 3);
45
 
46
  bar (c);
47
  bar (d);
48
  bar (e);
49
}
50
 
51
namespace N
52
{
53
  int f = (assert (foo ()), 4);
54
}
55
 
56
void __attribute__((noinline))
57
__assert_fail (const char *cond, const char *file, unsigned int line,
58
               const char *pretty) throw ()
59
{
60
  abort ();
61
}
62
 
63
// { dg-final { scan-assembler "int bar\\(T\\).*with T = int" } }
64
// { dg-final { scan-assembler "top level" } }
65
// { dg-final { scan-assembler "int main\\(\\)" } }
66
// { dg-final { scan-assembler "int bar\\(T\\).*with T = double" } }
67
// { dg-final { scan-assembler "int bar\\(T\\).*with T = unsigned char\*" } }

powered by: WebSVN 2.1.0

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