1176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines// RUN: %clang_cc1 -emit-llvm -triple=i386-pc-win32 -fms-compatibility %s -o - | FileCheck %s
2176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
3176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesenum Enum { zero, one, two };
4176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
5176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesstruct __declspec(dllexport) S {
6176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines  // In MS compatibility mode, this counts as a definition.
7176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines  // Since it is exported, it must be emitted even if it's unreferenced.
8176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines  static const short x = 42;
9176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
10176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines  // This works for enums too.
11176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines  static const Enum y = two;
12176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
13176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines  struct NonExported {
14176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines    // dllexport is not inherited by this nested class.
15176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines    // Since z is not referenced, it should not be emitted.
16176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines    static const int z = 42;
17176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines  };
18176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines};
19176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
200e2c34f92f00628d48968dfea096d36381f494cbStephen Hines// CHECK: @"\01?x@S@@2FB" = weak_odr dllexport constant i16 42, comdat, align 2
210e2c34f92f00628d48968dfea096d36381f494cbStephen Hines// CHECK: @"\01?y@S@@2W4Enum@@B" = weak_odr dllexport constant i32 2, comdat, align 4
22176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines// CHECK-NOT: NonExported
23