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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.pt/] [instantiate12.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do run  }
2
 
3
// Copyright (C) 2000 Free Software Foundation, Inc.
4
// Contributed by Nathan Sidwell 14 Nov 2000 
5
 
6
// Bug 635. We failed to emit initializer code for out-of-class defined
7
// static const members of template instantiations.
8
 
9
static int inited = 0;
10
 
11
static bool setFlag()
12
{
13
  inited++;
14
  return true;
15
}
16
 
17
template struct X
18
{
19
  static const bool cflag;
20
  static bool flag;
21
  static const bool iflag = true;
22
  static const bool jflag = true;
23
};
24
 
25
template const bool X::cflag (setFlag ());
26
template bool X::flag (setFlag ());
27
template const bool X::iflag;
28
 
29
int main ()
30
{
31
  X a;
32
  if (!a.flag)
33
    return 1;
34
  if (!a.cflag)
35
    return 2;
36
  if (!a.iflag)
37
    return 3;
38
  if (!a.jflag)
39
    return 5;
40
  if (!X::flag)
41
    return 5;
42
  if (!X::cflag)
43
    return 6;
44
  if (!X::iflag)
45
    return 7;
46
  if (!X::jflag)
47
    return 8;
48
  if (inited != 4)
49
    return 9;
50
  return 0;
51
}
52
 
53
// On platforms that do not have weak symbols, these static data
54
// members must be explicitly instantiated.  The iflag and jflag data
55
// members should not have to be explicitly instantiated because their
56
// const-ness should allow the compiler to elide references to the
57
// actual variables.
58
template const bool X::cflag;
59
template bool X::flag;
60
template const bool X::cflag;
61
template bool X::flag;

powered by: WebSVN 2.1.0

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