FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.pt / instantiate12.C
blobe1cc8534c8d3cc60e64f1bbc177acde755683359
2 // Copyright (C) 2000 Free Software Foundation, Inc.
3 // Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com>
5 // Bug 635. We failed to emit initializer code for out-of-class defined
6 // static const members of template instantiations.
8 static int inited = 0;
10 static bool setFlag()
12   inited++;
13   return true;
16 template<typename T> struct X
18   static const bool cflag;
19   static bool flag;
20   static const bool iflag = true;
21   static const bool jflag = true;
24 template<typename T> const bool X<T>::cflag (setFlag ());
25 template<typename T> bool X<T>::flag (setFlag ());
26 template<typename T> const bool X<T>::iflag;
28 int main ()
30   X<int> a;
31   if (!a.flag)
32     return 1;
33   if (!a.cflag)
34     return 2;
35   if (!a.iflag)
36     return 3;
37   if (!a.jflag)
38     return 5;
39   if (!X<float>::flag)
40     return 5;
41   if (!X<float>::cflag)
42     return 6;
43   if (!X<float>::iflag)
44     return 7;
45   if (!X<float>::jflag)
46     return 8;
47   if (inited != 4)
48     return 9;
49   return 0;