1 // { dg-do run  }
2 // GROUPS passed constructors
3 // Message-Id: <m0p8Am6-0002fCC@neal.ctd.comsat.com>
4 // Date: Fri, 10 Dec 93 11:33 EST
5 // From: neal@ctd.comsat.com (Neal Becker)
6 // Subject: serious problems with static constructors
7 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 
12 #define CONST const
13 
14 class Sig {
15 
16 public:
17 
18   enum Type { Byte_t, Word_t, Long_t, Float_t, Double_t, Complex_t, ComplexLong_t, Bad_t };
19 
20 private:
21 
22   Type T;
23 
24 public:
25 
26   static CONST char *ByteMagic, *WordMagic, *LongMagic,
27     *FloatMagic, *DoubleMagic, *ComplexMagic, *ComplexLongMagic, *BadMagic;
28 
29   struct SigTable {
30     Type T;
31     CONST char* Magic;
32   };
33 
34   static CONST SigTable sigTable[];
35 
36 };
37 
38 CONST char
39 *Sig::ByteMagic = "BYTE",
40 *Sig::WordMagic = "WORD",
41 *Sig::LongMagic = "LONG",
42 *Sig::FloatMagic = "FLOA",
43 *Sig::DoubleMagic = "DOUB",
44 *Sig::ComplexMagic = "COMP",
45 *Sig::ComplexLongMagic = "CMPL",
46 *Sig::BadMagic = NULL;
47 
48 
49 CONST Sig::SigTable Sig::sigTable[] = {
50   { Byte_t, ByteMagic },
51   { Word_t, WordMagic },
52   { Long_t, LongMagic },
53   { Float_t, FloatMagic },
54   { Double_t, DoubleMagic },
55   { Complex_t, ComplexMagic },
56   { ComplexLong_t, ComplexLongMagic },
57   { Bad_t, BadMagic }
58 };
59 
main()60 int main() {
61   if (strcmp (Sig::sigTable[0].Magic, "BYTE")
62       || strcmp (Sig::sigTable[1].Magic, "WORD")
63       || strcmp (Sig::sigTable[2].Magic, "LONG")
64       || strcmp (Sig::sigTable[3].Magic, "FLOA")
65       || strcmp (Sig::sigTable[4].Magic, "DOUB")
66       || strcmp (Sig::sigTable[5].Magic, "COMP"))
67     { printf ("FAIL\n"); return 1; }
68   else
69     printf ("PASS\n");
70 }
71