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