1 // RUN: %clang_cc1 -fsyntax-only -Wglobal-constructors %s -verify 2 3 int opaque_int(); 4 5 namespace 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 19 namespace 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 27 namespace 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 34 namespace 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 } 40