blob: 6d0709c5b798ef3080a3fed65bb4f38844c8677a [file] [log] [blame]
John McCall626e96e2010-08-01 20:20:59 +00001// RUN: %clang_cc1 -fsyntax-only -Wglobal-constructors %s -verify
2
3int opaque_int();
4
5namespace test0 {
6 // These should never require global constructors.
7 int a;
8 int b = 20;
9 float c = 5.0f;
10
11 // This global constructor is avoidable based on initialization order.
12 int d = b; // expected-warning {{global constructor}}
13
14 // These global constructors are unavoidable.
15 int e = opaque_int(); // expected-warning {{global constructor}}
16 int f = b; // expected-warning {{global constructor}}
17}
18
19namespace test1 {
20 struct A { int x; };
21 A a;
22 A b = A();
23 A c = { 10 };
24 A d = { opaque_int() }; // expected-warning {{global constructor}}
25}
26
27namespace test2 {
28 struct A { A(); };
29 A a; // expected-warning {{global constructor}}
30 A b[10]; // expected-warning {{global constructor}}
31 A c[10][10]; // expected-warning {{global constructor}}
32}
33
34namespace test3 {
35 struct A { ~A(); };
36 A a; // expected-warning {{global destructor}}
37 A b[10]; // expected-warning {{global destructor}}
38 A c[10][10]; // expected-warning {{global destructor}}
39}